]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Pass lookup_name_info to block_lookup_symbol_primary
authorTom Tromey <tom@tromey.com>
Thu, 2 Jan 2025 22:15:32 +0000 (15:15 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 10 Sep 2025 22:07:57 +0000 (16:07 -0600)
This changes block_lookup_symbol_primary to accept a lookup_name_info.
This follows the general trend of hoisting these objects to the
outermost layer where they make sense -- somewhat reducing the cost of
using them.

Acked-By: Simon Marchi <simon.marchi@efficios.com>
gdb/block.c
gdb/block.h
gdb/symtab.c

index b653abccb77ad52eb045ec064383ca98808d0a2c..35ea5f36923f54332db474ca60eee2a41ec3d013 100644 (file)
@@ -718,17 +718,16 @@ block_lookup_symbol (const struct block *block, const lookup_name_info &name,
 /* See block.h.  */
 
 struct symbol *
-block_lookup_symbol_primary (const struct block *block, const char *name,
+block_lookup_symbol_primary (const struct block *block,
+                            const lookup_name_info &name,
                             const domain_search_flags domain)
 {
-  lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
-
   /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK.  */
   gdb_assert (block->superblock () == NULL
              || block->superblock ()->superblock () == NULL);
 
   symbol *other = nullptr;
-  for (symbol *sym : block_iterator_range (block, &lookup_name))
+  for (symbol *sym : block_iterator_range (block, &name))
     {
       /* With the fix for PR gcc/debug/91507, we get for:
         ...
index 76fa203697c1c8534425234d9f90c22ffe5a9396..f8cd41441bf1e9d0ffb1b5245701f46113601cf7 100644 (file)
@@ -636,7 +636,7 @@ extern struct symbol *block_lookup_symbol (const struct block *block,
 
 extern struct symbol *block_lookup_symbol_primary
      (const struct block *block,
-      const char *name,
+      const lookup_name_info &name,
       const domain_search_flags domain);
 
 /* Find symbol NAME in BLOCK and in DOMAIN.  This will return a
index ae004b9411b8b009ee260454c3361a8f2b98d13a..d9356cea141c1fff24d0d4fdd6c5076a38c1f8bb 100644 (file)
@@ -2356,6 +2356,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
      block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
      name, domain_name (domain).c_str ());
 
+  lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
   struct block_symbol other;
   other.symbol = NULL;
   for (compunit_symtab *cust : objfile->compunits ())
@@ -2366,7 +2367,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
 
       bv = cust->blockvector ();
       block = bv->block (block_index);
-      result.symbol = block_lookup_symbol_primary (block, name, domain);
+      result.symbol = block_lookup_symbol_primary (block, lookup_name, domain);
       result.block = block;
       if (result.symbol == NULL)
        continue;