/* Symbol table lookup for the GNU debugger, GDB.
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009
- Free Software Foundation, Inc.
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009,
+ 2010 Free Software Foundation, Inc.
This file is part of GDB.
char *operator_chars (char *p, char **end);
static struct symbol *lookup_symbol_aux (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain,
enum language language,
static
struct symbol *lookup_symbol_aux_local (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain);
static
struct symbol *lookup_symbol_aux_symtabs (int block_index,
const char *name,
- const char *linkage_name,
const domain_enum domain);
static
struct symbol *lookup_symbol_aux_psymtabs (int block_index,
const char *name,
- const char *linkage_name,
const domain_enum domain);
static int file_matches (char *, char **, int);
|| gsymbol->language == language_auto)
{
demangled =
- cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
+ cplus_demangle (mangled, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
if (demangled != NULL)
{
gsymbol->language = language_cplus;
{
char *demangled_name = NULL;
const char *modified_name = NULL;
- const char *mangled_name = NULL;
struct symbol *returnval;
struct cleanup *cleanup = make_cleanup (null_cleanup, 0);
demangled_name = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
if (demangled_name)
{
- mangled_name = name;
modified_name = demangled_name;
make_cleanup (xfree, demangled_name);
}
DMGL_ANSI | DMGL_PARAMS | DMGL_JAVA);
if (demangled_name)
{
- mangled_name = name;
modified_name = demangled_name;
make_cleanup (xfree, demangled_name);
}
modified_name = copy;
}
- returnval = lookup_symbol_aux (modified_name, mangled_name, block,
- domain, lang, is_a_field_of_this);
+ returnval = lookup_symbol_aux (modified_name, block, domain, lang,
+ is_a_field_of_this);
do_cleanups (cleanup);
return returnval;
well. */
static struct symbol *
-lookup_symbol_aux (const char *name, const char *linkage_name,
- const struct block *block, const domain_enum domain,
- enum language language, int *is_a_field_of_this)
+lookup_symbol_aux (const char *name, const struct block *block,
+ const domain_enum domain, enum language language,
+ int *is_a_field_of_this)
{
struct symbol *sym;
const struct language_defn *langdef;
/* Search specified block and its superiors. Don't search
STATIC_BLOCK or GLOBAL_BLOCK. */
- sym = lookup_symbol_aux_local (name, linkage_name, block, domain);
+ sym = lookup_symbol_aux_local (name, block, domain);
if (sym != NULL)
return sym;
&& block != NULL)
{
struct symbol *sym = NULL;
+ const struct block *function_block = block;
/* 'this' is only defined in the function's block, so find the
enclosing function block. */
- for (; block && !BLOCK_FUNCTION (block);
- block = BLOCK_SUPERBLOCK (block));
+ for (; function_block && !BLOCK_FUNCTION (function_block);
+ function_block = BLOCK_SUPERBLOCK (function_block));
- if (block && !dict_empty (BLOCK_DICT (block)))
- sym = lookup_block_symbol (block, langdef->la_name_of_this,
- NULL, VAR_DOMAIN);
+ if (function_block && !dict_empty (BLOCK_DICT (function_block)))
+ sym = lookup_block_symbol (function_block, langdef->la_name_of_this,
+ VAR_DOMAIN);
if (sym)
{
struct type *t = sym->type;
/* Now do whatever is appropriate for LANGUAGE to look
up static and global variables. */
- sym = langdef->la_lookup_symbol_nonlocal (name, linkage_name, block, domain);
+ sym = langdef->la_lookup_symbol_nonlocal (name, block, domain);
if (sym != NULL)
return sym;
desired name as a file-level static, then do psymtab-to-symtab
conversion on the fly and return the found symbol. */
- sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, linkage_name, domain);
+ sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain);
if (sym != NULL)
return sym;
- sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, linkage_name, domain);
+ sym = lookup_symbol_aux_psymtabs (STATIC_BLOCK, name, domain);
if (sym != NULL)
return sym;
Don't search STATIC_BLOCK or GLOBAL_BLOCK. */
static struct symbol *
-lookup_symbol_aux_local (const char *name, const char *linkage_name,
- const struct block *block,
+lookup_symbol_aux_local (const char *name, const struct block *block,
const domain_enum domain)
{
struct symbol *sym;
while (block != static_block)
{
- sym = lookup_symbol_aux_block (name, linkage_name, block, domain);
+ sym = lookup_symbol_aux_block (name, block, domain);
if (sym != NULL)
return sym;
/* Go through SYMTABS. */
ALL_SYMTABS (obj, s)
if (block == BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK))
- return obj;
+ {
+ if (obj->separate_debug_objfile_backlink)
+ obj = obj->separate_debug_objfile_backlink;
+
+ return obj;
+ }
return NULL;
}
block_found appropriately. */
struct symbol *
-lookup_symbol_aux_block (const char *name, const char *linkage_name,
- const struct block *block,
+lookup_symbol_aux_block (const char *name, const struct block *block,
const domain_enum domain)
{
struct symbol *sym;
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (sym)
{
block_found = block;
psymtabs. */
struct symbol *
-lookup_global_symbol_from_objfile (const struct objfile *objfile,
+lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
const char *name,
- const char *linkage_name,
const domain_enum domain)
{
+ const struct objfile *objfile;
struct symbol *sym;
struct blockvector *bv;
const struct block *block;
struct symtab *s;
struct partial_symtab *ps;
- /* Go through symtabs. */
- ALL_OBJFILE_SYMTABS (objfile, s)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
- if (sym)
- {
- block_found = block;
- return fixup_symbol_section (sym, (struct objfile *)objfile);
- }
- }
-
- /* Now go through psymtabs. */
- ALL_OBJFILE_PSYMTABS (objfile, ps)
- {
- if (!ps->readin
- && lookup_partial_symbol (ps, name, linkage_name,
- 1, domain))
- {
- s = PSYMTAB_TO_SYMTAB (ps);
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
- return fixup_symbol_section (sym, (struct objfile *)objfile);
- }
- }
-
- if (objfile->separate_debug_objfile)
- return lookup_global_symbol_from_objfile (objfile->separate_debug_objfile,
- name, linkage_name, domain);
+ for (objfile = main_objfile;
+ objfile;
+ objfile = objfile_separate_debug_iterate (main_objfile, objfile))
+ {
+ /* Go through symtabs. */
+ ALL_OBJFILE_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, domain);
+ if (sym)
+ {
+ block_found = block;
+ return fixup_symbol_section (sym, (struct objfile *)objfile);
+ }
+ }
+
+ /* Now go through psymtabs. */
+ ALL_OBJFILE_PSYMTABS (objfile, ps)
+ {
+ if (!ps->readin
+ && lookup_partial_symbol (ps, name, 1, domain))
+ {
+ s = PSYMTAB_TO_SYMTAB (ps);
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, domain);
+ return fixup_symbol_section (sym, (struct objfile *)objfile);
+ }
+ }
+ }
return NULL;
}
static symbols. */
static struct symbol *
-lookup_symbol_aux_symtabs (int block_index,
- const char *name, const char *linkage_name,
+lookup_symbol_aux_symtabs (int block_index, const char *name,
const domain_enum domain)
{
struct symbol *sym;
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (sym)
{
block_found = block;
static struct symbol *
lookup_symbol_aux_psymtabs (int block_index, const char *name,
- const char *linkage_name,
const domain_enum domain)
{
struct symbol *sym;
ALL_PSYMTABS (objfile, ps)
{
if (!ps->readin
- && lookup_partial_symbol (ps, name, linkage_name,
- psymtab_index, domain))
+ && lookup_partial_symbol (ps, name, psymtab_index, domain))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, block_index);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort try
block = BLOCKVECTOR_BLOCK (bv,
block_index == GLOBAL_BLOCK ?
STATIC_BLOCK : GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, linkage_name, domain);
+ sym = lookup_block_symbol (block, name, domain);
if (!sym)
error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>)."),
block_index == GLOBAL_BLOCK ? "global" : "static",
struct symbol *
basic_lookup_symbol_nonlocal (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
than that one, so I don't think we should worry about that for
now. */
- sym = lookup_symbol_static (name, linkage_name, block, domain);
+ sym = lookup_symbol_static (name, block, domain);
if (sym != NULL)
return sym;
- return lookup_symbol_global (name, linkage_name, block, domain);
+ return lookup_symbol_global (name, block, domain);
}
/* Lookup a symbol in the static block associated to BLOCK, if there
struct symbol *
lookup_symbol_static (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
const struct block *static_block = block_static_block (block);
if (static_block != NULL)
- return lookup_symbol_aux_block (name, linkage_name, static_block, domain);
+ return lookup_symbol_aux_block (name, static_block, domain);
else
return NULL;
}
struct symbol *
lookup_symbol_global (const char *name,
- const char *linkage_name,
const struct block *block,
const domain_enum domain)
{
/* Call library-specific lookup procedure. */
objfile = lookup_objfile_from_block (block);
if (objfile != NULL)
- sym = solib_global_lookup (objfile, name, linkage_name, domain);
+ sym = solib_global_lookup (objfile, name, domain);
if (sym != NULL)
return sym;
- sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, linkage_name, domain);
+ sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain);
if (sym != NULL)
return sym;
- return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, linkage_name, domain);
+ return lookup_symbol_aux_psymtabs (GLOBAL_BLOCK, name, domain);
}
int
}
/* Look, in partial_symtab PST, for symbol whose natural name is NAME.
- If LINKAGE_NAME is non-NULL, check in addition that the symbol's
- linkage name matches it. Check the global symbols if GLOBAL, the
- static symbols if not */
+ Check the global symbols if GLOBAL, the static symbols if not. */
struct partial_symbol *
lookup_partial_symbol (struct partial_symtab *pst, const char *name,
- const char *linkage_name, int global,
- domain_enum domain)
+ int global, domain_enum domain)
{
struct partial_symbol *temp;
struct partial_symbol **start, **psym;
internal_error (__FILE__, __LINE__, _("failed internal consistency check"));
while (top <= real_top
- && (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (*top), linkage_name) == 0
- : SYMBOL_MATCHES_SEARCH_NAME (*top,name)))
+ && SYMBOL_MATCHES_SEARCH_NAME (*top, name))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (*top),
SYMBOL_DOMAIN (*top), domain))
for (psym = start; psym < start + length; psym++)
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym),
- SYMBOL_DOMAIN (*psym), domain))
- {
- if (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (*psym), linkage_name) == 0
- : SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
- {
- return (*psym);
- }
- }
+ SYMBOL_DOMAIN (*psym), domain)
+ && SYMBOL_MATCHES_SEARCH_NAME (*psym, name))
+ return (*psym);
}
}
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
{
return SYMBOL_TYPE (sym);
ALL_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_partial_symbol (ps, name, NULL,
- 1, STRUCT_DOMAIN))
+ if (!ps->readin && lookup_partial_symbol (ps, name, 1, STRUCT_DOMAIN))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
{
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
{
return SYMBOL_TYPE (sym);
ALL_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_partial_symbol (ps, name, NULL, 0, STRUCT_DOMAIN))
+ if (!ps->readin && lookup_partial_symbol (ps, name, 0, STRUCT_DOMAIN))
{
s = PSYMTAB_TO_SYMTAB (ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
{
/* This shouldn't be necessary, but as a last resort
* the psymtab gets it wrong in some cases.
*/
block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+ sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
if (!sym)
error (_("Internal: static symbol `%s' found in %s psymtab but not in symtab.\n\
%s may be an inlined function, or may be a template function\n\
ALL_PSYMTABS (objfile, pst)
{
- if (lookup_partial_symbol (pst, main_name (), NULL, 1, VAR_DOMAIN))
+ if (lookup_partial_symbol (pst, main_name (), 1, VAR_DOMAIN))
{
return (pst);
}
search on the symbols. Each symbol which is marked as being a ObjC/C++
symbol (language_cplus or language_objc set) has both the encoded and
non-encoded names tested for a match.
-
- If LINKAGE_NAME is non-NULL, verify that any symbol we find has this
- particular mangled name.
*/
struct symbol *
lookup_block_symbol (const struct block *block, const char *name,
- const char *linkage_name,
const domain_enum domain)
{
struct dict_iterator iter;
sym = dict_iter_name_next (name, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
- SYMBOL_DOMAIN (sym), domain)
- && (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
+ SYMBOL_DOMAIN (sym), domain))
return sym;
}
return NULL;
sym = dict_iter_name_next (name, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
- SYMBOL_DOMAIN (sym), domain)
- && (linkage_name != NULL
- ? strcmp (SYMBOL_LINKAGE_NAME (sym), linkage_name) == 0 : 1))
+ SYMBOL_DOMAIN (sym), domain))
{
sym_found = sym;
if (!SYMBOL_IS_ARGUMENT (sym))
&& ((regexp == NULL
|| re_exec (SYMBOL_NATURAL_NAME (*psym)) != 0)
&& ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
- && SYMBOL_CLASS (*psym) != LOC_BLOCK)
+ && SYMBOL_CLASS (*psym) != LOC_UNRESOLVED
+ && SYMBOL_CLASS (*psym) != LOC_BLOCK
+ && SYMBOL_CLASS (*psym) != LOC_CONST)
|| (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (*psym) == LOC_BLOCK)
|| (kind == TYPES_DOMAIN && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))))
{
&& ((regexp == NULL
|| re_exec (SYMBOL_NATURAL_NAME (sym)) != 0)
&& ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (sym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (sym) != LOC_UNRESOLVED
&& SYMBOL_CLASS (sym) != LOC_BLOCK
&& SYMBOL_CLASS (sym) != LOC_CONST)
|| (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (sym) == LOC_BLOCK)