fxysunshine opened a new pull request, #22590:
URL: https://github.com/apache/nuttx/pull/22590

   ## Summary
     * Three improvements to `tools/stackusage.py`:
       1. The call-graph function-boundary regex now skips local labels 
(`.L1729`, `.LBB0_1`) that some toolchains (e.g. TASKING) emit before nearly 
every basic block; treating them as function boundaries hijacked 
`current_func`, routing call edges to ephemeral label nodes and isolating 85% 
of functions on a TASKING ELF (worst-case depth degenerated to self stack only).
       2. New optional `--engine=capstone`: disassembles each function's bytes 
with Capstone and resolves call targets through the phase-1 symbol table, 
bypassing `objdump -d`, whose per-instruction symbol annotation is 
impractically slow on ELFs with very large symbol tables (35 min -> 3.2 s on a 
267 MB TASKING ELF for the call-graph phase).  Default remains objdump (no 
behavior change, no new dependencies); falls back to objdump with a stderr 
notice when capstone is unavailable or the architecture is unsupported.
       3. TriCore CSA (Context Save Area) accounting: each CALL frame adds 64 B 
of upper-context CSA (the CSA pool shares memory with the task/IRQ stack on 
NuttX TriCore, so SP-only totals undercount), `svlcx`-emitting functions add 
another 64 B, reported in a new CSA column; `--no-csa` disables it.  On by 
default for TriCore ELFs only; other architectures are unaffected.
   
   ## Impact
     * Is new feature added?  YES — optional `--engine=capstone` and the CSA 
column / `--no-csa` flag; both opt-in or TriCore-gated, defaults preserve 
current output and behavior.
     * Impact on user?  Host-side analysis tool only; no target code is 
affected.  `stackusage.py` remains dependency-free by default (capstone is 
optional via `pip install capstone`).
     * Impact on build?  NO (tools/ only, not compiled into the firmware).
     * Impact on documentation?  NO (tool help text covers the new options).
     * Impact on security?  NO.
     * Impact on compatibility?  Default output format and values unchanged for 
non-TriCore ELFs.
   
   ## Testing
     I confirm that changes are verified on local setup and works as intended:
     * Build Host(s): Linux x86_64, Ubuntu 22.04, gcc 13.4.0, python3 (capstone 
5.0.3 for the optional engine)
     * Target(s): host tool; exercised against the `sim:nsh` `nuttx` ELF built 
from this tree
     * Both engines verified on the same ELF: default objdump engine produces 
the usual table; `--engine=capstone` completes and resolves the same top 
hot-spots (worst chains can differ slightly between engines, as each resolves 
edges via a different mechanism — symtable vs objdump annotation).
     * `sim:nsh` Make + CMake builds and `ostest` still pass with the change in 
place (`RESULT: PASS` from the pre-upload gate); `tools/checkpatch.sh` clean.
     * TriCore-specific paths (CSA column, `svlcx` detection, `calli`/`calla` 
handling) verified against the original measurements on TASKING/GCC TriCore 
ELFs reported in the commit messages; no TriCore ELF was available in this 
environment for a live re-run.
   
   ## PR verification Self-Check
     * [X] This PR introduces only one functional change.
     * [X] I have updated all required description fields above.
     * [X] My PR adheres to Contributing Guidelines and Documentation (git 
commit title and message, coding standard, etc).
     * [ ] My PR is still work in progress (not ready for review).
     * [X] My PR is ready for review and can be safely merged into a codebase.
   
   Signed-off-by: fangxinyong <[email protected]>
   


-- 
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]

  • [PR] tools/stackusage: skip l... fxysunshine (via GitHub) via commits

Reply via email to