Unify lookup_symbol_in_objfile_symtabs
authorJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 5 Dec 2014 18:39:12 +0000 (19:39 +0100)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Fri, 5 Dec 2014 18:39:12 +0000 (19:39 +0100)
That's right, block_lookup_symbol_primary()'s additional requirement over
block_lookup_symbol() is:
Function is useful if one iterates all global/static blocks of an
objfile.

Which is satisfied both in lookup_symbol_in_objfile_symtabs() and in
lookup_global_symbol_from_objfile() thanks to their's ALL_OBJFILE_COMPUNITS.

In fact after reverting that ba715d7fe49c8a59660fbd571b935b29eb7cfbdb above
the lines of code were exactly the same.

So instead of accelerating both lookup_symbol_in_objfile_symtabs() and
lookup_global_symbol_from_objfile() I just accelerated
lookup_symbol_in_objfile_symtabs() and I am proposing to reuse
lookup_symbol_in_objfile_symtabs() in lookup_global_symbol_from_objfile()
instead.  In fact such unification would already save some lines of code even
before the checked-in acceleration patch above.

gdb/ChangeLog
2014-12-05  Jan Kratochvil  <jan.kratochvil@redhat.com>

* symtab.c (lookup_symbol_in_objfile_symtabs): New declaration.
(lookup_global_symbol_from_objfile): Call it.

gdb/ChangeLog
gdb/symtab.c

index b010c81ce6ed677eecdfb81be80aaf07ead20cf1..83e649e46970ace24559d3034ba3aa3dd12e0e02 100644 (file)
@@ -1,3 +1,8 @@
+2014-12-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       * symtab.c (lookup_symbol_in_objfile_symtabs): New declaration.
+       (lookup_global_symbol_from_objfile): Call it.
+
 2014-12-05  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
        Remove const from struct objfile *.
index c697b1bcca0bcc391fe8af0d7c9f66cb8c3a1486..c07b90268dae20adeddd86e93a09f872bf8089a6 100644 (file)
@@ -79,6 +79,11 @@ struct symbol *lookup_local_symbol (const char *name,
                                    const domain_enum domain,
                                    enum language language);
 
+static struct symbol *
+  lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
+                                   int block_index, const char *name,
+                                   const domain_enum domain);
+
 static
 struct symbol *lookup_symbol_via_quick_fns (struct objfile *objfile,
                                            int block_index,
@@ -1546,24 +1551,12 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
        objfile;
        objfile = objfile_separate_debug_iterate (main_objfile, objfile))
     {
-      struct compunit_symtab *cust;
       struct symbol *sym;
-
-      /* Go through symtabs.  */
-      ALL_OBJFILE_COMPUNITS (objfile, cust)
-       {
-         const struct blockvector *bv;
-         const struct block *block;
-
-         bv = COMPUNIT_BLOCKVECTOR (cust);
-         block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
-         sym = block_lookup_symbol (block, name, domain);
-         if (sym)
-           {
-             block_found = block;
-             return fixup_symbol_section (sym, objfile);
-           }
-       }
+      
+      sym = lookup_symbol_in_objfile_symtabs (objfile, GLOBAL_BLOCK, name,
+                                             domain);
+      if (sym != NULL)
+       return sym;
 
       sym = lookup_symbol_via_quick_fns (objfile, GLOBAL_BLOCK, name, domain);
       if (sym)
This page took 0.033461 seconds and 4 git commands to generate.