From c79ecacd3f75cfb0ec1a3afc49ca3f30b1759009 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Fri, 11 Aug 2023 01:36:50 +0200 Subject: [PATCH 13/13] [gdb/symtab] Fix DW_TAG_inlined_subroutine entries in the cooked index We get incorrect qualified names in the cooked index for DW_TAG_inlined_subroutine DIEs with abstract origin, due to the fact that the DIE parent is used instead of the abstract origin. Fix this by preferring the abstract origin parent, if available. Tested on x86_64-linux. PR symtab/30728 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30728 --- gdb/dwarf2/read.c | 67 ++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 93708ef11b9..a4f982962ae 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -16464,52 +16464,49 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu, const gdb_byte *new_info_ptr = (new_reader->buffer + to_underlying (origin_offset)); - if (*parent_entry == nullptr) + gdb_assert (reader->cu->per_cu->is_debug_types + == new_reader->cu->per_cu->is_debug_types); + CORE_ADDR addr + = parent_map::form_addr (origin_offset, origin_is_dwz, + reader->cu->per_cu->is_debug_types); + if (new_reader->cu == reader->cu) { - gdb_assert (reader->cu->per_cu->is_debug_types - == new_reader->cu->per_cu->is_debug_types); - CORE_ADDR addr - = parent_map::form_addr (origin_offset, origin_is_dwz, - reader->cu->per_cu->is_debug_types); - if (new_reader->cu == reader->cu) + /* Intra-CU case. */ + if (new_info_ptr > watermark_ptr) { - /* Intra-CU case. */ - if (new_info_ptr > watermark_ptr) - { - /* Defer because origin is not read yet. */ - *maybe_defer = addr; - } - else - { - auto tmp = find_parent (addr); - if (tmp == &parent_map::deferred) - { - /* Defer because origin is deferred. */ - *maybe_defer = addr; - } - else - *parent_entry = tmp; - } + /* Defer because origin is not read yet. */ + *maybe_defer = addr; } else { - /* Inter-CU case. */ - if (parent_valid (addr)) + auto tmp = find_parent (addr); + if (tmp == &parent_map::deferred) { - auto tmp = find_parent (addr); - if (tmp == &parent_map::deferred) - { - /* Defer because origin is deferred. */ - *maybe_defer = addr; - } - else - *parent_entry = tmp; + /* Defer because origin is deferred. */ + *maybe_defer = addr; } else + *parent_entry = tmp; + } + } + else + { + /* Inter-CU case. */ + if (parent_valid (addr)) + { + auto tmp = find_parent (addr); + if (tmp == &parent_map::deferred) { - /* Defer because origin is in other shard. */ + /* Defer because origin is deferred. */ *maybe_defer = addr; } + else + *parent_entry = tmp; + } + else + { + /* Defer because origin is in other shard. */ + *maybe_defer = addr; } } -- 2.35.3