forked from Imagelibrary/binutils-gdb
gdb: new 'maint print frame-id' command
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.
This commit is contained in:
28
gdb/frame.c
28
gdb/frame.c
@@ -3116,6 +3116,30 @@ the rest of the stack trace."),
|
||||
},
|
||||
};
|
||||
|
||||
/* Implement the 'maintenance print frame-id' command. */
|
||||
|
||||
static void
|
||||
maintenance_print_frame_id (const char *args, int from_tty)
|
||||
{
|
||||
struct frame_info *frame;
|
||||
|
||||
/* Use the currently selected frame, or select a frame based on the level
|
||||
number passed by the user. */
|
||||
if (args == nullptr)
|
||||
frame = get_selected_frame ("No frame selected");
|
||||
else
|
||||
{
|
||||
int level = value_as_long (parse_and_eval (args));
|
||||
frame = find_relative_frame (get_current_frame (), &level);
|
||||
}
|
||||
|
||||
/* Print the frame-id. */
|
||||
gdb_assert (frame != nullptr);
|
||||
gdb_printf ("frame-id for frame #%d: %s\n",
|
||||
frame_relative_level (frame),
|
||||
get_frame_id (frame).to_string ().c_str ());
|
||||
}
|
||||
|
||||
void _initialize_frame ();
|
||||
void
|
||||
_initialize_frame ()
|
||||
@@ -3160,4 +3184,8 @@ When non-zero, frame specific internal debugging is enabled."),
|
||||
NULL,
|
||||
show_frame_debug,
|
||||
&setdebuglist, &showdebuglist);
|
||||
|
||||
add_cmd ("frame-id", class_maintenance, maintenance_print_frame_id,
|
||||
_("Print the current frame-id."),
|
||||
&maintenanceprintlist);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user