This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Change to pre-expand symtabs
- From: Tom Tromey <tromey at redhat dot com>
- To: Keith Seitz <keiths at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 01 Sep 2010 15:32:43 -0600
- Subject: Re: [RFA] Change to pre-expand symtabs
- References: <4C4DD835.7060702@redhat.com>
Keith> This patch actually does two things, both related to PR symtab/11743
Keith> (for which I've previously submitted various ugly patches). First, it
Keith> switches gdb to search for symtabs by using psymtab pre-expansion.
[...]
Tom> Would you mind letting me take over this one? I found a case where
Tom> pre-expansion with an index expands way too many symbol tables.
I'm afraid I am going to kick this one back to you.
As we discussed on irc, it has problems if the searched-for name
includes a paren that is not used to enclose the function arguments.
I found one other little buglet:
+ char *tmp = alloca (strlen (name));
+ memcpy (tmp, name, paren - name);
+ tmp[name - paren] = '\0';
That last line should read "paren - name". (Also it is more efficient
not to use paren-name+1, not strlen, to size the temporary array.)
I've appended a patch which is this patch, updated with that fix, and
updated for the pre-expansion change I'm going to send soon. This
modified patch causes a regression in type-opaque.exp, I didn't research
why.
Tom
diff --git b/gdb/psymtab.c a/gdb/psymtab.c
index 44ccb0f..54057b2 100644
--- b/gdb/psymtab.c
+++ a/gdb/psymtab.c
@@ -409,15 +409,6 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
int block_index, const char *name,
const domain_enum domain)
{
- struct partial_symtab *ps;
- const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
-
- ALL_OBJFILE_PSYMTABS (objfile, ps)
- {
- if (!ps->readin && lookup_partial_symbol (ps, name, psymtab_index, domain))
- return PSYMTAB_TO_SYMTAB (ps);
- }
-
return NULL;
}
@@ -432,6 +423,35 @@ expand_one_symtab_matching_psymtabs (struct objfile *objfile,
void *),
void *data)
{
+ char *paren;
+ struct partial_symtab *pst;
+ const int psymtab_index = (kind == GLOBAL_BLOCK ? 1 : 0);
+
+ /* If NAME contains overload information, strip it, since psymtabs only
+ contain the method name. */
+ paren = strchr (name, '(');
+ if (paren != NULL)
+ {
+ char *tmp = alloca (paren - name + 1);
+ memcpy (tmp, name, paren - name);
+ tmp[paren - name] = '\0';
+ name = tmp;
+ }
+
+ ALL_OBJFILE_PSYMTABS (objfile, pst)
+ {
+ if (!pst->readin
+ && lookup_partial_symbol (pst, name, psymtab_index, domain) != NULL)
+ {
+ struct symtab *symtab = PSYMTAB_TO_SYMTAB (pst);
+ struct symbol *sym;
+
+ sym = matcher (symtab, kind, name, domain, data);
+ if (sym)
+ return sym;
+ }
+ }
+
return NULL;
}