GDB fetch argument value from the wrong stack-frame.

William Tambe tambewilliam@gmail.com
Fri Aug 16 04:08:00 GMT 2019


I am running into an issue where when using the command "print arg"
where arg is a function argument, GDB use an address within the
current stack-frame instead of from the previous stack-frame.

Any idea what needs to be implemented such that when accessing a
function argument, GDB use instead an address from the previous
stack-frame ?

Below is an ascii drawing of a stackframe description:

/* Stack after function's prologue:
  SP ->+-----------------------+                         low addr
       |   func arguments      | \
       | that are created for  |  | pretendargs_size
       | args of vararg funcs. | / |
       +-----------------------+   | outargs_size (Include pretendargs_size)
       |                       |   |
       |    func arguments     |  /
       |                       | /
       +-----------------------+
       |                       | \
       |  local variables      |  | localvars_size
       |                       | /
       +-----------------------+
       |  register save area   | \
  FP ->+-----------------------+  |
       |  previous frame ptr   |  | savedregs_size
       +-----------------------+  |
       |    return address     | /                       Callee
  AP ->+-----------------------+------------------------------------
       |   func arguments,     |                         Caller
       | including those that  |
       | are created for args  |
       |   of vararg funcs.    |
       +-----------------------+
       |                       |
       |   local variables     |
       |                       |
       +-----------------------+                         high addr
*/



More information about the Gdb mailing list