-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/shell: add heap command #10953
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sys/shell: add heap command #10953
Conversation
9ba068c to
82cedd4
Compare
73eea1f to
d1431d7
Compare
|
tested on AVR (arduino-mega2560) but looks weird: |
|
on ESP8266 it works, question: size is in HEX too, right? However, I think DEC is more natural to the user. |
|
@smlng Thanks for testing.
Strange, I tested it with arduino-mega2560 too before I opened the PR. It seems that variables |
No, should be in decimal. |
Output on esp8266:
|
isn't that one included here? |
|
Oh I see, it is not 😞 my bad, will retry ... |
No, it is kept completely separate since compilation of this PR works also without the changes of PR #10934. |
|
okay rebased on top of #10934, and it works: |
Ok, it seems to be HEX for you but it isn't 😉 There is some overhead for chunk management structures that decreases the heap. For example, if you use |
|
yeah, was already expecting some kind of overhead being involved here - but it fits so nicely with HEX. However, I tried more values for malloc and can confirm it is not HEX but rather DEC as it should be. so my initial limited tests matched just by chance. |
|
please rebase and squash as needed |
|
@smlng I had to resolve conflicts for MSP430. Therefore, I would like to test it with WSN430 nodes in IoT-LAB again before I push it, but the testbed is down at the moment. |
d1431d7 to
740618d
Compare
|
Tested again |
smlng
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested again, still works. I would include this and improve/change later to (maybe) separate the print from getting the stats, as I suggested earlier. However, that can be done in a separate PR.
I also checked code sizes, it has no effect if not used ... as expected, so all good here.
|
please check and fix CI errors (cppcheck is not happy) and also squash (if needed) |
|
Hm ... wierd Here, So, I could solve it only by hard casting data types. But casting to |
|
I'd like to maybe get a second opinion: maybe @kaspar030, @MrKevinWeiss or @MichelRottleuthner : any objections from your sides? To me this looks good to go, it doesn't increase binary size when unused but might still be handy for debugging and such. |
|
I would like to see an on target test to go along with this. Just a simple heap, malloc, heap, free, heap just so it is easy to run tests on all boards. Also the |
Also, isn't that default by now? |
Just to clarify. Although it should be possible to execute such a sequence of these commands, the output of the |
|
@MrKevinWeiss I wrote a short test [UPDATE] |
|
@MrKevinWeiss The test program is working. The PR would have to be squashed. |
|
Great, I will look at it shortly. Many thanks for all the work! |
MrKevinWeiss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retested with the automatic test provided. ACK and please squash.
The any boards failed due to terminal problems and not the implementation:
# Build '10953' with 'tests/heap_cmd'
#### arduino-mega2560/failuresummary.md
#### cc2650-launchpad/failuresummary.md
#### ek-lm4f120xl/failuresummary.md
#### esp32-wroom-32/failuresummary.md
Failures during test:
- [tests/heap_cmd](tests/heap_cmd/test.failed)
#### frdm-k64f/failuresummary.md
#### frdm-kw41z/failuresummary.md
#### msba2/failuresummary.md
#### mulle/failuresummary.md
Failures during test:
- [tests/heap_cmd](tests/heap_cmd/test.failed)
#### nrf52dk/failuresummary.md
#### nucleo-f103rb/failuresummary.md
#### pba-d-01-kw2x/failuresummary.md
#### sltb001a/failuresummary.md
#### stm32f3discovery/failuresummary.md
|
please squash |
5a4038a to
37debfd
Compare
|
Squashed |
|
@MrKevinWeiss Thanks for your support. |
|
Anytime 😎 |
Contribution description
During the development of applications that are using dynamic memory by
mallocandfree, it is often helpful to get information about the current heap status. There was an old fragment of aheapshell command in the current master which was initially added only forLPC2387some years ago but removed with PR #3530 with the introduction of thenewlib_syscalls_defaultmodule.With this PR provides a module
heap_cmdwhich introduces a more general implementation of thisheapcommand for all platforms. If moduleheap_cmdis enabled shell commandheapis added. This command calls a functionheap_statswhich should print the heap statisticheap size,used bytesandfree bytes. The function is either realized bynewlib_syscalls_defaultor by the CPU if the CPU declares that it has such a function by defineHAVE_HEAP_STATS. If the function does not exist, it simply prints that the function is not supported.Following platforms are supported:
newlib_syscalls_defaultare working out of the box, e.g., all Cortex-M MCUs.heap_stats, the implementation requires PR cpu/atmega_common: make remaining RAM available as heap #10934.heap_stats.heap_stats, this implementation requires PR cpu/msp430_common: set top of heap for sbrk #10943 and cpu/msp430_common: add real malloc/free functions #10944.heap_statsheap_stats.Following platforms are not supported:
The PR also includes a shell-based test application
tests/heap_cmdby which additional commandsmallocandfreecan be used to test the heap functions.Testing procedure
Use
tests/heap_cmdand execute commandsmalloc,freeandheapto test.Issues/PRs references
Depends on PR #10934, #10943 and #10944.