GDB fetch argument value from the wrong stack-frame.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GDB fetch argument value from the wrong stack-frame.

William Tambe
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
*/
Reply | Threaded
Open this post in threaded view
|

Re: GDB fetch argument value from the wrong stack-frame.

William Tambe
To further expand on the issue that I am seeing, the gdb command "info
frame" reports "Arglist" and "Locals" at the same address.

Any idea what could be the reason causing GDB not to use previous
stack-frame to fetch an argument value ?

On Thu, Aug 15, 2019 at 11:08 PM William Tambe <[hidden email]> wrote:

>
> 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
> */