From: Tom Tromey Date: Sun, 19 Jan 2025 23:53:33 +0000 (-0700) Subject: Fix index's handling of DW_TAG_imported_declaration X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53e6563141335737904685f7dac9ea0618c36319;p=thirdparty%2Fbinutils-gdb.git Fix index's handling of DW_TAG_imported_declaration Currently the full symbol reader puts DW_TAG_imported_declaration in TYPE_DOMAIN, in the global scope. This patch changes the cooked indexer to follow. Without this patch, a later patch in the series would cause nsalias.exp to regress. This also updates read-gdb-index.c to do something similar. Acked-By: Simon Marchi --- diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c index ef883259032..31344d7fdaa 100644 --- a/gdb/dwarf2/cooked-indexer.c +++ b/gdb/dwarf2/cooked-indexer.c @@ -544,6 +544,11 @@ cooked_indexer::index_dies (cutu_reader *reader, flags &= ~IS_STATIC; flags |= parent_entry->flags & IS_STATIC; } + else if (abbrev->tag == DW_TAG_imported_declaration) + { + /* Match the full reader. */ + flags &= ~IS_STATIC; + } if (abbrev->tag == DW_TAG_namespace && m_language == language_cplus diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c index 070239a5b6a..beeaa40e568 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -1100,7 +1100,7 @@ dw2_expand_marked_cus (dwarf2_per_objfile *per_objfile, offset_type idx, mask = SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN; break; case GDB_INDEX_SYMBOL_KIND_OTHER: - mask = SEARCH_MODULE_DOMAIN; + mask = SEARCH_MODULE_DOMAIN | SEARCH_TYPE_DOMAIN; break; } if ((kind & mask) == 0) diff --git a/gdb/dwarf2/tag.h b/gdb/dwarf2/tag.h index ed730c01c40..a70fca03f2e 100644 --- a/gdb/dwarf2/tag.h +++ b/gdb/dwarf2/tag.h @@ -102,6 +102,10 @@ tag_matches_domain (dwarf_tag tag, domain_search_flags search, language lang) } break; + case DW_TAG_imported_declaration: + /* DW_TAG_imported_declaration isn't necessarily a type, but the + scanner doesn't track the referent, and the full reader + also currently puts it in TYPE_DOMAIN. */ case DW_TAG_padding: case DW_TAG_array_type: case DW_TAG_pointer_type: