]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove lookup_objfile_from_block
authorTom Tromey <tom@tromey.com>
Fri, 15 May 2020 22:24:07 +0000 (16:24 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 15 May 2020 22:24:07 +0000 (16:24 -0600)
lookup_objfile_from_block mostly duplicates the functionality of
block_objfile, but in a less efficient way.  This patch removes this
function and changes the callers to use block_objfile instead.

Tested by the buildbot.

gdb/ChangeLog
2020-05-15  Tom Tromey  <tom@tromey.com>

* symtab.c (lookup_language_this, lookup_symbol_aux): Use
block_objfile.
(lookup_objfile_from_block): Remove.
(lookup_symbol_in_block, lookup_symbol_in_static_block)
(lookup_global_symbol): Use block_objfile.
* symtab.h (lookup_objfile_from_block): Don't declare.
* printcmd.c (clear_dangling_display_expressions): Use
block_objfile.
* parse.c (operator_check_standard): Use block_objfile.

gdb/ChangeLog
gdb/parse.c
gdb/printcmd.c
gdb/symtab.c
gdb/symtab.h

index 4b6294f4faff146667c24201d832a71e6056cfc2..7b19973118a59cdff7f8e5c6a41dba73fb83fc91 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-15  Tom Tromey  <tom@tromey.com>
+
+       * symtab.c (lookup_language_this, lookup_symbol_aux): Use
+       block_objfile.
+       (lookup_objfile_from_block): Remove.
+       (lookup_symbol_in_block, lookup_symbol_in_static_block)
+       (lookup_global_symbol): Use block_objfile.
+       * symtab.h (lookup_objfile_from_block): Don't declare.
+       * printcmd.c (clear_dangling_display_expressions): Use
+       block_objfile.
+       * parse.c (operator_check_standard): Use block_objfile.
+
 2020-05-15  Tom Tromey  <tom@tromey.com>
 
        * language.c (language_alloc_type_symbol): Set
index b4d9005de55d7281a5aa7bd365e61152d416cb67..d5efe4ab3d8cb4c5107253097e5d75c206442568 100644 (file)
@@ -1340,7 +1340,7 @@ operator_check_standard (struct expression *exp, int pos,
          return 1;
 
        /* Check objfile where is placed the code touching the variable.  */
-       objfile = lookup_objfile_from_block (block);
+       objfile = block_objfile (block);
 
        type = SYMBOL_TYPE (symbol);
       }
index c94ad0a56005462b8a0969d6d230ee1dd276b869..388a0b2c6d414450f6c54c5f463d538167b29a9b 100644 (file)
@@ -2128,12 +2128,20 @@ clear_dangling_display_expressions (struct objfile *objfile)
       if (d->pspace != pspace)
        continue;
 
-      if (lookup_objfile_from_block (d->block) == objfile
+      struct objfile *bl_objf = nullptr;
+      if (d->block != nullptr)
+       {
+         bl_objf = block_objfile (d->block);
+         if (bl_objf->separate_debug_objfile_backlink != nullptr)
+           bl_objf = bl_objf->separate_debug_objfile_backlink;
+       }
+
+      if (bl_objf == objfile
          || (d->exp != NULL && exp_uses_objfile (d->exp.get (), objfile)))
-      {
-       d->exp.reset ();
-       d->block = NULL;
-      }
+       {
+         d->exp.reset ();
+         d->block = NULL;
+       }
     }
 }
 \f
index 16ebe4d39f41d7c3cf84e8d131078c014ede174d..1a5de4d8aa8862b518b8daec68b92b4fe4646ae9 100644 (file)
@@ -1917,7 +1917,7 @@ lookup_language_this (const struct language_defn *lang,
 
   if (symbol_lookup_debug > 1)
     {
-      struct objfile *objfile = lookup_objfile_from_block (block);
+      struct objfile *objfile = block_objfile (block);
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_language_this (%s, %s (objfile %s))",
@@ -2012,7 +2012,8 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
 
   if (symbol_lookup_debug)
     {
-      struct objfile *objfile = lookup_objfile_from_block (block);
+      struct objfile *objfile = (block == nullptr
+                                ? nullptr : block_objfile (block));
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_symbol_aux (%s, %s (objfile %s), %s, %s)\n",
@@ -2157,32 +2158,6 @@ lookup_local_symbol (const char *name,
 
 /* See symtab.h.  */
 
-struct objfile *
-lookup_objfile_from_block (const struct block *block)
-{
-  if (block == NULL)
-    return NULL;
-
-  block = block_global_block (block);
-  /* Look through all blockvectors.  */
-  for (objfile *obj : current_program_space->objfiles ())
-    {
-      for (compunit_symtab *cust : obj->compunits ())
-       if (block == BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust),
-                                       GLOBAL_BLOCK))
-         {
-           if (obj->separate_debug_objfile_backlink)
-             obj = obj->separate_debug_objfile_backlink;
-
-           return obj;
-         }
-    }
-
-  return NULL;
-}
-
-/* See symtab.h.  */
-
 struct symbol *
 lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
                        const struct block *block,
@@ -2192,7 +2167,8 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
 
   if (symbol_lookup_debug > 1)
     {
-      struct objfile *objfile = lookup_objfile_from_block (block);
+      struct objfile *objfile = (block == nullptr
+                                ? nullptr : block_objfile (block));
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_symbol_in_block (%s, %s (objfile %s), %s)",
@@ -2482,7 +2458,8 @@ lookup_symbol_in_static_block (const char *name,
 
   if (symbol_lookup_debug)
     {
-      struct objfile *objfile = lookup_objfile_from_block (static_block);
+      struct objfile *objfile = (block == nullptr
+                                ? nullptr : block_objfile (block));
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_symbol_in_static_block (%s, %s (objfile %s),"
@@ -2704,7 +2681,14 @@ lookup_global_symbol (const char *name,
        return { sym, global_block };
     }
 
-  struct objfile *objfile = lookup_objfile_from_block (block);
+  struct objfile *objfile = nullptr;
+  if (block != nullptr)
+    {
+      objfile = block_objfile (block);
+      if (objfile->separate_debug_objfile_backlink != nullptr)
+       objfile = objfile->separate_debug_objfile_backlink;
+    }
+
   block_symbol bs
     = lookup_global_or_static_symbol (name, GLOBAL_BLOCK, objfile, domain);
   if (better_symbol (sym, bs.symbol, domain) == sym)
index aaf42a576a41630405741737b9b4f0e8b5c48df5..05e6a311b875b5d1fccb812730cf06b8b89cf80e 100644 (file)
@@ -2238,10 +2238,6 @@ bool producer_is_realview (const char *producer);
 void fixup_section (struct general_symbol_info *ginfo,
                    CORE_ADDR addr, struct objfile *objfile);
 
-/* Look up objfile containing BLOCK.  */
-
-struct objfile *lookup_objfile_from_block (const struct block *block);
-
 extern unsigned int symtab_create_debug;
 
 extern unsigned int symbol_lookup_debug;