hujun260 opened a new pull request, #17946:
URL: https://github.com/apache/nuttx/pull/17946
## Summary
This PR includes a series of fixes and improvements for the GDB stub and
ARM64
backtrace functionality:
1. **Fix SMP call in IRQ context**: Replace synchronous SMP calls with
asynchronous
equivalents to prevent deadlocks when gdbstub debugpoint operations are
invoked
from interrupt handlers.
2. **Fix ARM64 backtrace register access**: Correct register access in
arm64_backtrace
to use TCB context directly instead of running_regs(), ensuring accurate
stack
traces for non-running tasks.
3. **Improve conditional compilation**: Add proper architecture guards to
prevent
compilation errors in builds without debug support.
## Changes
The following modifications have been made:
1. **libs/libc/gdbstub/lib_gdbstub.c**:
- Add static `smp_call_data_s` structure for SMP communication
- Replace `nxsched_smp_call()` with `nxsched_smp_call_async()` in
`gdb_debugpoint_add()`
- Replace `nxsched_smp_call()` with `nxsched_smp_call_async()` in
`gdb_debugpoint_remove()`
- Initialize async call data using `nxsched_smp_call_init()`
- Add `CONFIG_ARCH_HAVE_DEBUG` guard to prevent undefined references
2. **arch/arm64/src/common/arm64_backtrace.c**:
- Fix `up_backtrace()` to access registers from `tcb->xcp.regs` directly
- Replace `running_regs()[REG_X29]` with `(void
*)(tcb->xcp.regs)[REG_X29]`
- Replace `running_regs()[REG_ELR]` with `(void
*)(tcb->xcp.regs)[REG_ELR]`
- Ensures backtrace works correctly for any task, not just the running
task
## Testing
Tested on:
- **Platform**: NuttX simulator with SMP and debug support enabled
- **Target**: GDB stub debug operations and ARM64 task backtrace
- **Method**:
- Verified SMP debugpoint operations work correctly when called from IRQ
handlers
- Verified backtrace generation for ARM64 tasks with accurate register
values
- Tested with CONFIG_DEBUG_SYMBOLS and CONFIG_GDBSTUB enabled
- **Result**:
- No deadlocks observed when setting/removing debug points from interrupt
context
- Backtrace output correctly reflects TCB register state rather than
current CPU state
## Impact
- **Stability**: Prevents potential deadlocks in debugger operations on SMP
systems
- **Correctness**: Improves accuracy of stack traces for all ARM64 tasks
- **Compatibility**: No breaking changes; all existing APIs remain unchanged
- **Code Quality**: Improves robustness of debug infrastructure
- **Performance**: Negligible impact; async calls are more efficient than
sync in IRQ context
--
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]