nuttx/arch
Lingao Meng 2a6059a206 arch/sim: walk frame-pointer chain for non-running tasks in up_backtrace
The previous up_backtrace() relied entirely on host_backtrace() (a thin
wrapper around glibc's backtrace()), which can only unwind the host
thread that calls it.  As a result, when assert / dump_tasks() walked the
task list and called sched_dumpstack() for every task, every task other
than the currently-running one returned a zero-length backtrace, and the
output was silently dropped.  In practice this meant that on sim only
the crashing task ever produced a usable trace.

Fix this by walking the frame-pointer chain ourselves whenever the
target tcb is not the running task.  Because sim's setjmp/longjmp is
provided by NuttX itself (libs/libc/machine/sim/arch_setjmp_*.S) and not
by host libc, the rbp/rsp/rip (or arm fp/sp/pc) saved in tcb->xcp.regs
are plain unmangled pointers, identical across Linux, macOS and Windows
hosts.  The frame layout ([fp]=prev fp, [fp+1]=return address) is also
shared by every host ABI sim supports (x86, x86_64, ARM, ARM64).

The walker validates that fp lies inside the task's stack and is
properly aligned, and stops when fp[0] is NULL, so a corrupted stack
cannot make us read out of bounds.  The running-task path is unchanged
and still uses host_backtrace() so DWARF unwinding through host
libraries continues to work.

Requires CONFIG_FRAME_POINTER=y so the compiler emits a usable fp link.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2026-06-04 09:54:08 +08:00
..
arm arch/arm/src/stm32h5/stm32_adc: Reset channel counter before conversions 2026-06-02 20:09:31 +08:00
arm64 bcm2711/fb: Use physical device resolution OR force resolution 2026-05-31 11:06:41 +08:00
avr !sys/types.h: change time_t and clock_t to int64_t to align with other OSes 2026-05-19 16:21:28 +08:00
ceva arch/ceva: Replace board_app_initialize 2026-05-02 18:36:46 +08:00
dummy
hc style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
mips !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
misoc include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
or1k include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
renesas !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
risc-v arch/risc-v/espressif: Add BLE support for esp32[-c6|-h2] 2026-06-02 00:08:50 +08:00
sim arch/sim: walk frame-pointer chain for non-running tasks in up_backtrace 2026-06-04 09:54:08 +08:00
sparc !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
tricore arch/tricore: Add hardware debug breakpoint and watchpoint support. 2026-05-22 15:38:36 +08:00
x86 arch/x86: Add palette 256 color to qemu-i486 VGA driver 2026-05-02 09:51:59 -04:00
x86_64 !nuttx: drop redundant casts on tv_sec/tv_nsec and fix printf formats 2026-05-19 16:21:28 +08:00
xtensa xtensa/esp32: Fix RWDT register offsets. 2026-05-27 09:36:43 +08:00
z16 include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
z80 style: fix checkpatch issues after debug.h move 2026-04-07 07:50:06 -03:00
CMakeLists.txt arch/z80: migrate to SPDX identifier 2024-12-02 17:23:25 +08:00
Kconfig arch/tricore: add TriCore up_backtrace() support 2026-05-20 09:20:33 +08:00