diff options
author | Tom Tromey <tom@tromey.com> | 2021-04-17 09:35:04 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-04-17 09:35:05 -0600 |
commit | 84d865e39c3739097d7a3481b9c9b6b6fecb2b06 (patch) | |
tree | 564ba47ed285702b5c3a852def5321870287b1c3 /gdb/symfile-debug.c | |
parent | 3bfa51a75fc18775ea043efb248d0e2c35103202 (diff) | |
download | gdb-84d865e39c3739097d7a3481b9c9b6b6fecb2b06.zip gdb-84d865e39c3739097d7a3481b9c9b6b6fecb2b06.tar.gz gdb-84d865e39c3739097d7a3481b9c9b6b6fecb2b06.tar.bz2 |
Remove quick_symbol_functions::lookup_symbol
This removes quick_symbol_functions, replacing it with calls to
expand_symtabs_matching. Because the replacement is somewhat verbose,
objfile::lookup_symbol is not removed. This consolidates some
duplicated code into this one spot.
gdb/ChangeLog
2021-04-17 Tom Tromey <tom@tromey.com>
* symfile-debug.c (objfile::lookup_symbol): Rewrite.
* quick-symbol.h (struct quick_symbol_functions) <lookup_symbol>:
Remove.
* psymtab.c (psymbol_functions::lookup_symbol): Remove.
* psympriv.h (struct psymbol_functions) <lookup_symbol>: Remove.
* objfiles.h (struct objfile) <lookup_symbol>: Add comment.
* dwarf2/read.c (struct dwarf2_gdb_index) <lookup_symbol>:
Remove.
(struct dwarf2_debug_names_index) <lookup_symbol>: Remove.
(dwarf2_gdb_index::lookup_symbol)
(dwarf2_debug_names_index::lookup_symbol): Remove.
Diffstat (limited to 'gdb/symfile-debug.c')
-rw-r--r-- | gdb/symfile-debug.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 577b0fc..0535f41 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -32,6 +32,7 @@ #include "source.h" #include "symtab.h" #include "symfile.h" +#include "block.h" /* We need to save a pointer to the real symbol functions. Plus, the debug versions are malloc'd because we have to NULL out the @@ -173,10 +174,49 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain) objfile_debug_name (this), kind, name, domain_name (domain)); + lookup_name_info lookup_name (name, symbol_name_match_type::FULL); + + auto search_one_symtab = [&] (compunit_symtab *stab) + { + struct symbol *sym, *with_opaque = NULL; + const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (stab); + const struct block *block = BLOCKVECTOR_BLOCK (bv, kind); + + sym = block_find_symbol (block, name, domain, + block_find_non_opaque_type_preferred, + &with_opaque); + + /* Some caution must be observed with overloaded functions + and methods, since the index will not contain any overload + information (but NAME might contain it). */ + + if (sym != NULL + && SYMBOL_MATCHES_SEARCH_NAME (sym, lookup_name)) + { + retval = stab; + /* Found it. */ + return false; + } + if (with_opaque != NULL + && SYMBOL_MATCHES_SEARCH_NAME (with_opaque, lookup_name)) + retval = stab; + + /* Keep looking through other psymtabs. */ + return true; + }; + for (const auto &iter : qf) { - retval = iter->lookup_symbol (this, kind, name, domain); - if (retval != nullptr) + if (!iter->expand_symtabs_matching (this, + nullptr, + &lookup_name, + nullptr, + search_one_symtab, + kind == GLOBAL_BLOCK + ? SEARCH_GLOBAL_BLOCK + : SEARCH_STATIC_BLOCK, + domain, + ALL_DOMAIN)) break; } |