From: Tom de Vries Date: Tue, 8 Oct 2024 10:27:20 +0000 (+0200) Subject: [gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types X-Git-Tag: gdb-16-branchpoint~705 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5ad960fcdb6732c805d2a235efc8a40df644e03e;p=thirdparty%2Fbinutils-gdb.git [gdb/symtab] Fix gdb.dwarf2/enum-type-c++.exp with cc-with-debug-types When running test-case gdb.dwarf2/enum-type-c++.exp with target board cc-with-debug-types, we run into: ... (gdb) FAIL: gdb.dwarf2/enum-type-c++.exp: val1 has a parent ... because val1 has no parent: ... [31] ((cooked_index_entry *) 0x7efedc002e90) name: val1 canonical: val1 qualified: val1 DWARF tag: DW_TAG_enumerator flags: 0x0 [] DIE offset: 0xef parent: ((cooked_index_entry *) 0) ... [37] ((cooked_index_entry *) 0x38ffd280) name: val1 canonical: val1 qualified: val1 DWARF tag: DW_TAG_enumerator flags: 0x0 [] DIE offset: 0xef parent: ((cooked_index_entry *) 0) ... There are two entries, which seems to be an inefficiency, but for now let's focus on the correctness issue. The debug info for val1 looks like this: ... <1>: Abbrev Number: 2 (DW_TAG_namespace) DW_AT_name : ns DW_AT_declaration : 1 <2>: Abbrev Number: 12 (DW_TAG_class_type) DW_AT_name : A DW_AT_declaration : 1 <3>: Abbrev Number: 13 (DW_TAG_enumeration_type) DW_AT_declaration : 1 <1>
: Abbrev Number: 14 (DW_TAG_enumeration_type) DW_AT_specification: <0xd6> <2>: Abbrev Number: 5 (DW_TAG_enumerator) DW_AT_name : val1 DW_AT_const_value : 1 ... Fix this by: - adding a cooked index entry for DIE 0xcb (and consequently for child DIE 0xd3), by marking it interesting, - making sure that the entry for DIE 0xcb has a name, and - using the entry for DIE 0xd3 as parent entry for DIE 0xdd. Tested on aarch64-linux. Approved-By: Tom Tromey --- diff --git a/gdb/dwarf2/abbrev.c b/gdb/dwarf2/abbrev.c index bae8d8b3bed..c30db1ee31a 100644 --- a/gdb/dwarf2/abbrev.c +++ b/gdb/dwarf2/abbrev.c @@ -276,7 +276,8 @@ abbrev_table::read (struct dwarf2_section_info *section, } else if ((cur_abbrev->tag == DW_TAG_structure_type || cur_abbrev->tag == DW_TAG_class_type - || cur_abbrev->tag == DW_TAG_union_type) + || cur_abbrev->tag == DW_TAG_union_type + || cur_abbrev->tag == DW_TAG_namespace) && cur_abbrev->has_children) { /* We have to record this as interesting, regardless of how diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 95e7d6aee31..ea31d8dd851 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16310,7 +16310,8 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, want to treat them as definitions. */ if ((abbrev->tag == DW_TAG_class_type || abbrev->tag == DW_TAG_structure_type - || abbrev->tag == DW_TAG_union_type) + || abbrev->tag == DW_TAG_union_type + || abbrev->tag == DW_TAG_namespace) && abbrev->has_children) *flags |= IS_TYPE_DECLARATION; else @@ -16635,7 +16636,7 @@ cooked_indexer::index_dies (cutu_reader *reader, else if (defer != 0) recurse_parent = defer; else - recurse_parent = parent_entry; + recurse_parent = this_parent_entry; info_ptr = recurse (reader, info_ptr, recurse_parent, fully); }