binutils-gdb/gdb/dwarf2
Tom de Vries 21528df40e [gdb/symtab] Revert "Change handling of DW_TAG_enumeration_type in DWARF scanner"
After adding dwarf assembly to test-case gdb.dwarf2/enum-type.exp that adds
this debug info:
...
 <1><11f>: Abbrev Number: 3 (DW_TAG_enumeration_type)
    <120>   DW_AT_specification: <0x130>
 <2><124>: Abbrev Number: 4 (DW_TAG_enumerator)
    <125>   DW_AT_name        : val1
    <12a>   DW_AT_const_value : 1
 <2><12b>: Abbrev Number: 0
 <1><12c>: Abbrev Number: 5 (DW_TAG_namespace)
    <12d>   DW_AT_name        : ns
 <2><130>: Abbrev Number: 6 (DW_TAG_enumeration_type)
    <131>   DW_AT_name        : e
    <133>   DW_AT_type        : <0x118>
    <137>   DW_AT_declaration : 1
...
I run into an assertion failure:
...
(gdb) file enum-type^M
Reading symbols from enum-type...^M
cooked-index.h:214: internal-error: get_parent: \
  Assertion `(flags & IS_PARENT_DEFERRED) == 0' failed.^M
...

This was reported in PR32160 comment 1.

This is a regression since commit 4e417d7bb1 ("Change handling of
DW_TAG_enumeration_type in DWARF scanner").

Fix this by reverting the commit.

[ Also drop the kfails for PR31900 and PR32158, which are regressions by that
same commit. ]

That allows us to look at the output of "maint print objfiles", and for val1
we get an entry without parent:
...
    [27] ((cooked_index_entry *) 0x7fbbb4002ef0)
    name:       val1
    canonical:  val1
    qualified:  val1
    DWARF tag:  DW_TAG_enumerator
    flags:      0x0 []
    DIE offset: 0x124
    parent:     ((cooked_index_entry *) 0)
...
which is incorrect, as noted in that same comment, but an improvement over the
assertion failure, and I don't think that ever worked.  This is to be
addressed in a follow-up patch.

Reverting the commit begs the question: what was it trying to fix in the first
place, and do we need a different fix?  I've investigated this and filed
PR32160 to track this.

My guess is that the commit was based on a misunderstand of what we track
in cooked_indexer::m_die_range_map.

Each DIE has two types of parent DIEs:
- a DIE that is the parent as indicated by the tree structure in which DIEs
  occur, and
- a DIE that represent the parent scope.

In most cases, these two are the same, but some times they're not.

The debug info above demonstrates such a case.  The DIE at 0x11f:
- has a tree-parent: the DIE representing the CU, and
- has a scope-parent: DIE 0x12c representing namespace ns.

In cooked_indexer::m_die_range_map, we track scope-parents, and the commit
tried to add a tree-parent instead.

So, I don't think we need a different fix, and propose we backport the reversal
for gdb 15.2.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31900
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32158
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32160
(cherry picked from commit a2860473ef)
2024-09-15 15:30:53 +02:00
..
abbrev-cache.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
abbrev-cache.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
abbrev.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
abbrev.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
ada-imported.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
aranges.c Remove call to dwarf2_per_objfile::adjust from ranges readers 2024-05-04 09:30:30 -06:00
aranges.h Remove addrmap_fixed::set_entry 2024-01-15 11:50:24 -07:00
attribute.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
attribute.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
call-site.h gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
comp-unit-head.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
comp-unit-head.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
cooked-index.c Fix heap-use-after-free in index-cached with --disable-threading 2024-05-04 18:55:20 +02:00
cooked-index.h Correctly handle DIE parent computations 2024-04-16 11:54:46 -06:00
cu.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
cu.h [gdb/symtab] Workaround PR gas/31115 2024-03-20 09:57:49 +01:00
die.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
die.h gdb: don't include hashtab.h in defs.h 2024-04-22 21:34:19 -04:00
dwz.c gdb: ensure has dwarf info before reading DWZ file 2024-04-03 13:47:03 +01:00
dwz.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
expr.c gdb: move a bunch of quit-related things to event-top.{c,h} 2024-04-23 11:26:14 -04:00
expr.h gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
file-and-dir.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
frame-tailcall.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
frame-tailcall.h gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
frame.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
frame.h gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
index-cache.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
index-cache.h Move the 'store' method to index_cache_store_context 2024-03-08 17:25:50 -07:00
index-common.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
index-common.h gdb: don't include hashtab.h in defs.h 2024-04-22 21:34:19 -04:00
index-write.c gdb: remove gdbcmd.h 2024-04-25 12:59:02 -04:00
index-write.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
leb.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
leb.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
line-header.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
line-header.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
loc.c gdb: remove gdbcmd.h 2024-04-25 12:59:02 -04:00
loc.h gdb: pass frames as const frame_info_ptr & 2024-02-20 10:42:25 -05:00
macro.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
macro.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
mapped-index.h Do not write the index cache from an index 2024-01-18 08:20:16 -07:00
parent-map.h Introduce class parent_map for DIE range map 2024-04-16 11:54:46 -06:00
public.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
read-debug-names.c Correctly handle DIE parent computations 2024-04-16 11:54:46 -06:00
read-debug-names.h Export dwarf5_augmentation 2024-01-18 08:20:17 -07:00
read-gdb-index.c Remove call to dwarf2_per_objfile::adjust from ranges readers 2024-05-04 09:30:30 -06:00
read-gdb-index.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
read.c [gdb/symtab] Revert "Change handling of DW_TAG_enumeration_type in DWARF scanner" 2024-09-15 15:30:53 +02:00
read.h Remove dwarf2_per_objfile::adjust 2024-05-04 09:30:31 -06:00
sect-names.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
section.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
section.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
stringify.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
stringify.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
tag.h Use the new symbol domains 2024-01-28 10:58:16 -07:00
types.h gdbsupport: constify some return values in print-utils.{h,cc} 2024-04-18 10:31:54 -04:00