From: Tom Tromey Date: Thu, 2 Jan 2025 22:17:25 +0000 (-0700) Subject: Simplify block_lookup_symbol X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa2d85304419557e1287d149f3a1c3e233c23107;p=thirdparty%2Fbinutils-gdb.git Simplify block_lookup_symbol 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 --- diff --git a/gdb/block.c b/gdb/block.c index 35ea5f36923..483da5b0925 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -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)) {