public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: Keith Seitz <keiths@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] Change to pre-expand symtabs
Date: Wed, 01 Sep 2010 21:44:00 -0000	[thread overview]
Message-ID: <m34oe9b150.fsf@fleche.redhat.com> (raw)
In-Reply-To: <4C4DD835.7060702@redhat.com> (Keith Seitz's message of "Mon, 26	Jul 2010 11:47:17 -0700")

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;
 }
 

  parent reply	other threads:[~2010-09-01 21:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-26 18:47 Keith Seitz
2010-07-29 20:52 ` Tom Tromey
2010-07-30 16:48   ` Keith Seitz
2010-09-01 21:44 ` Tom Tromey [this message]
2010-09-02 17:28   ` Keith Seitz
2010-09-02 22:13   ` Keith Seitz
2010-09-04 20:48     ` Jan Kratochvil
2010-09-08 17:17       ` Keith Seitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m34oe9b150.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=keiths@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).