[22/28] Pass lookup_name_info to block_lookup_symbol_primary

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

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply

Commit Message

Tom Tromey March 11, 2025, 2:12 p.m. UTC
  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.
---
 gdb/block.c  | 7 +++----
 gdb/block.h  | 2 +-
 gdb/symtab.c | 3 ++-
 3 files changed, 6 insertions(+), 6 deletions(-)
  

Patch

diff --git a/gdb/block.c b/gdb/block.c
index 2c07b38f8f806b8a154eb42adbd3f53a3535c57f..583c4ef1bf07ab942af71d0f1d1b38799849451d 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -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:
 	 ...
diff --git a/gdb/block.h b/gdb/block.h
index 75f5c8e93944342782343ebfb9b5b99afce1d4ff..c348c7fdcc4088e7f5c912e49c387e2c650eda45 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -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
diff --git a/gdb/symtab.c b/gdb/symtab.c
index cb8abca6c6a3368e9ed834f011463e0ce5e50722..eeafcaab49df8ad727980ff99e9e2a8c52043abd 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2365,6 +2365,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 ())
@@ -2375,7 +2376,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;