This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[1/4] RFC: add a pre-expand "quick" function


This patch adds a pre-expand "quick" function to the symbol table API.

This is needed for the index, because the index doesn't encode
information about symbol types.  So, for a lookup we need to fully read
all the CUs defining a name before searching.

This is a separate patch because Keith may need it for a different fix.
It may go in separately from the rest of the series.

Tom

b/gdb/ChangeLog:
2010-06-30  Tom Tromey  <tromey@redhat.com>

	* symtab.c (lookup_symbol_aux_symtabs): Call pre-expand hook.
	(basic_lookup_transparent_type): Likewise.
	* symfile.h (struct quick_symbol_functions)
	<pre_expand_symtabs_matching>: New field.
	* psymtab.c (pre_expand_symtabs_matching_psymtabs): New function.
	(psym_functions): Update.

>From 97b6c5cb7927921b8424b9f5bdc3cb4f668c9669 Mon Sep 17 00:00:00 2001
From: Tom Tromey <tromey@redhat.com>
Date: Wed, 30 Jun 2010 10:07:59 -0600
Subject: [PATCH 1/4] add pre-expand hook

---
 gdb/ChangeLog |    9 +++++++++
 gdb/psymtab.c |    9 +++++++++
 gdb/symfile.h |    9 +++++++++
 gdb/symtab.c  |   52 +++++++++++++++++++++++++++++++++++-----------------
 4 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 367cf1e..ca06130 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -421,6 +421,14 @@ lookup_symbol_aux_psymtabs (struct objfile *objfile,
   return NULL;
 }
 
+static void
+pre_expand_symtabs_matching_psymtabs (struct objfile *objfile,
+				      int kind, const char *name,
+				      domain_enum domain)
+{
+  /* Nothing.  */
+}
+
 /* Look, in partial_symtab PST, for symbol whose natural name is NAME.
    Check the global symbols if GLOBAL, the static symbols if not. */
 
@@ -1199,6 +1207,7 @@ const struct quick_symbol_functions psym_functions =
   forget_cached_source_info_partial,
   lookup_symtab_via_partial_symtab,
   lookup_symbol_aux_psymtabs,
+  pre_expand_symtabs_matching_psymtabs,
   print_psymtab_stats_for_objfile,
   dump_psymtabs_for_objfile,
   relocate_psymtabs,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index d53c465..a869fa3 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -171,6 +171,15 @@ struct quick_symbol_functions
 				   int kind, const char *name,
 				   domain_enum domain);
 
+  /* This is called to expand symbol tables before looking up a
+     symbol.  A backend can choose to implement this and then have its
+     `lookup_symbol' hook always return NULL, or the reverse.  (It
+     doesn't make sense to implement both.)  The arguments are as for
+     `lookup_symbol'.  */
+  void (*pre_expand_symtabs_matching) (struct objfile *objfile,
+				       int kind, const char *name,
+				       domain_enum domain);
+
   /* Print statistics about any indices loaded for OBJFILE.  The
      statistics should be printed to gdb_stdout.  This is used for
      "maint print statistics".  */
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 9472c24..4e48e48 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1295,16 +1295,25 @@ lookup_symbol_aux_symtabs (int block_index, const char *name,
   const struct block *block;
   struct symtab *s;
 
-  ALL_PRIMARY_SYMTABS (objfile, s)
+  ALL_OBJFILES (objfile)
   {
-    bv = BLOCKVECTOR (s);
-    block = BLOCKVECTOR_BLOCK (bv, block_index);
-    sym = lookup_block_symbol (block, name, domain);
-    if (sym)
-      {
-	block_found = block;
-	return fixup_symbol_section (sym, objfile);
-      }
+    if (objfile->sf)
+      objfile->sf->qf->pre_expand_symtabs_matching (objfile,
+						    block_index,
+						    name, domain);
+
+    ALL_OBJFILE_SYMTABS (objfile, s)
+      if (s->primary)
+	{
+	  bv = BLOCKVECTOR (s);
+	  block = BLOCKVECTOR_BLOCK (bv, block_index);
+	  sym = lookup_block_symbol (block, name, domain);
+	  if (sym)
+	    {
+	      block_found = block;
+	      return fixup_symbol_section (sym, objfile);
+	    }
+	}
   }
 
   return NULL;
@@ -1547,15 +1556,24 @@ basic_lookup_transparent_type (const char *name)
      of the desired name as a global, then do psymtab-to-symtab
      conversion on the fly and return the found symbol.  */
 
-  ALL_PRIMARY_SYMTABS (objfile, s)
+  ALL_OBJFILES (objfile)
   {
-    bv = BLOCKVECTOR (s);
-    block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-    sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
-    if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
-      {
-	return SYMBOL_TYPE (sym);
-      }
+    if (objfile->sf)
+      objfile->sf->qf->pre_expand_symtabs_matching (objfile,
+						    GLOBAL_BLOCK,
+						    name, STRUCT_DOMAIN);
+
+    ALL_OBJFILE_SYMTABS (objfile, s)
+      if (s->primary)
+	{
+	  bv = BLOCKVECTOR (s);
+	  block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+	  sym = lookup_block_symbol (block, name, STRUCT_DOMAIN);
+	  if (sym && !TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+	    {
+	      return SYMBOL_TYPE (sym);
+	    }
+	}
   }
 
   ALL_OBJFILES (objfile)
-- 
1.6.2.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]