]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb: fail for 'maint print frame-id LEVEL' of an invalid frame
authorAndrew Burgess <aburgess@redhat.com>
Tue, 20 Jan 2026 15:08:38 +0000 (15:08 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Tue, 20 Jan 2026 20:39:15 +0000 (20:39 +0000)
commit190609444ccf2dff54f7c890d04d23e0db5c2220
tree35f46a0f5c86ed7db8a8fbb5cd15e0e507724034
parentb2c74dcb465ccec1289dde0e1c8d299d85bb34f8
gdb: fail for 'maint print frame-id LEVEL' of an invalid frame

I noticed that 'maint print frame-id LEVEL' will always print a
frame-id, just not always for LEVEL, for example:

  (gdb) bt
  #0  woof () at stack.c:4
  #1  0x000000000040111f in bar () at stack.c:10
  #2  0x000000000040112f in foo () at stack.c:16
  #3  0x000000000040113f in main () at stack.c:22
  (gdb) maintenance print frame-id 4
  frame-id for frame #3: {stack=0x7fffffffa640,code=0x0000000000401131,!special}
  (gdb)

Notice that the request was for the frame-id of #4, which doesn't
exist, but what I got was the frame-id for #3.

Fix this by adding a check to maintenance_print_frame_id (frame.c), so
the new behaviour is:

  (gdb) maintenance print frame-id 4
  No frame at level 4.
  (gdb)

This matches the behaviour of the 'frame' command:

  (gdb) frame 4
  No frame at level 4.
  (gdb)

I've added a new test to cover this case.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/frame.c
gdb/testsuite/gdb.base/maint-print-frame-id.exp