This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 60d5ce41cd0 include/nuttx/sched.h: Align struct tcbinfo_s.
60d5ce41cd0 is described below
commit 60d5ce41cd073f475e41957cef7a9944282a0956
Author: Max Kriegleder <[email protected]>
AuthorDate: Mon Oct 26 22:01:27 2026 +0100
include/nuttx/sched.h: Align struct tcbinfo_s.
struct tcbinfo_s is packed, so g_tcbinfo can land on an odd address.
On a Cortex-M it lives in .text, and GDB reports the address of a
symbol there with bit 0 cleared (as for Thumb code): `p &g_tcbinfo`
gave 0x1987a for a g_tcbinfo at 0x1987b, and GDB passed 0x1987a to the
J-Link GDB server in its symbol lookup. The J-Link RTOS plugin
(tools/jlink-nuttx.c) then read every TCB offset one byte off: wrong
priorities and states, missing threads. nxgdb reads g_tcbinfo through
GDB the same way.
Align the type to 8 bytes. The members are naturally aligned already,
so the layout (24 bytes, the same offsets) does not change.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Max Kriegleder <[email protected]>
---
include/nuttx/sched.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 75fedb3a555..cc912629f8f 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -790,10 +790,14 @@ struct pthread_entry_s
/* struct tcbinfo_s *********************************************************/
/* The structure save key filed offset of tcb_s while can be used by
- * debuggers to parse the tcb information
+ * debuggers to parse the tcb information.
+ *
+ * Aligned so that g_tcbinfo never lands on an odd address: GDB clears
+ * bit 0 of addresses in code sections on Thumb targets, so a debugger
+ * looking it up by symbol would read it one byte off.
*/
-begin_packed_struct struct tcbinfo_s
+begin_packed_struct struct aligned_data(8) tcbinfo_s
{
uint16_t pid_off; /* Offset of tcb.pid */
uint16_t state_off; /* Offset of tcb.task_state */