From 536a40f3a8d2c18aae18a9137b838ff2accdfc08 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 17 Apr 2021 09:35:04 -0600 Subject: Remove quick_symbol_functions::map_symtabs_matching_filename This replaces quick_symbol_functions::map_symtabs_matching_filename with a call to expand_symtabs_matching. As with the previous patch, rather than update all callers, the implementation is consolidated in objfile::map_symtabs_matching_filename. gdb/ChangeLog 2021-04-17 Tom Tromey * symfile-debug.c (objfile::map_symtabs_matching_filename): Rewrite. * quick-symbol.h (struct quick_symbol_functions) : Remove. * psymtab.c (partial_map_expand_apply) (psymbol_functions::map_symtabs_matching_filename): Remove. * psympriv.h (struct psymbol_functions) : Remove. * objfiles.h (struct objfile) : Update comment. * dwarf2/read.c (struct dwarf2_base_index_functions) : Remove. (dw2_map_expand_apply) (dwarf2_base_index_functions::map_symtabs_matching_filename): Remove. --- gdb/symfile-debug.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'gdb/symfile-debug.c') diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index 0535f41..cc31fc0 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -33,6 +33,7 @@ #include "symtab.h" #include "symfile.h" #include "block.h" +#include "filenames.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 @@ -146,13 +147,51 @@ objfile::map_symtabs_matching_filename real_path ? real_path : NULL, host_address_to_string (&callback)); - bool retval = false; + bool retval = true; + const char *name_basename = lbasename (name); + + auto match_one_filename = [&] (const char *filename, bool basenames) + { + if (compare_filenames_for_search (filename, name)) + return true; + if (basenames && FILENAME_CMP (name_basename, filename) == 0) + return true; + if (real_path != nullptr && IS_ABSOLUTE_PATH (filename) + && IS_ABSOLUTE_PATH (real_path)) + return filename_cmp (filename, real_path) == 0; + return false; + }; + + compunit_symtab *last_made = this->compunit_symtabs; + + auto on_expansion = [&] (compunit_symtab *symtab) + { + /* The callback to iterate_over_some_symtabs returns false to keep + going and true to continue, so we have to invert the result + here, for expand_symtabs_matching. */ + bool result = !iterate_over_some_symtabs (name, real_path, + this->compunit_symtabs, + last_made, + callback); + last_made = this->compunit_symtabs; + return result; + }; + for (const auto &iter : qf) { - retval = (iter->map_symtabs_matching_filename - (this, name, real_path, callback)); - if (retval) - break; + if (!iter->expand_symtabs_matching (this, + match_one_filename, + nullptr, + nullptr, + on_expansion, + (SEARCH_GLOBAL_BLOCK + | SEARCH_STATIC_BLOCK), + UNDEF_DOMAIN, + ALL_DOMAIN)) + { + retval = false; + break; + } } if (debug_symfile) @@ -160,7 +199,9 @@ objfile::map_symtabs_matching_filename "qf->map_symtabs_matching_filename (...) = %d\n", retval); - return retval; + /* We must re-invert the return value here to match the caller's + expectations. */ + return !retval; } struct compunit_symtab * -- cgit v1.1