cgdb

GDB | C - Why is 'Arglist' address differs from the address of the argument?


Below is the stack frame info, within it are displayed the 'Arglist' i.e. starting address of all the arguments, yet when I dump address of the only argument (tcb_handle), I see that the value of the address is different from the value displayed against 'arglist'.

(gdb) info frame 2
Stack frame at 0xdf7ed500:
 pc = 0x10c7d44 in ofm_receive_data (ofm_mgr.c:1428); saved pc = 0x1115de4
 called by frame at 0xdf7ed518, caller of frame at 0xdf7ed430
 source language c.
 Arglist at 0xdf7ed4fc, args: tcb_handle=3699037576
 Locals at 0xdf7ed4fc, Previous frame's sp at 0xdf7ed4f4
 Saved registers:
  r4 at 0xdf7ed4d4, r5 at 0xdf7ed4d8, r6 at 0xdf7ed4dc, r7 at 0xdf7ed4e0, r8 at 0xdf7ed4e4, 
r9 at 0xdf7ed4e8, r10 at 0xdf7ed4ec, r11 at 0xdf7ed4f0, lr at 0xdf7ed4f8
(gdb) p &tcb_handle
$54 = (TCB_HANDLE *) 0xdf7ed4bc

Please help me understand the difference.


Solution

  • The Arglist at 0xdf7ed4fc just tells us where GDB has logically mapped the function arguments in the stack frame, based on debug info and ABI conventions. It’s kind of a symbolic representation.

    When you run p &tcb_handle and see 0xdf7ed4bc, you’re asking GDB to show the actual address of the variable tcb_handle within this function’s frame. So actually… what likely happened here is:

    The discrepancy arises because tcb_handle was passed in a register (per the ABI), and the compiler spilled it into the stack at 0xdf7ed4bc for local use. Meanwhile, GDB’s Arglist address (0xdf7ed4fc) reflects a logical frame layout based on debug info, not the actual variable address. So, it’s a mismatch between GDB’s symbolic model and the compiler’s optimized calling convention.

    If still be curious, can try to disassemble the prologue of ofm_receive_data, then ... likely see something like:

    str r0, [sp, #-offset] ; Spilling tcb_handle to stack