[Bug symtab/24820] New: .debug_names has incorrect contents

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[Bug symtab/24820] New: .debug_names has incorrect contents

fweimer at redhat dot com

            Bug ID: 24820
           Summary: .debug_names has incorrect contents
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: tromey at sourceware dot org
  Target Milestone: ---

gdb's "save gdb-index -dwarf-5" command creates a .debug_names index
that does not follow what I believe the DWARF standard specifies.
Then, gdb's .debug_names reader assumes that the index is gdb-like.

This is a problem for other readers and other writers; and anyway
gdb should follow the spec regardless.

Here's a simple test case that Pedro wrote:

namespace A {

namespace B {

namespace C {

void D ()



int main ()
  return 0;

gdb creates this index:

Symbol table:
[  0] #0b888030 int: <1> DW_TAG_typedef DW_IDX_compile_unit=0
[  1] #7c9a7f6a main: <2> DW_TAG_subprogram DW_IDX_compile_unit=0
[  2] #ba2c1ff3 A::B::C: <3> DW_TAG_typedef DW_IDX_compile_unit=0
[  3] #ac31fdab A::B::C::D: <2> DW_TAG_subprogram DW_IDX_compile_unit=0
[  4] #7c933edc A::B: <3> DW_TAG_typedef DW_IDX_compile_unit=0
[  5] #0002b606 A: <3> DW_TAG_typedef DW_IDX_compile_unit=0

However, clang creates this index:

[  0] #960aadf5 _ZN1A1B1C1DEv: <46> DW_TAG_subprogram DW_IDX_die_offset=<0x2c>
[  1] #0002b606 A: <57> DW_TAG_namespace DW_IDX_die_offset=<0x26>
[  2] #0b888030 int: <36> DW_TAG_base_type DW_IDX_die_offset=<0x58>
[  3] #7c9a7f6a main: <46> DW_TAG_subprogram DW_IDX_die_offset=<0x42>
[  4] #0002b607 B: <57> DW_TAG_namespace DW_IDX_die_offset=<0x28>
[  5] #0002b608 C: <57> DW_TAG_namespace DW_IDX_die_offset=<0x2a>
[  6] #0002b609 D: <46> DW_TAG_subprogram DW_IDX_die_offset=<0x2c>

clang is more correct here.

First, it puts the mangled name into the index.  From

• If a subprogram or inlined subroutine is included, and has a
DW_AT_linkage_name attribute, there will be an additional index entry for
the linkage name.

Second, my understanding is that the index is intended to hold
simple names, essentially just the DW_AT_name; but gdb puts fully-qualified
names into the index instead.  This does not seem to be spelled out
very explicitly in the DWARF standard, but it's what I recall from a
talk with Cary Coutant and Eric Christopher at a GCC Summit years ago.
Supporting evidence is what clang does (since this was based on some
earlier work by Apple) and also this text in

The intent of the above rules is to provide the consumer with some assurance
that looking
up an unqualified name in the index will yield all relevant debugging
information entries
that provide a defining declaration at global scope for that name.

Note that it's fine for gdb to supplement the name list, though IMO
it would be better not to bother.

You are receiving this mail because:
You are on the CC list for the bug.