From: Tom de Vries Date: Sun, 9 Feb 2020 12:32:26 +0000 (+0100) Subject: [gdb] Mention CU offset for if verbose X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2e9276136b1c2f54e01a921b3911e40297f16938;p=binutils-gdb.git [gdb] Mention CU offset for if verbose Say we're debugging a test-case with CUs with name "", meaning not originating from a single file compilation, and use the verbose setting: ... $ gdb -iex "set verbose on" -batch cc1 Reading symbols from cc1... Reading in symbols for ... \ and /tmp/trunk/gcc/attribs.c... \ ... and /tmp/trunk/gcc/tree-ssa-reassoc.c... \ done. ... From the "/tmp/trunk/gcc/attribs.c" message, it's clear which CU is loaded. But that's not the case for the "" message. The message uses the filename field of struct partial_symtab, which is documented like this: ... /* Name of the source file which this partial_symtab defines, or if the psymtab is anonymous then a descriptive name for debugging purposes, or "". It must not be NULL. */ ... So, fix this by setting the filename field to a more descriptive name than "", by appending the CU offset. This way, we print instead: ... $ gdb -iex "set verbose on" -batch cc1 Reading symbols from cc1... Reading in symbols for @0x41146d9 \ and /tmp/trunk/gcc/attribs.c... \ ... \ and /tmp/trunk/gcc/tree-ssa-reassoc.c... \ done. ... Build and reg-tested on x86_64-linux. gdb/ChangeLog: 2020-02-09 Tom de Vries * dwarf2read.c (process_psymtab_comp_unit_reader): Append CU offset to filename if it matches "". --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5f40634e265..c751df7d9a5 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-02-09 Tom de Vries + + * dwarf2read.c (process_psymtab_comp_unit_reader): Append CU offset to + filename if it matches "". + 2020-02-09 Hannes Domani * windows-tdep.c (struct enum_value_name): New struct. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index d1622dc74fa..9e66e613cd6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -7252,9 +7252,17 @@ process_psymtab_comp_unit_reader (const struct die_reader_specs *reader, prepare_one_comp_unit (cu, comp_unit_die, pretend_language); /* Allocate a new partial symbol table structure. */ + gdb::unique_xmalloc_ptr debug_filename; + static const char artificial[] = ""; filename = dwarf2_string_attr (comp_unit_die, DW_AT_name, cu); if (filename == NULL) filename = ""; + else if (strcmp (filename, artificial) == 0) + { + debug_filename.reset (concat (artificial, "@", + sect_offset_str (per_cu->sect_off), NULL)); + filename = debug_filename.get (); + } pst = create_partial_symtab (per_cu, filename);