aboutsummaryrefslogtreecommitdiff
path: root/gdb/block.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/block.c')
-rw-r--r--gdb/block.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/gdb/block.c b/gdb/block.c
index 79a8f19..f7621aa 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -739,13 +739,21 @@ block_lookup_symbol (const struct block *block, const char *name,
if (!BLOCK_FUNCTION (block))
{
+ struct symbol *other = NULL;
+
ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
{
+ if (SYMBOL_DOMAIN (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 (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), domain))
- return sym;
+ other = sym;
}
- return NULL;
+ return other;
}
else
{
@@ -753,7 +761,10 @@ block_lookup_symbol (const struct block *block, const char *name,
list; this loop makes sure to take anything else other than
parameter symbols first; it only uses parameter symbols as a
last resort. Note that this only takes up extra computation
- time on a match. */
+ time on a match.
+ It's hard to define types in the parameter list (at least in
+ C/C++) so we don't do the same PR 16253 hack here that is done
+ for the !BLOCK_FUNCTION case. */
struct symbol *sym_found = NULL;
@@ -779,23 +790,31 @@ struct symbol *
block_lookup_symbol_primary (const struct block *block, const char *name,
const domain_enum domain)
{
- struct symbol *sym;
+ struct symbol *sym, *other;
struct dict_iterator dict_iter;
/* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
|| BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
+ other = NULL;
for (sym = dict_iter_name_first (block->dict, name, &dict_iter);
sym != NULL;
sym = dict_iter_name_next (name, &dict_iter))
{
+ if (SYMBOL_DOMAIN (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 (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
SYMBOL_DOMAIN (sym), domain))
- return sym;
+ other = sym;
}
- return NULL;
+ return other;
}
/* See block.h. */