]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify block_lookup_symbol
authorTom Tromey <tom@tromey.com>
Thu, 2 Jan 2025 22:17:25 +0000 (15:17 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 10 Sep 2025 22:07:57 +0000 (16:07 -0600)
One loop in block_lookup_symbol is identical to the code in
block_lookup_symbol_primary.  This patch simplifies the former by
having it call the latter.

This removes an assert.  However, note that the assert is not needed
-- it does not check any invariant that must be maintained.

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

index 35ea5f36923f54332db474ca60eee2a41ec3d013..483da5b0925563764cf947615d5b745b9d4475b3 100644 (file)
@@ -669,24 +669,7 @@ block_lookup_symbol (const struct block *block, const lookup_name_info &name,
                     const domain_search_flags domain)
 {
   if (!block->function ())
-    {
-      struct symbol *other = NULL;
-
-      for (struct symbol *sym : block_iterator_range (block, &name))
-       {
-         /* See comment related to PR gcc/debug/91507 in
-            block_lookup_symbol_primary.  */
-         if (best_symbol (sym, domain))
-           return sym;
-         /* This is a bit of a hack, but symbol_matches_domain might ignore
-            STRUCT vs VAR domain symbols.  So if a matching symbol is found,
-            make sure there is no "better" matching symbol, i.e., one with
-            exactly the same domain.  PR 16253.  */
-         if (sym->matches (domain))
-           other = better_symbol (other, sym, domain);
-       }
-      return other;
-    }
+    return block_lookup_symbol_primary (block, name, domain);
   else
     {
       /* Note that parameter symbols do not always show up last in the
@@ -722,10 +705,6 @@ block_lookup_symbol_primary (const struct block *block,
                             const lookup_name_info &name,
                             const domain_search_flags domain)
 {
-  /* 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, &name))
     {