aboutsummaryrefslogtreecommitdiff
path: root/gdb/psymtab.c
diff options
context:
space:
mode:
authorKeith Seitz <keiths@redhat.com>2011-03-16 21:12:12 +0000
committerKeith Seitz <keiths@redhat.com>2011-03-16 21:12:12 +0000
commitc00f848495bbc6e6b24d4ec81d64a09f5759bf3d (patch)
treed95cbfa0489f1fff9ebe2d1d1d9fc6a6069ff4de /gdb/psymtab.c
parent598997c828bff87692dc5addca8b7961f227918b (diff)
downloadgdb-c00f848495bbc6e6b24d4ec81d64a09f5759bf3d.zip
gdb-c00f848495bbc6e6b24d4ec81d64a09f5759bf3d.tar.gz
gdb-c00f848495bbc6e6b24d4ec81d64a09f5759bf3d.tar.bz2
* linespec.c (find_methods): Canonicalize NAME before looking
up the symbol. (name_end): New function. (keep_name_info): New function. (decode_line_1): Use keep_name_info. (decode_compound): Likewise. * cli/cli-utils.h (remove_trailing_whitespace): New function. * cli/cli-utils.c (remove_trailing_whitespace): Likewise. PR c++/12273 * linespec.c (locate_first_half): Keep overload information, too. (decode_compound): Use a string to represent break characters to escape the loop. If P points to a break character, do not increment it. For C++ and Java, keep overload information and relevant keywords. If we cannot find a symbol, search the minimal symbols. PR c++/11734 * linespec.c (decode_compound): Rename SAVED_ARG to THE_REAL_SAVED_ARG. Make a copy of THE_REAL_SAVED_ARG in SAVED_ARG and strip single-quotes. Pass a valid block to lookup_symbol. (lookup_prefix_sym): Likewise. (find_method): Construct search name based on SYM_CLASS instead of SAVED_ARG. * psymtab.c (lookup_partial_symbol): Add language parameter. (lookup_symbol_aux_psymtabs): Likewise. Don't assume that the psymtab we found was the right one. Search for the desired symbol in the symtab to be certain. (psymtab_search_name): New function. (lookup_partial_symbol): Use psymtab_search_name. Add language parameter. (read_symtabs_for_function): Add language parameter and pass to lookup_partial_symbol. (find_symbol_file_from_partial): Likewise.
Diffstat (limited to 'gdb/psymtab.c')
-rw-r--r--gdb/psymtab.c79
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);
}