zyfeier opened a new pull request, #21772:
URL: https://github.com/apache/nuttx/pull/21772
## Summary
* Why: the GDB remote protocol and NuttX's internal TCB lookup disagree
about PID 0 - GDB numbers threads from 1, while NuttX reserves PID 0 for the
IDLE task. Mapping GDB thread ids onto NuttX pids with a plain `+1/-1` offset
leaves the idle task reachable through the protocol-side id and lets a protocol
id that hashes to the same pidhash slot shadow the idle task during lookups.
* What: translate the GDB-side thread number into a valid NuttX pid via
PID0_REPLACE (INT32_MAX) at the protocol boundary, so no GDB-visible thread id
ever maps onto the reserved pid 0.
* How: gdb_get_thread(), gdb_query(), gdb_is_thread_active(),
gdb_thread_context() and gdb_send_stop() encode/decode PID0_REPLACE; the old
`pid + 1` / `pid - 1` arithmetic is gone.
## Impact
* Is new feature added? NO - bugfix in existing gdbstub pid handling.
* Impact on user: NO
* Impact on build: NO
* Impact on hardware: gdbstub users only (arm64/arm/risc-v boards with
CONFIG_SERIAL_GDBSTUB).
* Impact on documentation: NO
* Impact on security: NO
* Impact on compatibility: NO
## Testing
I confirm that changes are verified on local setup and works as intended:
* Build Host(s): Linux x86_64 (Ubuntu 24.04)
* Target(s): syntax-level compile check of libs/libc/gdbstub/lib_gdbstub.c
with the in-tree include environment (gcc -fsyntax-only -Wall -Wshadow, clean).
Testing logs (compile check):
```
$ gcc -fsyntax-only -fno-strict-aliasing -Wall -Wstrict-prototypes \
-Wshadow -Wundef -I./include -I./sched -I./libs/libc \
-include ./include/nuttx/config.h lib_gdbstub.c
$ echo $?
0
```
Full board builds of the GDBSTUB configs (qemu-armv8a:gdbstub,
stm32f429i-disco:gdbstub) require the aarch64-none-elf toolchain which is
not available on this host; those builds are covered by the repository CI.
Local CI check `tools/checkpatch.sh -c -u -m -g HEAD~1..HEAD` passes.
--
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]