[riot-notifications] [RIOT-OS/RIOT] sys/shell: add heap command (#10953)

Gunar Schorcht notifications at github.com
Tue Feb 5 18:32:14 CET 2019


### Contribution description

During the development of applications that are using dynamic memory by `malloc` and `free`, it is often helpful to get information about the current heap status. There was an old fragment of a `heap` shell command in the current master which was initially added only for `LPC2387` some years ago but removed with PR #3530 with the introduction of the `newlib_syscalls_default` module.

With this PR provides a module `heap_cmd` which introduces a more general implementation of this `heap` command for all platforms. If module `heap_cmd` is enabled shell command `heap` is added. This command calls a function `heap_stats` which should print the heap statistic `heap size`, `used bytes` and `free bytes`. The function is either realized by `newlib_syscalls_default` or by the CPU if the CPU declares that it has such a function by define `HAVE_HEAP_STATS`. If the function does not exist, it simply prints that the function is not supported.

Following platforms are supported:

- Platforms that use `newlib_syscalls_default` are working out of the box, e.g., all Cortex-M MCUs.
- AVR MCUs implement function `heap_stats`, the implementation requires PR #10934.
- MIPS32R2 CPUs implement function `heap_stats`.
- MSP430 CPUs implement function `heap_stats`, this implementation requires PR #10943 and #10944.
- ESP8266 and ESP32 implement function `heap_stats`
- FE310 CPU implements function `heap_stats`.

Following platforms are not supported:

- native

The PR also includes a shell-based test application `tests/heap_cmd` by which additional commands `malloc` and `free` can be used to test the heap functions.

### Testing procedure

Use `test/heap_cmd` and execute commands `malloc`, `free` and `heap` to test.

### Issues/PRs references

Depends on PR #10934, #10943 and #10944.
You can view, comment on, or merge this pull request online at:

  https://github.com/RIOT-OS/RIOT/pull/10953

-- Commit Summary --

  * sys/shell: pseudomodule heap_cmd added
  * sys/shell: cleanup the heap command approach
  * cpu/esp8266: changes for common heap command
  * cpu/esp32: changes for common heap command
  * cpu/atmega_common: changes for common heap command
  * cpu/mips32r2_common: changes for heap command
  * cpu/msp430_common: changes for heap command
  * cpu/fe310: changes for common heap command
  * tests/heap_cmd: shell-based heap function test app

-- File Changes --

    M cpu/atmega_common/cpu.c (22)
    M cpu/atmega_common/include/cpu_conf.h (5)
    M cpu/esp32/include/cpu_conf.h (5)
    M cpu/esp32/syscalls.c (44)
    M cpu/esp8266/Makefile.dep (1)
    M cpu/esp8266/syscalls.c (39)
    M cpu/fe310/cpu.c (15)
    M cpu/fe310/include/cpu_conf.h (5)
    M cpu/mips32r2_common/Makefile.include (1)
    M cpu/mips32r2_common/cpu.c (34)
    M cpu/msp430_common/include/cpu_conf.h (5)
    A cpu/msp430_common/malloc.c (458)
    M makefiles/pseudomodules.inc.mk (1)
    M sys/newlib_syscalls_default/syscalls.c (19)
    M sys/shell/commands/Makefile (3)
    M sys/shell/commands/sc_heap.c (12)
    M sys/shell/commands/shell_commands.c (6)
    A tests/heap_cmd/Makefile (12)
    A tests/heap_cmd/README.md (5)
    A tests/heap_cmd/main.c (68)

-- Patch Links --

https://github.com/RIOT-OS/RIOT/pull/10953.patch
https://github.com/RIOT-OS/RIOT/pull/10953.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10953
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190205/1a46ba52/attachment-0001.html>


More information about the notifications mailing list