tools: replace showstack.sh with stackusage.py#18538
tools: replace showstack.sh with stackusage.py#18538xiaoxiang781216 wants to merge 2 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Replaces the legacy showstack.sh stack-usage sorter with a Python-based static stack analyzer that can combine GCC .su data with an objdump-derived call graph to estimate worst-case stack depth, and documents the new workflow.
Changes:
- Added
tools/stackusage.pyimplementing.suparsing, optional call-graph extraction, and worst-case stack depth estimation with uncertainty reasons. - Removed
tools/showstack.shand updatedKconfighelp text to point users at the new tool. - Added new documentation page and linked it from the debugging docs index.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/stackusage.py | New Python analyzer for per-function self + worst-case total stack usage with uncertainty reporting. |
| tools/showstack.sh | Removed the old .su sorting shell script. |
| Kconfig | Updates STACK_USAGE help text to reference tools/stackusage.py. |
| Documentation/debugging/stackusage.rst | New documentation for using the new stack usage analyzer. |
| Documentation/debugging/index.rst | Adds stackusage.rst to the debugging docs toctree. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
43c8726 to
2935f94
Compare
|
Why is copilot reviewing this PR? Is the feature enabled on the NuttX repo? |
I request Coplit review my patch |
Okay! Makes sense, thanks! |
9af8002 to
02605f7
Compare
|
@xiaoxiang781216 same comment as @raiden00pl did here: #18396 If this code is supposed to be integrated in the build system, it is better to avoid Python dependence. In that PR @Abhishekmishra2808 rewrote this Python script as C file. I understand that currently it is not used in the build-system, but may it become integrated into build system in the future? If that is the case, then we need to rewrite it. |
|
@acassis this PR is a completely different case. In this PR, we don't add Python as a dependency to the build system. This PR is about a debug tool; the debug tools in nuttx have been using Python for a long time. Using Python for such tools is an obvious choice for me personally, it gives endless possibilities and is now easy to vibe-code |
Hi @raiden00pl thank you for explanation. Ok, so everything is fine for this PR |
02605f7 to
4bc2ef0
Compare
4bc2ef0 to
9a773cb
Compare
9a773cb to
5495354
Compare
Replace pyelftools and capstone Python library dependencies with subprocess calls to standard toolchain binaries (readelf, objdump, addr2line). This eliminates all external Python package requirements, removes manual DWARF parsing, and reduces the code from 818 to 563 lines. Works with both GNU and LLVM toolchains via the -p/--prefix option: -p arm-none-eabi- (GCC cross-compiler) -p llvm- (LLVM/clang toolchain) Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
5495354 to
5ffce6a
Compare
Add RST documentation for the stackusage.py static stack analysis tool, covering usage, command-line options, output format, and markers. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
5ffce6a to
9b4bf38
Compare
Summary
tools/showstack.shwithtools/stackusage.pyfor static stackanalysis with call graph based worst-case estimation.
.debug_frameCFA offsets viareadelf -wFfor per-functionstack sizes, builds call graphs from
objdump -ddisassembly, resolvessource locations via
addr2line -fe.plus standard toolchain binaries (
readelf,objdump,addr2line).-p/--prefixoption(e.g.
-p arm-none-eabi-for GCC,-p llvm-for LLVM).x86, x86_64, RISC-V, MIPS, Xtensa, PowerPC, SPARC, TriCore, SuperH, etc.).
and missing DWARF data.
Documentation/debugging/stackusage.rst.Impact
stackusage.pyreplacesshowstack.sh.showstack.shremoved, usestackusage.pyinstead.stackusage.rst).showstack.shis removed and replaced bystackusage.py.Testing
Build Host(s): Linux x86_64
Target(s): nucleo-f429zi:nsh (arm-none-eabi-gcc, CONFIG_DEBUG_SYMBOLS=y)
Testing logs after change: