Allow passing a block to lookup_global_symbol_from_objfile
authorChristian Biesinger <cbiesinger@google.com>
Tue, 25 Jun 2019 20:45:41 +0000 (15:45 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Thu, 25 Jul 2019 00:02:50 +0000 (19:02 -0500)
This has no behavior change in itself, but allows a future patch
to add a function to the Python API to look up symbols in the
static block.

gdb/ChangeLog:

2019-07-24  Christian Biesinger  <cbiesinger@google.com>

* compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
* solib-spu.c (spu_lookup_lib_symbol): Pass GLOBAL_SCOPE.
* solib-svr4.c (elf_lookup_lib_symbol): Pass GLOBAL_SCOPE.
* symtab.c (lookup_global_symbol_from_objfile): Add a scope parameter.
* symtab.h (lookup_global_symbol_from_objfile): Likewise.

gdb/ChangeLog
gdb/compile/compile-object-load.c
gdb/solib-spu.c
gdb/solib-svr4.c
gdb/symtab.c
gdb/symtab.h

index 2ed8f65ba354bd279c353dc32133dc824f23c373..e24988858bb1d3681be2d44b7189d8d5c76c1892 100644 (file)
@@ -1,3 +1,12 @@
+2019-07-22  Christian Biesinger  <cbiesinger@google.com>
+
+       * compile/compile-object-load.c (compile_object_load): Pass GLOBAL_SCOPE.
+       * solib-spu.c (spu_lookup_lib_symbol): Pass GLOBAL_SCOPE.
+       * solib-svr4.c (elf_lookup_lib_symbol): Pass GLOBAL_SCOPE.
+       * symtab.c (lookup_global_symbol_from_objfile): Add a scope parameter.
+       * symtab.h (lookup_global_symbol_from_objfile): Likewise.
+
+
 2019-07-24  Yoshinori Sato  <ysato@users.sourceforge.jp>
 
        * h8300-tdep.c (h8300_register_name_common): New.
index 4e702051950c6e431a84eb46f2f2ad213070160a..3a765a345bf9b8b5160715d124fe34d16ad38ff8 100644 (file)
@@ -639,6 +639,7 @@ compile_object_load (const compile_file_names &file_names,
   objfile = objfile_holder.get ();
 
   func_sym = lookup_global_symbol_from_objfile (objfile,
+                                               GLOBAL_BLOCK,
                                                GCC_FE_WRAPPER_FUNCTION,
                                                VAR_DOMAIN).symbol;
   if (func_sym == NULL)
index 448e1a64f4cb99536930b5b65db46104b6a13af1..5b97b9bcf68885c0cc78f2548eb51217121810bf 100644 (file)
@@ -392,7 +392,8 @@ spu_lookup_lib_symbol (struct objfile *objfile,
                       const domain_enum domain)
 {
   if (bfd_get_arch (objfile->obfd) == bfd_arch_spu)
-    return lookup_global_symbol_from_objfile (objfile, name, domain);
+    return lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, name,
+                                             domain);
 
   if (svr4_so_ops.lookup_lib_global_symbol != NULL)
     return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain);
index 8cd5b7d8e7031fd13ea913ac232853b8eef2e2e4..c0c505acaa023d14e0ed200e8564bf8a48d6d3ba 100644 (file)
@@ -3226,7 +3226,8 @@ elf_lookup_lib_symbol (struct objfile *objfile,
   if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL, NULL) != 1)
     return {};
 
-  return lookup_global_symbol_from_objfile (objfile, name, domain);
+  return lookup_global_symbol_from_objfile (objfile, GLOBAL_BLOCK, name,
+                                           domain);
 }
 
 void
index 5b8bfc1df7e44bcc8d04900748dec6466beabce1..87a0c8e4da6eb420098f5433444e5ee8a3e1f8f2 100644 (file)
@@ -2224,15 +2224,18 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
 
 struct block_symbol
 lookup_global_symbol_from_objfile (struct objfile *main_objfile,
+                                  enum block_enum block_index,
                                   const char *name,
                                   const domain_enum domain)
 {
+  gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
+
   for (objfile *objfile : main_objfile->separate_debug_objfiles ())
     {
       struct block_symbol result
-        = lookup_symbol_in_objfile (objfile, GLOBAL_BLOCK, name, domain);
+        = lookup_symbol_in_objfile (objfile, block_index, name, domain);
 
-      if (result.symbol != NULL)
+      if (result.symbol != nullptr)
        return result;
     }
 
index b91454c85c4f91d865b6ff1358954b696987b50f..9880ecc4c5380ba2ef8b4198bc40bfa9b76fb1f5 100644 (file)
@@ -2045,13 +2045,16 @@ extern bool treg_matches_sym_type_name (const compiled_regex &treg,
 extern const char *main_name ();
 extern enum language main_language (void);
 
-/* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global blocks.
+/* Lookup symbol NAME from DOMAIN in MAIN_OBJFILE's global or static blocks,
+   as specified by BLOCK_INDEX.
    This searches MAIN_OBJFILE as well as any associated separate debug info
    objfiles of MAIN_OBJFILE.
+   BLOCK_INDEX can be GLOBAL_BLOCK or STATIC_BLOCK.
    Upon success fixes up the symbol's section if necessary.  */
 
 extern struct block_symbol
   lookup_global_symbol_from_objfile (struct objfile *main_objfile,
+                                    enum block_enum block_index,
                                     const char *name,
                                     const domain_enum domain);