/* Block-related functions for the GNU debugger, GDB.
- Copyright (C) 2003-2015 Free Software Foundation, Inc.
+ Copyright (C) 2003-2016 Free Software Foundation, Inc.
This file is part of GDB.
struct block_namespace_info
{
const char *scope;
- struct using_direct *using;
+ struct using_direct *using_decl;
};
static void block_initialize_namespace (struct block *block,
/* If we have an addrmap mapping code addresses to blocks, then use
that. */
if (BLOCKVECTOR_MAP (bl))
- return addrmap_find (BLOCKVECTOR_MAP (bl), pc);
+ return (struct block *) addrmap_find (BLOCKVECTOR_MAP (bl), pc);
/* Otherwise, use binary search to find the last block that starts
before PC.
: MSYMBOL_PRINT_NAME (msym.minsym)));
}
- return *slot;
+ return (struct call_site *) *slot;
}
/* Return the blockvector immediately containing the innermost lexical block
if (block == NULL || BLOCK_NAMESPACE (block) == NULL)
return NULL;
else
- return BLOCK_NAMESPACE (block)->using;
+ return BLOCK_NAMESPACE (block)->using_decl;
}
/* Set BLOCK's using member to USING; if needed, allocate memory via
void
block_set_using (struct block *block,
- struct using_direct *using,
+ struct using_direct *using_decl,
struct obstack *obstack)
{
block_initialize_namespace (block, obstack);
- BLOCK_NAMESPACE (block)->using = using;
+ BLOCK_NAMESPACE (block)->using_decl = using_decl;
}
/* If BLOCK_NAMESPACE (block) is NULL, allocate it via OBSTACK and
{
if (BLOCK_NAMESPACE (block) == NULL)
{
- BLOCK_NAMESPACE (block)
- = obstack_alloc (obstack, sizeof (struct block_namespace_info));
+ BLOCK_NAMESPACE (block) = XOBNEW (obstack, struct block_namespace_info);
BLOCK_NAMESPACE (block)->scope = NULL;
- BLOCK_NAMESPACE (block)->using = NULL;
+ BLOCK_NAMESPACE (block)->using_decl = NULL;
}
}
gb->compunit_symtab = cu;
}
+/* See block.h. */
+
+struct dynamic_prop *
+block_static_link (const struct block *block)
+{
+ struct objfile *objfile = block_objfile (block);
+
+ /* Only objfile-owned blocks that materialize top function scopes can have
+ static links. */
+ if (objfile == NULL || BLOCK_FUNCTION (block) == NULL)
+ return NULL;
+
+ return (struct dynamic_prop *) objfile_lookup_static_link (objfile, block);
+}
+
/* Return the compunit of the global block. */
static struct compunit_symtab *
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
{
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;
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 other;
+}
+
+/* See block.h. */
+
+struct symbol *
+block_find_symbol (const struct block *block, const char *name,
+ const domain_enum domain,
+ block_symbol_matcher_ftype *matcher, void *data)
+{
+ struct block_iterator iter;
+ struct symbol *sym;
+
+ /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK. */
+ gdb_assert (BLOCK_SUPERBLOCK (block) == NULL
+ || BLOCK_SUPERBLOCK (BLOCK_SUPERBLOCK (block)) == NULL);
+
+ ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
+ {
+ /* MATCHER is deliberately called second here so that it never sees
+ a non-domain-matching symbol. */
+ if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+ SYMBOL_DOMAIN (sym), domain)
+ && matcher (sym, data))
+ return sym;
+ }
return NULL;
}
+
+/* See block.h. */
+
+int
+block_find_non_opaque_type (struct symbol *sym, void *data)
+{
+ return !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym));
+}
+
+/* See block.h. */
+
+int
+block_find_non_opaque_type_preferred (struct symbol *sym, void *data)
+{
+ struct symbol **best = (struct symbol **) data;
+
+ if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+ return 1;
+ *best = sym;
+ return 0;
+}