]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/symtab] Fix parent of enumerator
authorTom de Vries <tdevries@suse.de>
Tue, 8 Oct 2024 10:27:20 +0000 (12:27 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 8 Oct 2024 10:27:20 +0000 (12:27 +0200)
commit42d385542f5f948e68db256b249662683057b288
tree4f0afe17b4485ddd50da7a18ae1e77ce953d0529
parente808bbbe37dda4a3ec5872ff990090cc746ad7ac
[gdb/symtab] Fix parent of enumerator

As mentioned in commit 489b82720f5 ('[gdb/symtab] Revert "Change handling of
DW_TAG_enumeration_type in DWARF scanner"'), when doing "maint print objfiles" in
test-case gdb.dwarf2/enum-type.exp, 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)
...

This happens here in cooked_indexer::index_dies:
...
      info_ptr = recurse (reader, info_ptr,
  is_enum_class ? this_entry : parent_entry,
  fully);
...
when we're passing down a nullptr parent_entry, while the parent of this_entry
is deferred.

Fix this in cooked_indexer::index_dies by passing down a deffered parent
instead, such that we get:
...
    [27] ((cooked_index_entry *) 0x7ff0e4002ef0)^M
    name:       val1^M
    canonical:  val1^M
    qualified:  ns::val1^M
    DWARF tag:  DW_TAG_enumerator^M
    flags:      0x0 []^M
    DIE offset: 0x124^M
    parent:     ((cooked_index_entry *) 0x7ff0e4002f20) [ns]^M
...

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/read.c
gdb/testsuite/gdb.dwarf2/enum-type.exp