[PING][PATCH 2/2] [gdb/symtab] Add maint expand-symtabs -verbose
Joel Brobecker
brobecker@adacore.com
Sat Jan 8 10:55:22 GMT 2022
Hi Tom,
On Mon, Jan 03, 2022 at 03:53:02PM +0100, Tom de Vries via Gdb-patches wrote:
> On 11/12/21 18:16, Tom de Vries via Gdb-patches wrote:
> > Add a -verbose option to command "maint expand-symtabs", such that we
> > have (abbreviating /home/abuild/rpmbuild/BUILD to $BUILD):
> > ...
> > $ gdb -q -batch ./outputs/gdb.dwarf2/dw2-symtab-includes/dw2-symtab-includes \
> > -ex "maint expand-symtabs -verbose"
> > Expanded symtab for file $BUILD/glibc-2.34/sysdeps/x86_64/crtn.S at 0x26c9f00
> > Expanded symtab for file <unknown> at 0x26ca1e0
> > Expanded symtab for file $BUILD/glibc-2.34/sysdeps/x86_64/crti.S at 0x26ca540
> > Expanded symtab for file $BUILD/glibc-2.34/csu/static-reloc.c at 0x26ca860
> > Expanded symtab for file $BUILD/glibc-2.34/csu/init.c at 0x2716890
> > Expanded symtab for file $BUILD/glibc-2.34/sysdeps/x86/abi-note.c at 0x2708a90
> > Expanded symtab for file $BUILD/glibc-2.34/sysdeps/x86_64/start.S at 0x2717810
> > ...
> >
> > Note that the <unknown> corresponds to a CU without name:
> > ...
> > <0><963>: Abbrev Number: 2 (DW_TAG_compile_unit)
> > <964> DW_AT_language : 2 (non-ANSI C)
> > <965> DW_AT_stmt_list : 0x1e0
> > <1><969>: Abbrev Number: 3 (DW_TAG_imported_unit)
> > ...
> >
> > Tested on x86_64-linux.
>
> Ping.
Thanks for the patch.
This seems reasonable to me, so OK for me (minus the changes to
the documentation).
> > ---
> > gdb/doc/gdb.texinfo | 5 +++--
> > gdb/symmisc.c | 14 +++++++++++++-
> > gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp | 3 ++-
> > 3 files changed, 18 insertions(+), 4 deletions(-)
> >
> > diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> > index fc8e5bdf3db..fbf6e8549e1 100644
> > --- a/gdb/doc/gdb.texinfo
> > +++ b/gdb/doc/gdb.texinfo
> > @@ -39159,10 +39159,11 @@ Use this to check, for example, whether a symbol is in one but not the other.
> > Check the consistency of currently expanded symtabs.
> > @kindex maint expand-symtabs
> > -@item maint expand-symtabs [@var{regexp}]
> > +@item maint expand-symtabs @r{[}-verbose@r{]} [@var{regexp}]
> > Expand symbol tables.
> > If @var{regexp} is specified, only expand symbol tables for file
> > -names matching @var{regexp}.
> > +names matching @var{regexp}. If @code{-verbose} is passed, mentions
> > +expanded symbol tables.
> > @kindex maint set catch-demangler-crashes
> > @kindex maint show catch-demangler-crashes
> > diff --git a/gdb/symmisc.c b/gdb/symmisc.c
> > index e38ceb6bda1..7597487201e 100644
> > --- a/gdb/symmisc.c
> > +++ b/gdb/symmisc.c
> > @@ -904,6 +904,7 @@ maintenance_check_symtabs (const char *ignore, int from_tty)
> > static void
> > maintenance_expand_symtabs (const char *args, int from_tty)
> > {
> > + bool verbose = args != nullptr && check_for_argument (&args, "-verbose");
> > char *regexp = NULL;
> > /* We use buildargv here so that we handle spaces in the regexp
> > @@ -923,6 +924,17 @@ maintenance_expand_symtabs (const char *args, int from_tty)
> > if (regexp)
> > re_comp (regexp);
> > + auto on_expansion = [&] (compunit_symtab *symtab)
> > + {
> > + if (verbose)
> > + printf_filtered ("Expanded symtab for file %s at %s\n",
> > + symtab_to_fullname (COMPUNIT_FILETABS (symtab)),
> > + host_address_to_string (symtab));
> > +
> > + /* Keep going. */
> > + return true;
> > + };
> > +
> > for (struct program_space *pspace : program_spaces)
> > for (objfile *objfile : pspace->objfiles ())
> > objfile->expand_symtabs_matching
> > @@ -934,7 +946,7 @@ maintenance_expand_symtabs (const char *args, int from_tty)
> > },
> > NULL,
> > NULL,
> > - NULL,
> > + on_expansion,
> > SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
> > UNDEF_DOMAIN,
> > ALL_DOMAIN);
> > diff --git a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp
> > index 5eecc8f58ef..a97c5328f7c 100644
> > --- a/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp
> > +++ b/gdb/testsuite/gdb.dwarf2/dw2-symtab-includes.exp
> > @@ -70,7 +70,8 @@ if { [readnow] } {
> > gdb_test_no_output "maint info symtabs" $test
> > # Expand dw2-symtab-includes.h symtab
> > -gdb_test "maint expand-symtab dw2-symtab-includes.h"
> > +gdb_test "maint expand-symtab -verbose dw2-symtab-includes.h" \
> > + "Expanded symtab for file <unknown> at $hex"
> > # Check that there are includes.
> > gdb_test "maint info symtabs" \
--
Joel
More information about the Gdb-patches
mailing list