From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 22D803858D28; Fri, 10 Feb 2023 12:07:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22D803858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676030840; bh=fivDl3Rqu1qI3e2YlojbjrOnRu9w3A91b2Zm8FMaAUM=; h=From:To:Subject:Date:From; b=aVD9etG1ctmmfAmygJJPoNVo2VVMBPLVCu1XPWJMbKitqPcUOLqhpQYEWP02JwRN4 IiFfDQcq3Y12bKlH5lNeNvj5wigTyZzSvFP8qTlydFl8VQCZJ7icwnPOX2Uvnh9F71 XQbDRswdcWD/WhRgd8qyyEi7y7ctKhl7qg6qrcw0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/cli] Add maint info frame-unwinders X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 779b2502783107368c03421597b095c648f47a3a X-Git-Newrev: be01687991aa6c8517b3e635b8f13b0bac6a851a Message-Id: <20230210120720.22D803858D28@sourceware.org> Date: Fri, 10 Feb 2023 12:07:20 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dbe01687991aa= 6c8517b3e635b8f13b0bac6a851a commit be01687991aa6c8517b3e635b8f13b0bac6a851a Author: Tom de Vries Date: Fri Feb 10 13:07:14 2023 +0100 [gdb/cli] Add maint info frame-unwinders =20 Add a new command "maint info frame-unwinders": ... (gdb) help maint info frame-unwinders List the frame unwinders currently in effect, starting with the highest= \ priority. ... =20 Output for i386: ... $ gdb -q -batch -ex "set arch i386" -ex "maint info frame-unwinders" The target architecture is set to "i386". dummy DUMMY_FRAME dwarf2 tailcall TAILCALL_FRAME inline INLINE_FRAME i386 epilogue NORMAL_FRAME dwarf2 NORMAL_FRAME dwarf2 signal SIGTRAMP_FRAME i386 stack tramp NORMAL_FRAME i386 sigtramp SIGTRAMP_FRAME i386 prologue NORMAL_FRAME ... =20 Output for x86_64: ... $ gdb -q -batch -ex "set arch i386:x86-64" -ex "maint info frame-unwind= ers" The target architecture is set to "i386:x86-64". dummy DUMMY_FRAME dwarf2 tailcall TAILCALL_FRAME inline INLINE_FRAME python NORMAL_FRAME amd64 epilogue NORMAL_FRAME i386 epilogue NORMAL_FRAME dwarf2 NORMAL_FRAME dwarf2 signal SIGTRAMP_FRAME amd64 sigtramp SIGTRAMP_FRAME amd64 prologue NORMAL_FRAME i386 stack tramp NORMAL_FRAME i386 sigtramp SIGTRAMP_FRAME i386 prologue NORMAL_FRAME ... =20 Tested on x86_64-linux. =20 Reviewed-By: Tom Tromey Reviewed-By: Eli Zaretskii Diff: --- gdb/NEWS | 4 ++++ gdb/doc/gdb.texinfo | 4 ++++ gdb/frame-unwind.c | 32 ++++++++++++++++++++++++++++++++ gdb/frame.c | 4 ++-- gdb/frame.h | 4 ++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 1567cbea9bd..b85923cf80d 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -52,6 +52,10 @@ maintenance print record-instruction [ N ] prints how GDB would undo the N-th previous instruction, and if N is positive, it prints how GDB will redo the N-th following instruction. =20 +maintenance info frame-unwinders + List the frame unwinders currently in effect, starting with the highest + priority. + * MI changes =20 ** mi now reports 'no-history' as a stop reason when hitting the end of the diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index eebb6dd422a..7b128053b5a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -40986,6 +40986,10 @@ with the DWARF frame unwinders enabled. If DWARF frame unwinders are not supported for a particular target architecture, then enabling this flag does not cause them to be used. =20 +@kindex maint info frame-unwinders +@item maint info frame-unwinders +List the frame unwinders currently in effect, starting with the highest pr= iority. + @kindex maint set worker-threads @kindex maint show worker-threads @item maint set worker-threads diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c index b708c64f967..76601faa479 100644 --- a/gdb/frame-unwind.c +++ b/gdb/frame-unwind.c @@ -28,6 +28,7 @@ #include "target.h" #include "gdbarch.h" #include "dwarf2/frame-tailcall.h" +#include "cli/cli-cmds.h" =20 struct frame_unwind_table_entry { @@ -337,3 +338,34 @@ frame_unwind_got_address (frame_info_ptr frame, int re= gnum, register_type (gdbarch, regnum), addr); return reg_val; } + +/* Implement "maintenance info frame-unwinders" command. */ + +static void +maintenance_info_frame_unwinders (const char *args, int from_tty) +{ + struct gdbarch *gdbarch =3D target_gdbarch (); + struct frame_unwind_table *table =3D get_frame_unwind_table (gdbarch); + + for (struct frame_unwind_table_entry *entry =3D table->list; entry !=3D = NULL; + entry =3D entry->next) + { + const char *name =3D entry->unwinder->name; + const char *type =3D frame_type_str (entry->unwinder->type); + + gdb_printf (gdb_stdout, "%-16s\t%-16s\n", name, type); + } +} + +void _initialize_frame_unwind (); +void +_initialize_frame_unwind () +{ + /* Add "maint info frame-unwinders". */ + add_cmd ("frame-unwinders", + class_maintenance, + maintenance_info_frame_unwinders, + _("List the frame unwinders currently in effect, " + "starting with the highest priority."), + &maintenanceinfolist); +} diff --git a/gdb/frame.c b/gdb/frame.c index 9235a2ceb38..c69a3ea0cb0 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -439,9 +439,9 @@ frame_id::to_string () const return res; } =20 -/* Return a string representation of TYPE. */ +/* See frame.h. */ =20 -static const char * +const char * frame_type_str (frame_type type) { switch (type) diff --git a/gdb/frame.h b/gdb/frame.h index 4a99bd660df..6ed8db0af56 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -203,6 +203,10 @@ enum frame_type SENTINEL_FRAME }; =20 +/* Return a string representation of TYPE. */ + +extern const char *frame_type_str (frame_type type); + /* A wrapper for "frame_info *". frame_info objects are invalidated whenever reinit_frame_cache is called. This class arranges to invalidate the pointer when appropriate. This is done to help