keiths / rpms / gdb

Forked from rpms/gdb 18 days ago
Clone
Jan Kratochvil f8eee05
http://sourceware.org/ml/gdb-patches/2012-05/msg01105.html
Jan Kratochvil f8eee05
Subject: [RFA/commit 1/3] Revert "Search global symbols from the expression's block objfile first."
Jan Kratochvil f8eee05
Jan Kratochvil f8eee05
The search order used in this patch breaks global symbol lookups
Jan Kratochvil f8eee05
for certain symbols when copy-relocation is used.  A slightly different
Jan Kratochvil f8eee05
search order will be implemented later.
Jan Kratochvil f8eee05
Jan Kratochvil f8eee05
gdb/ChangeLog:
Jan Kratochvil f8eee05
Jan Kratochvil f8eee05
        Revert the following patch:
Jan Kratochvil f8eee05
        * findvar.c (default_read_var_value): For LOC_UNRESOLVED symbols,
Jan Kratochvil f8eee05
        try locating the symbol in the symbol's own objfile first, before
Jan Kratochvil f8eee05
        extending the search to all objfiles.
Jan Kratochvil f8eee05
        * symtab.c (lookup_symbol_aux_objfile): New function, extracted
Jan Kratochvil f8eee05
        out of lookup_symbol_aux_symtabs.
Jan Kratochvil f8eee05
        (lookup_symbol_aux_symtabs): Add new parameter "exclude_objfile".
Jan Kratochvil f8eee05
        Replace extracted-out code by call to lookup_symbol_aux_objfile.
Jan Kratochvil f8eee05
        Do not search EXCLUDE_OBJFILE.
Jan Kratochvil f8eee05
        (lookup_static_symbol_aux): Update call to lookup_symbol_aux_symtabs.
Jan Kratochvil f8eee05
        (lookup_symbol_global): Search for matches in the block's objfile
Jan Kratochvil f8eee05
        first, before searching all other objfiles.
Jan Kratochvil f8eee05
Jan Kratochvil f8eee05
Will commit if patches #2 & #3 are OK.
Jan Kratochvil f8eee05
Jan Kratochvil f8eee05
---
Jan Kratochvil f8eee05
 gdb/findvar.c |   10 +-----
Jan Kratochvil f8eee05
 gdb/symtab.c  |  108 +++++++++++++++++----------------------------------------
Jan Kratochvil f8eee05
 2 files changed, 33 insertions(+), 85 deletions(-)
Jan Kratochvil f8eee05
Jan Kratochvil f8eee05
diff --git a/gdb/findvar.c b/gdb/findvar.c
Jan Kratochvil f8eee05
index ed7903c..9009e6f 100644
Jan Kratochvil f8eee05
--- a/gdb/findvar.c
Jan Kratochvil f8eee05
+++ b/gdb/findvar.c
Jan Kratochvil f8eee05
@@ -562,15 +562,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame)
Jan Kratochvil f8eee05
 	struct minimal_symbol *msym;
Jan Kratochvil f8eee05
 	struct obj_section *obj_section;
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
-	/* First, try locating the associated minimal symbol within
Jan Kratochvil f8eee05
-	   the same objfile.  This prevents us from selecting another
Jan Kratochvil f8eee05
-	   symbol with the same name but located in a different objfile.  */
Jan Kratochvil f8eee05
-	msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL,
Jan Kratochvil f8eee05
-				      SYMBOL_SYMTAB (var)->objfile);
Jan Kratochvil f8eee05
-	/* If the lookup failed, try expanding the search to all
Jan Kratochvil f8eee05
-	   objfiles.  */
Jan Kratochvil f8eee05
-	if (msym == NULL)
Jan Kratochvil f8eee05
-	  msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
Jan Kratochvil f8eee05
+	msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
Jan Kratochvil f8eee05
 	if (msym == NULL)
Jan Kratochvil f8eee05
 	  error (_("No global symbol \"%s\"."), SYMBOL_LINKAGE_NAME (var));
Jan Kratochvil f8eee05
 	if (overlay_debugging)
Jan Kratochvil f8eee05
diff --git a/gdb/symtab.c b/gdb/symtab.c
Jan Kratochvil f8eee05
index 85ddd1d..39d8c6f 100644
Jan Kratochvil f8eee05
--- a/gdb/symtab.c
Jan Kratochvil f8eee05
+++ b/gdb/symtab.c
Jan Kratochvil f8eee05
@@ -95,8 +95,7 @@ struct symbol *lookup_symbol_aux_local (const char *name,
Jan Kratochvil f8eee05
 static
Jan Kratochvil f8eee05
 struct symbol *lookup_symbol_aux_symtabs (int block_index,
Jan Kratochvil f8eee05
 					  const char *name,
Jan Kratochvil f8eee05
-					  const domain_enum domain,
Jan Kratochvil f8eee05
-					  struct objfile *exclude_objfile);
Jan Kratochvil f8eee05
+					  const domain_enum domain);
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
 static
Jan Kratochvil f8eee05
 struct symbol *lookup_symbol_aux_quick (struct objfile *objfile,
Jan Kratochvil f8eee05
@@ -1360,7 +1359,7 @@ lookup_static_symbol_aux (const char *name, const domain_enum domain)
Jan Kratochvil f8eee05
   struct objfile *objfile;
Jan Kratochvil f8eee05
   struct symbol *sym;
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
-  sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain, NULL);
Jan Kratochvil f8eee05
+  sym = lookup_symbol_aux_symtabs (STATIC_BLOCK, name, domain);
Jan Kratochvil f8eee05
   if (sym != NULL)
Jan Kratochvil f8eee05
     return sym;
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
@@ -1499,61 +1498,40 @@ lookup_global_symbol_from_objfile (const struct objfile *main_objfile,
Jan Kratochvil f8eee05
   return NULL;
Jan Kratochvil f8eee05
 }
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
-/* Check to see if the symbol is defined in one of the OBJFILE's
Jan Kratochvil f8eee05
-   symtabs.  BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK,
Jan Kratochvil f8eee05
+/* Check to see if the symbol is defined in one of the symtabs.
Jan Kratochvil f8eee05
+   BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK,
Jan Kratochvil f8eee05
    depending on whether or not we want to search global symbols or
Jan Kratochvil f8eee05
    static symbols.  */
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
 static struct symbol *
Jan Kratochvil f8eee05
-lookup_symbol_aux_objfile (struct objfile *objfile, int block_index,
Jan Kratochvil f8eee05
-			   const char *name, const domain_enum domain)
Jan Kratochvil f8eee05
-{
Jan Kratochvil f8eee05
-  struct symbol *sym = NULL;
Jan Kratochvil f8eee05
-  struct blockvector *bv;
Jan Kratochvil f8eee05
-  const struct block *block;
Jan Kratochvil f8eee05
-  struct symtab *s;
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-  if (objfile->sf)
Jan Kratochvil f8eee05
-    objfile->sf->qf->pre_expand_symtabs_matching (objfile, block_index,
Jan Kratochvil f8eee05
-						  name, domain);
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-  ALL_OBJFILE_SYMTABS (objfile, s)
Jan Kratochvil f8eee05
-    if (s->primary)
Jan Kratochvil f8eee05
-      {
Jan Kratochvil f8eee05
-	bv = BLOCKVECTOR (s);
Jan Kratochvil f8eee05
-	block = BLOCKVECTOR_BLOCK (bv, block_index);
Jan Kratochvil f8eee05
-	sym = lookup_block_symbol (block, name, domain);
Jan Kratochvil f8eee05
-	if (sym)
Jan Kratochvil f8eee05
-	  {
Jan Kratochvil f8eee05
-	    block_found = block;
Jan Kratochvil f8eee05
-	    return fixup_symbol_section (sym, objfile);
Jan Kratochvil f8eee05
-	  }
Jan Kratochvil f8eee05
-      }
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-  return NULL;
Jan Kratochvil f8eee05
-}
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-/* Same as lookup_symbol_aux_objfile, except that it searches all
Jan Kratochvil f8eee05
-   objfiles except for EXCLUDE_OBJFILE.  Return the first match found.
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-   If EXCLUDE_OBJFILE is NULL, then all objfiles are searched.  */
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-static struct symbol *
Jan Kratochvil f8eee05
 lookup_symbol_aux_symtabs (int block_index, const char *name,
Jan Kratochvil f8eee05
-			   const domain_enum domain,
Jan Kratochvil f8eee05
-			   struct objfile *exclude_objfile)
Jan Kratochvil f8eee05
+			   const domain_enum domain)
Jan Kratochvil f8eee05
 {
Jan Kratochvil f8eee05
   struct symbol *sym;
Jan Kratochvil f8eee05
   struct objfile *objfile;
Jan Kratochvil f8eee05
+  struct blockvector *bv;
Jan Kratochvil f8eee05
+  const struct block *block;
Jan Kratochvil f8eee05
+  struct symtab *s;
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
   ALL_OBJFILES (objfile)
Jan Kratochvil f8eee05
   {
Jan Kratochvil f8eee05
-    if (objfile != exclude_objfile)
Jan Kratochvil f8eee05
-      {
Jan Kratochvil f8eee05
-	sym = lookup_symbol_aux_objfile (objfile, block_index, name, domain);
Jan Kratochvil f8eee05
-	if (sym)
Jan Kratochvil f8eee05
-	  return sym;
Jan Kratochvil f8eee05
-      }
Jan Kratochvil f8eee05
+    if (objfile->sf)
Jan Kratochvil f8eee05
+      objfile->sf->qf->pre_expand_symtabs_matching (objfile,
Jan Kratochvil f8eee05
+						    block_index,
Jan Kratochvil f8eee05
+						    name, domain);
Jan Kratochvil f8eee05
+
Jan Kratochvil f8eee05
+    ALL_OBJFILE_SYMTABS (objfile, s)
Jan Kratochvil f8eee05
+      if (s->primary)
Jan Kratochvil f8eee05
+	{
Jan Kratochvil f8eee05
+	  bv = BLOCKVECTOR (s);
Jan Kratochvil f8eee05
+	  block = BLOCKVECTOR_BLOCK (bv, block_index);
Jan Kratochvil f8eee05
+	  sym = lookup_block_symbol (block, name, domain);
Jan Kratochvil f8eee05
+	  if (sym)
Jan Kratochvil f8eee05
+	    {
Jan Kratochvil f8eee05
+	      block_found = block;
Jan Kratochvil f8eee05
+	      return fixup_symbol_section (sym, objfile);
Jan Kratochvil f8eee05
+	    }
Jan Kratochvil f8eee05
+	}
Jan Kratochvil f8eee05
   }
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
   return NULL;
Jan Kratochvil f8eee05
@@ -1679,46 +1657,24 @@ lookup_symbol_global (const char *name,
Jan Kratochvil f8eee05
 		      const domain_enum domain)
Jan Kratochvil f8eee05
 {
Jan Kratochvil f8eee05
   struct symbol *sym = NULL;
Jan Kratochvil f8eee05
-  struct objfile *block_objfile = NULL;
Jan Kratochvil f8eee05
   struct objfile *objfile = NULL;
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
   /* Call library-specific lookup procedure.  */
Jan Kratochvil f8eee05
-  block_objfile = lookup_objfile_from_block (block);
Jan Kratochvil f8eee05
-  if (block_objfile != NULL)
Jan Kratochvil f8eee05
-    sym = solib_global_lookup (block_objfile, name, domain);
Jan Kratochvil f8eee05
+  objfile = lookup_objfile_from_block (block);
Jan Kratochvil f8eee05
+  if (objfile != NULL)
Jan Kratochvil f8eee05
+    sym = solib_global_lookup (objfile, name, domain);
Jan Kratochvil f8eee05
   if (sym != NULL)
Jan Kratochvil f8eee05
     return sym;
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
-  /* If BLOCK_OBJFILE is not NULL, then search this objfile first.
Jan Kratochvil f8eee05
-     In case the global symbol is defined in multiple objfiles,
Jan Kratochvil f8eee05
-     we have a better chance of finding the most relevant symbol.  */
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-  if (block_objfile != NULL)
Jan Kratochvil f8eee05
-    {
Jan Kratochvil f8eee05
-      sym = lookup_symbol_aux_objfile (block_objfile, GLOBAL_BLOCK,
Jan Kratochvil f8eee05
-				       name, domain);
Jan Kratochvil f8eee05
-      if (sym == NULL)
Jan Kratochvil f8eee05
-	sym = lookup_symbol_aux_quick (block_objfile, GLOBAL_BLOCK,
Jan Kratochvil f8eee05
-				       name, domain);
Jan Kratochvil f8eee05
-      if (sym != NULL)
Jan Kratochvil f8eee05
-	return sym;
Jan Kratochvil f8eee05
-    }
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-  /* Symbol not found in the BLOCK_OBJFILE, so try all the other
Jan Kratochvil f8eee05
-     objfiles, starting with symtabs first, and then partial symtabs.  */
Jan Kratochvil f8eee05
-
Jan Kratochvil f8eee05
-  sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain, block_objfile);
Jan Kratochvil f8eee05
+  sym = lookup_symbol_aux_symtabs (GLOBAL_BLOCK, name, domain);
Jan Kratochvil f8eee05
   if (sym != NULL)
Jan Kratochvil f8eee05
     return sym;
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
   ALL_OBJFILES (objfile)
Jan Kratochvil f8eee05
   {
Jan Kratochvil f8eee05
-    if (objfile != block_objfile)
Jan Kratochvil f8eee05
-      {
Jan Kratochvil f8eee05
-	sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain);
Jan Kratochvil f8eee05
-	if (sym)
Jan Kratochvil f8eee05
-	  return sym;
Jan Kratochvil f8eee05
-      }
Jan Kratochvil f8eee05
+    sym = lookup_symbol_aux_quick (objfile, GLOBAL_BLOCK, name, domain);
Jan Kratochvil f8eee05
+    if (sym)
Jan Kratochvil f8eee05
+      return sym;
Jan Kratochvil f8eee05
   }
Jan Kratochvil f8eee05
 
Jan Kratochvil f8eee05
   return NULL;
Jan Kratochvil f8eee05
-- 
Jan Kratochvil f8eee05
1.7.1
Jan Kratochvil f8eee05