This is the mail archive of the archer-commits@sourceware.org mailing list for the Archer 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]

[SCM] archer-tromey-optional-psymtab: Consolidate two quick functions. Normalize quick function names. Move require_partial_symbols out of loops over psymtabs.


The branch, archer-tromey-optional-psymtab has been updated
       via  bae817a545cfec8ca73ec727dc4a4384f32537e6 (commit)
      from  e5f2d15c145891551c3d3f260a08f36c140876d4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit bae817a545cfec8ca73ec727dc4a4384f32537e6
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Nov 16 13:19:22 2009 -0700

    Consolidate two quick functions.
    Normalize quick function names.
    Move require_partial_symbols out of loops over psymtabs.

-----------------------------------------------------------------------

Summary of changes:
 gdb/cp-support.c |    2 +-
 gdb/psymtab.c    |  104 +++------------------------------------------
 gdb/symfile.c    |    2 +-
 gdb/symfile.h    |   44 +++++++++----------
 gdb/symtab.c     |  125 +++++++++++++++++++++++++++++++++++++++++++++++------
 5 files changed, 140 insertions(+), 137 deletions(-)

First 500 lines of diff:
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index a359c6e..7abfdf4 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -759,7 +759,7 @@ make_symbol_overload_list_qualified (const char *func_name)
 
   ALL_OBJFILES (objfile)
   {
-    objfile->sf->qf->read_symtabs_for_function (objfile, func_name);
+    objfile->sf->qf->expand_symtabs_for_function (objfile, func_name);
   }
 
   /* Search upwards from currently selected frame (so that we can
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 4b7b3da..2893525 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -71,9 +71,9 @@ lookup_partial_symtab (struct objfile *objfile, const char *name,
 {
   struct partial_symtab *pst;
 
+  require_partial_symbols (objfile);
   ALL_OBJFILE_PSYMTABS (objfile, pst)
   {
-    require_partial_symbols (objfile);
     if (FILENAME_CMP (name, pst->filename) == 0)
       {
 	return (pst);
@@ -412,59 +412,21 @@ fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
   return psym;
 }
 
-/* Check to see if the symbol is defined in one of the partial
-   symtabs.  BLOCK_INDEX should be either GLOBAL_BLOCK or
-   STATIC_BLOCK, depending on whether or not we want to search global
-   symbols or static symbols.  */
-
-static struct symbol *
+static struct symtab *
 lookup_symbol_aux_psymtabs (struct objfile *objfile,
 			    int block_index, const char *name,
 			    const char *linkage_name,
 			    const domain_enum domain)
 {
-  struct symbol *sym;
-  struct blockvector *bv;
-  const struct block *block;
   struct partial_symtab *ps;
-  struct symtab *s;
   const int psymtab_index = (block_index == GLOBAL_BLOCK ? 1 : 0);
 
+  require_partial_symbols (objfile);
   ALL_OBJFILE_PSYMTABS (objfile, ps)
   {
-    require_partial_symbols (objfile);
-    if (!ps->readin
-	&& lookup_partial_symbol (ps, name, linkage_name,
-				  psymtab_index, domain))
-      {
-	s = PSYMTAB_TO_SYMTAB (ps);
-	bv = BLOCKVECTOR (s);
-	block = BLOCKVECTOR_BLOCK (bv, block_index);
-	sym = lookup_block_symbol (block, name, linkage_name, domain);
-	if (!sym)
-	  {
-	    /* This shouldn't be necessary, but as a last resort try
-	       looking in the statics even though the psymtab claimed
-	       the symbol was global, or vice-versa. It's possible
-	       that the psymtab gets it wrong in some cases.  */
-
-	    /* FIXME: carlton/2002-09-30: Should we really do that?
-	       If that happens, isn't it likely to be a GDB error, in
-	       which case we should fix the GDB error rather than
-	       silently dealing with it here?  So I'd vote for
-	       removing the check for the symbol in the other
-	       block.  */
-	    block = BLOCKVECTOR_BLOCK (bv,
-				       block_index == GLOBAL_BLOCK ?
-				       STATIC_BLOCK : GLOBAL_BLOCK);
-	    sym = lookup_block_symbol (block, name, linkage_name, domain);
-	    if (!sym)
-	      error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>)."),
-		     block_index == GLOBAL_BLOCK ? "global" : "static",
-		     name, ps->filename, name, name);
-	  }
-	return fixup_symbol_section (sym, objfile);
-      }
+    if (!ps->readin && lookup_partial_symbol (ps, name, linkage_name,
+					      psymtab_index, domain))
+      return PSYMTAB_TO_SYMTAB (ps);
   }
 
   return NULL;
@@ -564,57 +526,6 @@ lookup_partial_symbol (struct partial_symtab *pst, const char *name,
   return (NULL);
 }
 
-static struct type *
-basic_lookup_transparent_type_via_partial (struct objfile *objfile,
-					   const char *name, int kind)
-{
-  struct partial_symtab *ps;
-  int other_kind = kind == GLOBAL_BLOCK ? STATIC_BLOCK : GLOBAL_BLOCK;
-
-  /* FIXME: .debug_pubnames should be read in.
-     
-     One may also try to the first pass without the require_partial_symbols
-     call but that would behave nondeterministically.  */
-  ALL_OBJFILE_PSYMTABS (objfile, ps)
-  {
-    require_partial_symbols (objfile);
-    if (!ps->readin && lookup_partial_symbol (ps, name, NULL,
-					      kind == GLOBAL_BLOCK,
-					      STRUCT_DOMAIN))
-      {
-	struct symtab *s;
-	struct blockvector *bv;
-	struct block *block;
-	struct symbol *sym;
-
-	s = PSYMTAB_TO_SYMTAB (ps);
-	bv = BLOCKVECTOR (s);
-	block = BLOCKVECTOR_BLOCK (bv, kind);
-	sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
-	if (!sym)
-	  {
-	    /* This shouldn't be necessary, but as a last resort
-	     * try looking in the 'other kind' even though the psymtab
-	     * claimed the symbol was one thing. It's possible that
-	     * the psymtab gets it wrong in some cases.
-	     */
-	    block = BLOCKVECTOR_BLOCK (bv, other_kind);
-	    sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
-	    if (!sym)
-	      /* FIXME; error is wrong in one case */
-	      error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
-%s may be an inlined function, or may be a template function\n\
-(if a template, try specifying an instantiation: %s<type>)."),
-		     name, ps->filename, name, name);
-	  }
-	if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
-	  return SYMBOL_TYPE (sym);
-      }
-  }
-
-  return NULL;
-}
-
 /* True if we are nested inside psymtab_to_symtab. */
 
 int currently_reading_symtab = 0;
@@ -1121,7 +1032,7 @@ psymtab_to_fullname (struct partial_symtab *ps)
 }
 
 static char *
-find_symbol_file_from_partial (struct objfile *objfile, char *name)
+find_symbol_file_from_partial (struct objfile *objfile, const char *name)
 {
   struct partial_symtab *pst;
 
@@ -1367,7 +1278,6 @@ const struct quick_symbol_functions psym_functions =
   forget_cached_source_info_partial,
   lookup_symtab_via_partial_symtab,
   lookup_symbol_aux_psymtabs,
-  basic_lookup_transparent_type_via_partial,
   print_psymtab_stats_for_objfile,
   dump_psymtabs_for_objfile,
   relocate_psymtabs,
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 37dc8f9..0ea75ff 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -953,7 +953,7 @@ symbol_file_add_with_addrs_or_offsets (bfd *abfd,
      all partial symbol tables for this objfile if so. */
 
   if ((flags & OBJF_READNOW) || readnow_symbol_files)
-    objfile->sf->qf->expand_symbol_tables (objfile, from_tty);
+    objfile->sf->qf->expand_all_symtabs (objfile, from_tty);
 
   /* If the file has its own symbol tables it has no separate debug info.
      `.dynsym'/`.symtab' go to MSYMBOLS, `.debug_info' goes to SYMTABS/PSYMTABS.
diff --git a/gdb/symfile.h b/gdb/symfile.h
index d16fd61..ab3db0f 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -145,7 +145,8 @@ struct quick_symbol_functions
      If no such symbol table can be found, returns 0.
      
      Otherwise, sets *RESULT to the symbol table and returns 1.  This
-     might return 1 and set *RESULT to NULL; see lookup_symtab.  */
+     might return 1 and set *RESULT to NULL if the requested file is
+     an include file that does not have a symtab of its own.  */
   int (*lookup_symtab) (struct objfile *objfile,
 			const char *name,
 			const char *full_path,
@@ -153,22 +154,19 @@ struct quick_symbol_functions
 			struct symtab **result);
 
   /* Check to see if the symbol is defined in a "partial" symbol table
-     of OBJFILE.  BLOCK_INDEX should be either GLOBAL_BLOCK or
-     STATIC_BLOCK, depending on whether we want to search global
-     symbols or static symbols.  NAME is the name of the symbol to
-     look for, and LINKAGE_NAME is the linkage name (or NULL).  DOMAIN
-     indicates what sort of symbol to search for. */
-  struct symbol *(*lookup_symbol_aux) (struct objfile *objfile,
-				       int block_index, const char *name,
-				       const char *linkage_name,
-				       const domain_enum domain);
-
-  /* Look up a type in OBJFILE.  NAME is the name of the type.  KIND
-     is either GLOBAL_BLOCK or STATIC_BLOCK, depending on whether we
-     want to search global symbols or static symbols.  */
-  struct type *(*basic_lookup_transparent_type) (struct objfile *objfile,
-						 const char *name,
-						 int kind);
+     of OBJFILE.  KIND should be either GLOBAL_BLOCK or STATIC_BLOCK,
+     depending on whether we want to search global symbols or static
+     symbols.  NAME is the name of the symbol to look for, and
+     LINKAGE_NAME is the linkage name (or NULL).  DOMAIN indicates
+     what sort of symbol to search for.  If DOMAIN is STRUCT_DOMAIN,
+     then LINKAGE_NAME is ignored.
+     
+     Returns the newly-expanded symbol table in which the symbol is
+     defined, or NULL if no such symbol table exists.  */
+  struct symtab *(*lookup_symbol) (struct objfile *objfile,
+				   int kind, const char *name,
+				   const char *linkage_name,
+				   domain_enum domain);
 
   /* Print statistics about any indices loaded for OBJFILE.  The
      statistics should be printed to gdb_stdout.  This is used for
@@ -187,22 +185,22 @@ struct quick_symbol_functions
 
   /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
      the corresponding symbol tables are loaded.  */
-  void (*read_symtabs_for_function) (struct objfile *objfile,
-				     const char *func_name);
+  void (*expand_symtabs_for_function) (struct objfile *objfile,
+				       const char *func_name);
 
   /* Read all symbol tables associated with OBJFILE.  If FROM_TTY is
      true (or if INFO_VERBOSE), this should print some sort of message
      to gdb_stdout.  */
-  void (*expand_symbol_tables) (struct objfile *objfile, int from_tty);
+  void (*expand_all_symtabs) (struct objfile *objfile, int from_tty);
 
   /* Read all symbol tables associated with OBJFILE which have the
      file name FILENAME.  */
-  void (*read_symtabs_with_filename) (struct objfile *objfile,
-				      const char *filename);
+  void (*expand_symtabs_with_filename) (struct objfile *objfile,
+					const char *filename);
 
   /* Return the file name of the file holding the symbol in OBJFILE
      named NAME.  If no such symbol exists in OBJFILE, return NULL.  */
-  char *(*find_symbol_file) (struct objfile *objfile, char *name);
+  char *(*find_symbol_file) (struct objfile *objfile, const char *name);
 
   /* FIXME: document.  */
   void (*map_ada_symtabs) (struct objfile *objfile,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 33d3ee6..c2f7061 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -105,6 +105,13 @@ struct symbol *lookup_symbol_aux_symtabs (int block_index,
 					  const char *linkage_name,
 					  const domain_enum domain);
 
+static
+struct symbol *lookup_symbol_aux_quick (struct objfile *objfile,
+					int block_index,
+					const char *name,
+					const char *linkage_name,
+					const domain_enum domain);
+
 static int file_matches (char *, char **, int);
 
 static void print_symbol_info (domain_enum,
@@ -1031,8 +1038,8 @@ lookup_symbol_aux (const char *name, const char *linkage_name,
 
   ALL_OBJFILES (objfile)
   {
-    sym = objfile->sf->qf->lookup_symbol_aux (objfile, STATIC_BLOCK, name,
-					      linkage_name, domain);
+    sym = lookup_symbol_aux_quick (objfile, STATIC_BLOCK, name,
+				   linkage_name, domain);
     if (sym != NULL)
       return sym;
   }
@@ -1140,10 +1147,8 @@ lookup_global_symbol_from_objfile (const struct objfile *objfile,
   }
 
   /* Now go through psymtabs.  */
-  sym = objfile->sf->qf->lookup_symbol_aux ((struct objfile *) objfile,
-					    GLOBAL_BLOCK,
-					    name, linkage_name,
-					    domain);
+  sym = lookup_symbol_aux_quick ((struct objfile *) objfile, GLOBAL_BLOCK,
+				 name, linkage_name, domain);
   if (sym)
     return sym;
 
@@ -1185,6 +1190,53 @@ lookup_symbol_aux_symtabs (int block_index,
   return NULL;
 }
 
+/* A helper function for lookup_symbol_aux that interfaces with the
+   "quick" symbol table functions.  */
+
+static struct symbol *
+lookup_symbol_aux_quick (struct objfile *objfile, int kind,
+			 const char *name, const char *linkage_name,
+			 const domain_enum domain)
+{
+  struct symtab *symtab;
+  struct blockvector *bv;
+  const struct block *block;
+  struct partial_symtab *ps;
+  struct symbol *sym;
+
+  symtab = objfile->sf->qf->lookup_symbol (objfile, kind, name,
+					   linkage_name, domain);
+  if (!symtab)
+    return NULL;
+
+  bv = BLOCKVECTOR (symtab);
+  block = BLOCKVECTOR_BLOCK (bv, kind);
+  sym = lookup_block_symbol (block, name, linkage_name, domain);
+  if (!sym)
+    {
+      /* This shouldn't be necessary, but as a last resort try
+	 looking in the statics even though the psymtab claimed
+	 the symbol was global, or vice-versa. It's possible
+	 that the psymtab gets it wrong in some cases.  */
+
+      /* FIXME: carlton/2002-09-30: Should we really do that?
+	 If that happens, isn't it likely to be a GDB error, in
+	 which case we should fix the GDB error rather than
+	 silently dealing with it here?  So I'd vote for
+	 removing the check for the symbol in the other
+	 block.  */
+      block = BLOCKVECTOR_BLOCK (bv,
+				 kind == GLOBAL_BLOCK ?
+				 STATIC_BLOCK : GLOBAL_BLOCK);
+      sym = lookup_block_symbol (block, name, linkage_name, domain);
+      if (!sym)
+	error (_("Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n%s may be an inlined function, or may be a template function\n(if a template, try specifying an instantiation: %s<type>)."),
+	       kind == GLOBAL_BLOCK ? "global" : "static",
+	       name, symtab->filename, name, name);
+    }
+  return fixup_symbol_section (sym, objfile);
+}
+
 /* A default version of lookup_symbol_nonlocal for use by languages
    that can't think of anything better to do.  This implements the C
    lookup rules.  */
@@ -1274,8 +1326,8 @@ lookup_symbol_global (const char *name,
 
   ALL_OBJFILES (objfile)
   {
-    sym = objfile->sf->qf->lookup_symbol_aux (objfile, GLOBAL_BLOCK, name,
-					      linkage_name, domain);
+    sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name,
+				   linkage_name, domain);
     if (sym)
       return sym;
   }
@@ -1313,6 +1365,50 @@ lookup_transparent_type (const char *name)
   return current_language->la_lookup_transparent_type (name);
 }
 
+/* A helper for basic_lookup_transparent_type that interfaces with the
+   "quick" symbol table functions.  */
+
+static struct type *
+basic_lookup_transparent_type_quick (struct objfile *objfile, int kind,
+				     const char *name)
+{
+  struct symtab *symtab;
+  struct blockvector *bv;
+  struct block *block;
+  struct symbol *sym;
+
+  symtab = objfile->sf->qf->lookup_symbol (objfile, kind, name, NULL,
+					   STRUCT_DOMAIN);
+  if (!symtab)
+    return NULL;
+
+  bv = BLOCKVECTOR (symtab);
+  block = BLOCKVECTOR_BLOCK (bv, kind);
+  sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+  if (!sym)
+    {
+      int other_kind = kind == GLOBAL_BLOCK ? STATIC_BLOCK : GLOBAL_BLOCK;
+
+      /* This shouldn't be necessary, but as a last resort
+       * try looking in the 'other kind' even though the psymtab
+       * claimed the symbol was one thing. It's possible that
+       * the psymtab gets it wrong in some cases.
+       */
+      block = BLOCKVECTOR_BLOCK (bv, other_kind);
+      sym = lookup_block_symbol (block, name, NULL, STRUCT_DOMAIN);
+      if (!sym)
+	/* FIXME; error is wrong in one case */
+	error (_("Internal: global symbol `%s' found in %s psymtab but not in symtab.\n\
+%s may be an inlined function, or may be a template function\n\
+(if a template, try specifying an instantiation: %s<type>)."),
+	       name, symtab->filename, name, name);
+    }
+  if (!TYPE_IS_OPAQUE (SYMBOL_TYPE (sym)))
+    return SYMBOL_TYPE (sym);
+
+  return NULL;
+}
+
 /* The standard implementation of lookup_transparent_type.  This code
    was modeled on lookup_symbol -- the parts not relevant to looking
    up types were just left out.  In particular it's assumed here that
@@ -1347,8 +1443,7 @@ basic_lookup_transparent_type (const char *name)
 
   ALL_OBJFILES (objfile)
   {
-    t = objfile->sf->qf->basic_lookup_transparent_type (objfile, name,
-							GLOBAL_BLOCK);
+    t = basic_lookup_transparent_type_quick (objfile, GLOBAL_BLOCK, name);
     if (t)
       return t;
   }
@@ -1374,8 +1469,7 @@ basic_lookup_transparent_type (const char *name)
 
   ALL_OBJFILES (objfile)
   {
-    t = objfile->sf->qf->basic_lookup_transparent_type (objfile, name,
-							STATIC_BLOCK);
+    t = basic_lookup_transparent_type_quick (objfile, STATIC_BLOCK, name);
     if (t)
       return t;
   }
@@ -1908,7 +2002,8 @@ find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match)
 
       ALL_OBJFILES (objfile)
       {
-	objfile->sf->qf->read_symtabs_with_filename (objfile, symtab->filename);
+	objfile->sf->qf->expand_symtabs_with_filename (objfile,
+						       symtab->filename);
       }
 
       ALL_SYMTABS (objfile, s)
@@ -4154,8 +4249,8 @@ expand_line_sal (struct symtab_and_line sal)
 
       ALL_OBJFILES (objfile)
       {
-	objfile->sf->qf->read_symtabs_with_filename (objfile,
-						     sal.symtab->filename);
+	objfile->sf->qf->expand_symtabs_with_filename (objfile,
+						       sal.symtab->filename);
       }
 
       /* Now search the symtab for exact matches and append them.  If


hooks/post-receive
--
Repository for Project Archer.


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