public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Keith Seitz <keiths@redhat.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [RFA] Change to pre-expand symtabs
Date: Wed, 08 Sep 2010 17:17:00 -0000	[thread overview]
Message-ID: <4C86A806.6030002@redhat.com> (raw)
In-Reply-To: <20100904134451.GA6173@host1.dyn.jankratochvil.net>

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

On 09/04/2010 06:44 AM, Jan Kratochvil wrote:
> I find such static buffer as needlessly dangerous, in general, without
> thinking too much more.

Actually, I think I rushed this patch out. Tom and I were chatting on 
IRC. In the context of the patch I was developing then, this was a 
feasible solution.

However, at Tom's suggestion, I moved some things around, and completely 
forgot to move the memory allocation around with it. My bad.

Good catch, Jan.

I've attached an updated version of this.

Thank you for looking,

Keith

[-- Attachment #2: expand-psymtabs-overloaded-3.patch --]
[-- Type: text/plain, Size: 6412 bytes --]

Index: psymtab.c
===================================================================
RCS file: /cvs/src/src/gdb/psymtab.c,v
retrieving revision 1.12
diff -u -p -r1.12 psymtab.c
--- psymtab.c	1 Sep 2010 21:50:26 -0000	1.12
+++ psymtab.c	7 Sep 2010 20:59:54 -0000
@@ -414,15 +414,6 @@ lookup_symbol_aux_psymtabs (struct objfi
 			    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;
 }
 
@@ -437,6 +428,23 @@ expand_one_symtab_matching_psymtabs (str
 								void *),
 				     void *data)
 {
+  struct partial_symtab *pst;
+  const int psymtab_index = (kind == GLOBAL_BLOCK ? 1 : 0);
+
+  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;
 }
 
Index: symtab.c
===================================================================
RCS file: /cvs/src/src/gdb/symtab.c,v
retrieving revision 1.252
diff -u -p -r1.252 symtab.c
--- symtab.c	1 Sep 2010 21:50:26 -0000	1.252
+++ symtab.c	7 Sep 2010 20:59:55 -0000
@@ -759,6 +759,32 @@ symbol_search_name (const struct general
     return symbol_natural_name (gsymbol);
 }
 
+/* Returns the name used to search psymtabs.  The caller is responsible for
+   freeing the return result.  */
+
+static const 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;
+	  }
+      }
+
+    default:
+      break;
+    }
+
+  return xstrdup (name);
+}
+
 /* Initialize the structure fields to zero values.  */
 void
 init_sal (struct symtab_and_line *sal)
@@ -1409,7 +1435,13 @@ lookup_symbol_aux_symtabs (int block_ind
   struct blockvector *bv;
   const struct block *block;
   struct symtab *s;
+  const char *psym_search_name;
+  struct cleanup *cleanup;
+
+  psym_search_name = psymtab_search_name (name);
+  cleanup = make_cleanup (xfree, (void *) psym_search_name);
 
+  sym = NULL;
   ALL_OBJFILES (objfile)
   {
     ALL_OBJFILE_SYMTABS (objfile, s)
@@ -1421,7 +1453,8 @@ lookup_symbol_aux_symtabs (int block_ind
 	  if (sym)
 	    {
 	      block_found = block;
-	      return fixup_symbol_section (sym, objfile);
+	      sym = fixup_symbol_section (sym, objfile);
+	      goto done;
 	    }
 	}
 
@@ -1429,15 +1462,18 @@ lookup_symbol_aux_symtabs (int block_ind
       {
 	sym = objfile->sf->qf->expand_one_symtab_matching (objfile,
 							   block_index,
-							   name, domain,
+							   psym_search_name,
+							   domain,
 							   match_symbol_aux,
 							   objfile);
 	if (sym)
-	  return sym;
+	  goto done;
       }
   }
 
-  return NULL;
+ done:
+  do_cleanups (cleanup);
+  return sym;
 }
 
 /* A helper function for lookup_symbol_aux that interfaces with the
@@ -1671,7 +1707,7 @@ match_transparent_type (struct symtab *s
       struct symbol *sym;
 
       bv = BLOCKVECTOR (symtab);
-      block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+      block = BLOCKVECTOR_BLOCK (bv, kind);
       sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
       if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
 	return sym;
@@ -1694,13 +1730,19 @@ basic_lookup_transparent_type (const cha
   struct blockvector *bv;
   struct objfile *objfile;
   struct block *block;
-  struct type *t;
+  struct type *type;
+  const char *psym_search_name;
+  struct cleanup *cleanup;
 
   /* Now search all the global symbols.  Do the symtab's first, then
      check the psymtab's. If a psymtab indicates the existence
      of the desired name as a global, then do psymtab-to-symtab
      conversion on the fly and return the found symbol.  */
 
+  psym_search_name = psymtab_search_name (name);
+  cleanup = make_cleanup (xfree, (void *) psym_search_name);
+
+  type = NULL;
   ALL_OBJFILES (objfile)
   {
     ALL_OBJFILE_SYMTABS (objfile, s)
@@ -1711,7 +1753,8 @@ basic_lookup_transparent_type (const cha
 	  sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
 	  if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
 	    {
-	      return SYMBOL_TYPE (sym);
+	      type = SYMBOL_TYPE (sym);
+	      goto done;
 	    }
 	}
 
@@ -1719,20 +1762,24 @@ basic_lookup_transparent_type (const cha
       {
 	sym
 	  = objfile->sf->qf->expand_one_symtab_matching (objfile,
-							 GLOBAL_BLOCK, name,
+							 GLOBAL_BLOCK,
+							 psym_search_name,
 							 STRUCT_DOMAIN,
 							 match_transparent_type,
 							 NULL);
 	if (sym)
-	  return SYMBOL_TYPE (sym);
+	  {
+	    type = SYMBOL_TYPE (sym);
+	    goto done;
+	  }
       }
   }
 
   ALL_OBJFILES (objfile)
   {
-    t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK, name);
-    if (t)
-      return t;
+    type = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK, name);
+    if (type)
+      goto done;
   }
 
   /* Now search the static file-level symbols.
@@ -1752,7 +1799,8 @@ basic_lookup_transparent_type (const cha
 	sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
 	if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
 	  {
-	    return SYMBOL_TYPE (sym);
+	    type = SYMBOL_TYPE (sym);
+	    goto done;
 	  }
       }
 
@@ -1760,23 +1808,29 @@ basic_lookup_transparent_type (const cha
       {
 	sym
 	  = objfile->sf->qf->expand_one_symtab_matching (objfile,
-							 STATIC_BLOCK, name,
+							 STATIC_BLOCK,
+							 psym_search_name,
 							 STRUCT_DOMAIN,
 							 match_transparent_type,
 							 NULL);
 	if (sym)
-	  return SYMBOL_TYPE (sym);
+	  {
+	    type = SYMBOL_TYPE (sym);
+	    goto done;
+	  }
       }
   }
 
   ALL_OBJFILES (objfile)
   {
-    t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK, name);
-    if (t)
-      return t;
+    type = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK, name);
+    if (type)
+      goto done;
   }
 
-  return (struct type *) 0;
+ done:
+  do_cleanups (cleanup);
+  return type;
 }
 
 

      reply	other threads:[~2010-09-07 21:01 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
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 [this message]

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=4C86A806.6030002@redhat.com \
    --to=keiths@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    --cc=tromey@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).