[PATCH] gdb: new 'maint print frame-id' command
Andrew Burgess
aburgess@redhat.com
Wed Aug 17 13:20:22 GMT 2022
Bruno Larsen via Gdb-patches <gdb-patches@sourceware.org> writes:
> On 16/08/2022 19:18, Andrew Burgess via Gdb-patches wrote:
>> When debugging a certain class of GDB bug, I often end up wanting to
>> know what GDB thinks the frame-id is in a particular frame. It's
>> not too hard to pull this from some debug output, but I thought it
>> might be nice if there was a maintenance command that could tell us.
>>
>> This commit adds 'maint print frame-id' which prints the frame-id of
>> the currently selected frame. You can also pass a frame level number
>> to find the frame-id for a specific frame.
>>
>> There's a new test too.
>
> Hi Andrew,
>
> Thanks for this, it coincidentally really helps my current situation!
> All the C code looks fine to me, but the texinfo failed to compile
> (details below). Fixing that, this patch looks great, I'd encourage you
> to approve your patch!
>
>> ---
>> gdb/NEWS | 4 ++
>> gdb/doc/gdb.texinfo | 17 +++++
>> gdb/frame.c | 28 ++++++++
>> gdb/testsuite/gdb.base/maint-print-frame-id.c | 40 +++++++++++
>> .../gdb.base/maint-print-frame-id.exp | 68 +++++++++++++++++++
>> 5 files changed, 157 insertions(+)
>> create mode 100644 gdb/testsuite/gdb.base/maint-print-frame-id.c
>> create mode 100644 gdb/testsuite/gdb.base/maint-print-frame-id.exp
>>
>> diff --git a/gdb/NEWS b/gdb/NEWS
>> index f2040e26c0c..49ac714efda 100644
>> --- a/gdb/NEWS
>> +++ b/gdb/NEWS
>> @@ -91,6 +91,10 @@ show style disassembler symbol
>> The 'disassembler address' and 'disassembler symbol' styles are
>> aliases for the 'address' and 'function' styles respectively.
>>
>> +maintenance print frame-id [ LEVEL ]
>> + Print GDB's internal frame-id for the frame at LEVEL. If LEVEL is
>> + not given, then print the frame-id for the currently selected frame.
>> +
>> * Changed commands
>>
>> maintenance info line-table
>> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
>> index 82cb1c8d668..ca958173b57 100644
>> --- a/gdb/doc/gdb.texinfo
>> +++ b/gdb/doc/gdb.texinfo
>> @@ -40142,6 +40142,23 @@
>>
>> Takes an optional file parameter.
>>
>> +@kindex maint print frame-id
>> +@item maint print frame-id
>> +@itemx maint print frame-id @var{level}
>> +Print @value{GDBN}'s internal frame-id for the frame at relative
>> +@var{level}, or for the currently selected frame when @var{level} is
>> +not given.
>> +
>> +If used, @var{level} should be an integer, as displayed in the
>> +@command{backtrace} output.
>> +
>> +@smallexample
>> +(@value{GDBP}) maint print frame-id
>> +frame-id for frame #0: {stack=0x7fffffffac70,code=0x0000000000401106,!special}
>> +(@value{GDBP}) maint print frame-id 2
>> +frame-id for frame #2: {stack=0x7fffffffac90,code=0x000000000040111c,!special}
>
> In this line and 2 lines above, makeinfo was complaining about misplaced
> { and };
>
> Looking at the example above, it looks like it should be
>
> frame-id for frame #2:
> @{stack=0x7fffffffac90,code=0x000000000040111c,!special@}
Thanks. I've fixed this locally, and will include this fix when I check
this in (after giving others a chance to comment).
Thanks,
Andrew
More information about the Gdb-patches
mailing list