aboutsummaryrefslogtreecommitdiff
path: root/gdb/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/block.c')
-rw-r--r--gdb/block.c63
1 files changed, 25 insertions, 38 deletions
diff --git a/gdb/block.c b/gdb/block.c
index 1866c0f..2450ebd 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -618,7 +618,7 @@ block_iterator_next (struct block_iterator *iterator)
bool
best_symbol (struct symbol *a, const domain_search_flags domain)
{
- if (a->aclass () == LOC_UNRESOLVED)
+ if (a->loc_class () == LOC_UNRESOLVED)
return false;
if ((domain & SEARCH_VAR_DOMAIN) != 0)
@@ -644,10 +644,10 @@ better_symbol (struct symbol *a, struct symbol *b,
if (b->matches (domain) && !a->matches (domain))
return b;
- if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED)
+ if (a->loc_class () != LOC_UNRESOLVED && b->loc_class () == LOC_UNRESOLVED)
return a;
- if (b->aclass () != LOC_UNRESOLVED && a->aclass () == LOC_UNRESOLVED)
+ if (b->loc_class () != LOC_UNRESOLVED && a->loc_class () == LOC_UNRESOLVED)
return b;
return a;
@@ -670,22 +670,9 @@ block_lookup_symbol (const struct block *block, const lookup_name_info &name,
{
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;
+ best_symbol_tracker tracker;
+ tracker.search (nullptr, block, name, domain);
+ return tracker.currently_best.symbol;
}
else
{
@@ -717,24 +704,13 @@ 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,
+bool
+best_symbol_tracker::search (compunit_symtab *symtab,
+ const struct block *block,
+ const lookup_name_info &name,
const domain_search_flags domain)
{
- struct symbol *sym, *other;
- struct mdict_iterator mdict_iter;
-
- 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);
-
- other = NULL;
- for (sym = mdict_iter_match_first (block->multidict (), lookup_name,
- &mdict_iter);
- sym != NULL;
- sym = mdict_iter_match_next (lookup_name, &mdict_iter))
+ for (symbol *sym : block_iterator_range (block, &name))
{
/* With the fix for PR gcc/debug/91507, we get for:
...
@@ -764,17 +740,28 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
the only option to make this work is improve the fallback to use the
size of the minimal symbol. Filed as PR exp/24989. */
if (best_symbol (sym, domain))
- return sym;
+ {
+ best_symtab = symtab;
+ currently_best = { sym, block };
+ return true;
+ }
/* This is a bit of a hack, but 'matches' 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);
+ {
+ symbol *better = better_symbol (sym, currently_best.symbol, domain);
+ if (better != currently_best.symbol)
+ {
+ best_symtab = symtab;
+ currently_best = { better, block };
+ }
+ }
}
- return other;
+ return false;
}
/* See block.h. */