aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-05-15 16:24:07 -0600
committerTom Tromey <tom@tromey.com>2020-05-15 16:24:07 -0600
commitd6bc0792edf0ef423ee4604bfd4bee49654314bb (patch)
tree0aa725d9640096dbcde26bc0535ff0d15c7595a1 /gdb/symtab.c
parent8c14c3a3735d7de43e63710b2cd3a2e89cc4e243 (diff)
downloadgdb-d6bc0792edf0ef423ee4604bfd4bee49654314bb.zip
gdb-d6bc0792edf0ef423ee4604bfd4bee49654314bb.tar.gz
gdb-d6bc0792edf0ef423ee4604bfd4bee49654314bb.tar.bz2
Remove lookup_objfile_from_block
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.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 16ebe4d..1a5de4d 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -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)