Specify frame by address

Jan Kratochvil jan.kratochvil@redhat.com
Sat Oct 29 18:03:00 GMT 2011


Hi Eli,

On Sat, 29 Oct 2011 19:12:36 +0200, Eli Zaretskii wrote:
>   An argument specifies the frame to select.
>   It can be a stack frame number or the address of the frame.  <<<<<<<<<<
>   With argument, nothing is printed if input is coming from
>   a command file or a user-defined command.
> 
> But what is "the address of the frame"?  I thought that using an
> address of a function (the one shown by "info address") or some
> address shown by the "backtrace" command would do, but none of them
> seems to work.

See the bottom of parse_frame_specification_1.

"address of the frame" is frame_id.stack_addr.  For DWARF it is CFA
(dwarf2_frame_cfa), which is for most arches just unwound SP (not PC!), that
is SP as shown by GDB in the caller.

(gdb) info frame
Stack level 5, frame at 0x7fffffffd880:
[...]
(gdb) up
#6  0x0000000000486e82 in captured_command_loop (data=0x0) at ./main.c:234
(gdb) p/x $sp
$1 = 0x7fffffffd880
(gdb) frame 0
(gdb) frame 0x7fffffffd880
#5  0x00000000006f1421 in current_interp_command_loop () at interps.c:309


> The context of this is that I would like to write a command that
> automatically goes to a frame within a call to a specific function,
> because that command needs to access variables local to that function.

Such command really needs to iterate the frames and compare PC there.


Regards,
Jan



More information about the Gdb mailing list