[05/28] Fix index's handling of DW_TAG_imported_declaration

Message ID 20250311-search-in-psyms-v1-5-d73d9be20983@tromey.com
State New
Headers
Series Search symbols via quick API |

Commit Message

Tom Tromey March 11, 2025, 2:12 p.m. UTC
  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.
---
 gdb/dwarf2/cooked-indexer.c | 5 +++++
 gdb/dwarf2/read-gdb-index.c | 2 +-
 gdb/dwarf2/tag.h            | 4 ++++
 3 files changed, 10 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gdb/dwarf2/cooked-indexer.c b/gdb/dwarf2/cooked-indexer.c
index 98785e9d8ab636249f5f67cb3a408c83b9990633..f5ed116c097a9e569b9eb7731c9922e5d0d5f7a0 100644
--- a/gdb/dwarf2/cooked-indexer.c
+++ b/gdb/dwarf2/cooked-indexer.c
@@ -551,6 +551,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 f6c73d0c98a8e51c493c391375a349220ae7c447..8daaca96fda60417be42790963a23a91c7edac1b 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -1098,7 +1098,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 865c2bc109d1bf41aa4365a5cf9bda66a1ced65b..ef1ad217c6d34fbacdf5f6372b0d29ad3b6e7bbd 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: