xiaoxiang781216 opened a new pull request, #18538:
URL: https://github.com/apache/nuttx/pull/18538
## Summary
* Replace `tools/showstack.sh` with `tools/stackusage.py` for puncover-like
static stack analysis with call graph based worst-case estimation.
* Combines GCC `-fstack-usage` `.su` files with `objdump` call graph to
compute
worst-case total stack depth (self + deepest callee chain).
* Supports all 18 NuttX architectures (ARM, ARM64, RISC-V, x86, Xtensa, MIPS,
AVR, z80, z16, OpenRISC, SPARC, TriCore, HC, Renesas, CEVA, etc.).
* Flags uncertain cases: dynamic/alloca, recursion, indirect calls (function
pointers), and missing `.su` data.
* Summary reasons by default, `--detail` for full call chain info.
* Adds `Documentation/debugging/stackusage.rst`.
## Impact
* New feature added? YES — `stackusage.py` with call graph analysis replaces
the simple `showstack.sh` which only sorted `.su` files by size.
* User impact? YES — `showstack.sh` removed, use `stackusage.py` instead.
* Build impact? NO
* Hardware impact? NO
* Documentation update needed? YES — included (`stackusage.rst`).
* Security implications? NO
* Backward compatibility? `showstack.sh` is removed and replaced by
`stackusage.py`.
## Testing
Build Host(s): Linux x86_64, GCC (arm-none-eabi-gcc)
Target(s): arm, nucleo-f429zi:trace (CONFIG_STACK_USAGE=y)
Testing logs after change:
```
$ python3 tools/stackusage.py -n 20 -d arm-none-eabi-objdump -e nuttx .
Function Self Total File:Line
Reasons
----------------------------- ---- ----- -
--------------------------------- ---------------------------
nxtask_start 32 1180 * task/task_start.c:68
indirect, recursion, no .su
noteram_read 320 1180 * note/noteram_driver.c:471
no .su, recursion, indirect
start 0 1156 * armv7-m/arm_vectors.c:61
no .su, recursion, indirect
__start 16 1156 * chip/stm32_start.c:114
no .su, recursion, indirect
nxtask_startup 24 1148 * sched/task_startup.c:58
indirect, recursion, no .su
nx_start 24 1140 * include/nuttx/init.h:107
no .su, recursion, indirect
group_cancel_children_handler 24 1132 * group/group_killchildren.c:93
indirect, recursion, no .su
dhcpc_showusage 0 1124 *
no .su, recursion, indirect
telnetd_main 0 1124 *
no .su, recursion, indirect
renew_main 0 1124 *
no .su, recursion, indirect
exit 16 1124 * include/stdlib.h:169
indirect, recursion, no .su
show_usage 0 1124 *
no .su, indirect, recursion
trace_main 0 1124 *
no .su, recursion, indirect
ping_main 0 1124 *
no .su, recursion, indirect
nsh_consoleexit 0 1124 *
no .su, indirect, recursion
nx_bringup 8 1116 * init/nx_bringup.c:496
no .su, recursion, indirect
task_setcancelstate 24 1108 * include/sched.h:236
indirect, recursion, no .su
pthread_cancel 24 1108 * include/pthread.h:571
indirect, recursion, no .su
nx_workqueues 8 1108 * init/nx_bringup.c:191
no .su, recursion, indirect
work_start_highpri 16 1100 * wqueue/kwork_thread.c:555
no .su, recursion, indirect
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]