aboutsummaryrefslogtreecommitdiff
path: root/gdb/frame.c
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2022-08-16 16:48:01 +0100
committerAndrew Burgess <aburgess@redhat.com>2022-08-24 14:44:20 +0100
commit70175292616118bad315296ba6180f375326bb6c (patch)
treed8d27502ccae432ab24e068dc659f864546e7089 /gdb/frame.c
parent42bd5254fb5f52f045796e1d9cce07102881d3b1 (diff)
downloadbinutils-70175292616118bad315296ba6180f375326bb6c.zip
binutils-70175292616118bad315296ba6180f375326bb6c.tar.gz
binutils-70175292616118bad315296ba6180f375326bb6c.tar.bz2
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.
Diffstat (limited to 'gdb/frame.c')
-rw-r--r--gdb/frame.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/frame.c b/gdb/frame.c
index ae45e22..e6bebf5 100644
--- a/gdb/frame.c
+++ b/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);
}