diff options
Diffstat (limited to 'gdb/psymtab.c')
-rw-r--r-- | gdb/psymtab.c | 79 |
1 files changed, 73 insertions, 6 deletions
diff --git a/gdb/psymtab.c b/gdb/psymtab.c index eeae03b..edd476e 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -33,6 +33,8 @@ #include "readline/readline.h" #include "gdb_regex.h" #include "dictionary.h" +#include "language.h" +#include "cp-support.h" #ifndef DEV_TTY #define DEV_TTY "/dev/tty" @@ -480,7 +482,26 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile, ALL_OBJFILE_PSYMTABS_REQUIRED (objfile, ps) { if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain)) - return PSYMTAB_TO_SYMTAB (ps); + { + struct symbol *sym = NULL; + struct symtab *stab = PSYMTAB_TO_SYMTAB (ps); + + /* Some caution must be observed with overloaded functions + and methods, since the psymtab will not contain any overload + information (but NAME might contain it). */ + if (stab->primary) + { + struct blockvector *bv = BLOCKVECTOR (stab); + struct block *block = BLOCKVECTOR_BLOCK (bv, block_index); + + sym = lookup_block_symbol (block, name, domain); + } + + if (sym && strcmp_iw (SYMBOL_SEARCH_NAME (sym), name) == 0) + return stab; + + /* Keep looking through other psymtabs. */ + } } return NULL; @@ -573,6 +594,39 @@ pre_expand_symtabs_matching_psymtabs (struct objfile *objfile, /* Nothing. */ } +/* Returns the name used to search psymtabs. Unlike symtabs, psymtabs do + not contain any method/function instance information (since this would + force reading type information while reading psymtabs). Therefore, + if NAME contains overload information, it must be stripped before searching + psymtabs. + + The caller is responsible for freeing the return result. */ + +static char * +psymtab_search_name (const char *name) +{ + switch (current_language->la_language) + { + case language_cplus: + case language_java: + { + if (strchr (name, '(')) + { + char *ret = cp_remove_params (name); + + if (ret) + return ret; + } + } + break; + + default: + break; + } + + return xstrdup (name); +} + /* Look, in partial_symtab PST, for symbol whose natural name is NAME. Check the global symbols if GLOBAL, the static symbols if not. */ @@ -584,11 +638,16 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, struct partial_symbol **top, **real_top, **bottom, **center; int length = (global ? pst->n_global_syms : pst->n_static_syms); int do_linear_search = 1; + char *search_name; + struct cleanup *cleanup; if (length == 0) { return (NULL); } + + search_name = psymtab_search_name (name); + cleanup = make_cleanup (xfree, search_name); start = (global ? pst->objfile->global_psymbols.list + pst->globals_offset : pst->objfile->static_psymbols.list + pst->statics_offset); @@ -617,7 +676,8 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, { do_linear_search = 1; } - if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center), name) >= 0) + if (strcmp_iw_ordered (SYMBOL_SEARCH_NAME (*center), + search_name) >= 0) { top = center; } @@ -631,11 +691,14 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, _("failed internal consistency check")); while (top <= real_top - && SYMBOL_MATCHES_SEARCH_NAME (*top, name)) + && SYMBOL_MATCHES_SEARCH_NAME (*top, search_name)) { if (symbol_matches_domain (SYMBOL_LANGUAGE (*top), SYMBOL_DOMAIN (*top), domain)) - return (*top); + { + do_cleanups (cleanup); + return (*top); + } top++; } } @@ -649,11 +712,15 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name, { if (symbol_matches_domain (SYMBOL_LANGUAGE (*psym), SYMBOL_DOMAIN (*psym), domain) - && SYMBOL_MATCHES_SEARCH_NAME (*psym, name)) - return (*psym); + && SYMBOL_MATCHES_SEARCH_NAME (*psym, search_name)) + { + do_cleanups (cleanup); + return (*psym); + } } } + do_cleanups (cleanup); return (NULL); } |