]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify basic_lookup_transparent_type
authorTom Tromey <tom@tromey.com>
Tue, 31 Dec 2024 17:30:15 +0000 (10:30 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 10 Sep 2025 22:07:57 +0000 (16:07 -0600)
This patch changes basic_lookup_transparent_type to always work via
the "quick" API -- that is, no separate search of the already-expanded
symtabs is needed.

This is more efficient when many CUs have already been expanded.  It
also makes the lookup more consistent, as the result is no longer
dependent on the order in which CUs were previously expanded.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998
Acked-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-lang.c
gdb/symtab.c

index 0e3cb07c3d389c6e4d2d59ec7471ab391af95e8f..6da4cb557010d6c6c9e64ec9b8e8365b48e6a87d 100644 (file)
@@ -6467,7 +6467,7 @@ ada_get_tsd_type (struct inferior *inf)
 
   if (data->tsd_type == 0)
     data->tsd_type
-      = lookup_transparent_type ("<ada__tags__type_specific_data>",
+      = lookup_transparent_type ("ada.tags.type_specific_data",
                                 SEARCH_TYPE_DOMAIN);
   return data->tsd_type;
 }
index 9f6797118b5d0435af829e721172fba8bc7de8e6..ae004b9411b8b009ee260454c3361a8f2b98d13a 100644 (file)
@@ -2766,35 +2766,6 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
   return sym->type ();
 }
 
-/* Subroutine of basic_lookup_transparent_type to simplify it.
-   Look up the non-opaque definition of NAME in BLOCK_INDEX of OBJFILE.
-   BLOCK_INDEX is either GLOBAL_BLOCK or STATIC_BLOCK.  */
-
-static struct type *
-basic_lookup_transparent_type_1 (struct objfile *objfile,
-                                enum block_enum block_index,
-                                domain_search_flags flags,
-                                const lookup_name_info &name)
-{
-  const struct blockvector *bv;
-  const struct block *block;
-  const struct symbol *sym;
-
-  for (compunit_symtab *cust : objfile->compunits ())
-    {
-      bv = cust->blockvector ();
-      block = bv->block (block_index);
-      sym = block_find_symbol (block, name, flags, nullptr);
-      if (sym != nullptr)
-       {
-         gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
-         return sym->type ();
-       }
-    }
-
-  return NULL;
-}
-
 /* The standard implementation of lookup_transparent_type.  This code
    was modeled on lookup_symbol -- the parts not relevant to looking
    up types were just left out.  In particular it's assumed here that
@@ -2808,19 +2779,7 @@ basic_lookup_transparent_type (const char *name, domain_search_flags flags)
 
   lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
 
-  /* Now search all the global symbols.  Do the symtab's first, then
-     check the psymtab's.  If a psymtab indicates the existence
-     of the desired name as a global, then do psymtab-to-symtab
-     conversion on the fly and return the found symbol.  */
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      t = basic_lookup_transparent_type_1 (objfile, GLOBAL_BLOCK,
-                                          flags, lookup_name);
-      if (t)
-       return t;
-    }
-
+  /* Search all the global symbols.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
       t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK,
@@ -2829,21 +2788,8 @@ basic_lookup_transparent_type (const char *name, domain_search_flags flags)
        return t;
     }
 
-  /* Now search the static file-level symbols.
-     Not strictly correct, but more useful than an error.
-     Do the symtab's first, then
-     check the psymtab's.  If a psymtab indicates the existence
-     of the desired name as a file-level static, then do psymtab-to-symtab
-     conversion on the fly and return the found symbol.  */
-
-  for (objfile *objfile : current_program_space->objfiles ())
-    {
-      t = basic_lookup_transparent_type_1 (objfile, STATIC_BLOCK,
-                                          flags, lookup_name);
-      if (t)
-       return t;
-    }
-
+  /* Now search the static file-level symbols.  Not strictly correct,
+     but more useful than an error.  */
   for (objfile *objfile : current_program_space->objfiles ())
     {
       t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK,