From 90160b57032ce8c2d12864a53036bab2c5b86682 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 17 Apr 2021 09:35:04 -0600 Subject: [PATCH] Remove quick_symbol_functions::expand_symtabs_with_fullname This removes quick_symbol_functions::expand_symtabs_with_fullname, replacing it with a call to expand_symtabs_matching. As with the previous patches, the implementation is consolidated in the objfile method. gdb/ChangeLog 2021-04-17 Tom Tromey * quick-symbol.h (struct quick_symbol_functions) : Remove. * psymtab.c (psymbol_functions::expand_symtabs_with_fullname): Remove. * psympriv.h (struct psymbol_functions) : Remove. * dwarf2/read.c (struct dwarf2_base_index_functions) : Remove. (dwarf2_base_index_functions::expand_symtabs_with_fullname): Remove. * objfiles.h (struct objfile) : Update comment. * symfile-debug.c (objfile::expand_symtabs_with_fullname): Rewrite. --- gdb/ChangeLog | 17 +++++++++++++++++ gdb/dwarf2/read.c | 37 ------------------------------------- gdb/objfiles.h | 6 +++++- gdb/psympriv.h | 3 --- gdb/psymtab.c | 22 ---------------------- gdb/quick-symbol.h | 8 -------- gdb/symfile-debug.c | 16 +++++++++++++++- 7 files changed, 37 insertions(+), 72 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 88e87905915..6de85cb7983 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,20 @@ +2021-04-17 Tom Tromey + + * quick-symbol.h (struct quick_symbol_functions) + : Remove. + * psymtab.c (psymbol_functions::expand_symtabs_with_fullname): + Remove. + * psympriv.h (struct psymbol_functions) + : Remove. + * dwarf2/read.c (struct dwarf2_base_index_functions) + : Remove. + (dwarf2_base_index_functions::expand_symtabs_with_fullname): + Remove. + * objfiles.h (struct objfile) : + Update comment. + * symfile-debug.c (objfile::expand_symtabs_with_fullname): + Rewrite. + 2021-04-17 Tom Tromey * symfile-debug.c (objfile::expand_symtabs_for_function): diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 007b70ec32a..6befb77a2b6 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2241,9 +2241,6 @@ struct dwarf2_base_index_functions : public quick_symbol_functions void expand_all_symtabs (struct objfile *objfile) override; - void expand_symtabs_with_fullname (struct objfile *objfile, - const char *fullname) override; - struct compunit_symtab *find_pc_sect_compunit_symtab (struct objfile *objfile, struct bound_minimal_symbol msymbol, CORE_ADDR pc, struct obj_section *section, int warn_if_readin) override; @@ -3525,40 +3522,6 @@ dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile) } } -void -dwarf2_base_index_functions::expand_symtabs_with_fullname - (struct objfile *objfile, const char *fullname) -{ - dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile); - - /* We don't need to consider type units here. - This is only called for examining code, e.g. expand_line_sal. - There can be an order of magnitude (or more) more type units - than comp units, and we avoid them if we can. */ - - for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units) - { - /* We only need to look at symtabs not already expanded. */ - if (per_objfile->symtab_set_p (per_cu)) - continue; - - quick_file_names *file_data = dw2_get_file_names (per_cu, per_objfile); - if (file_data == NULL) - continue; - - for (int j = 0; j < file_data->num_file_names; ++j) - { - const char *this_fullname = file_data->file_names[j]; - - if (filename_cmp (this_fullname, fullname) == 0) - { - dw2_instantiate_symtab (per_cu, per_objfile, false); - break; - } - } - } -} - static bool dw2_expand_symtabs_matching_symbol (mapped_index_base &index, diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 64cfca41f15..90ea49e7c90 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -613,7 +613,11 @@ public: /* See quick_symbol_functions. */ void expand_all_symtabs (); - /* See quick_symbol_functions. */ + /* Read all symbol tables associated with OBJFILE which have + symtab_to_fullname equal to FULLNAME. + This is for the purposes of examining code only, e.g., expand_line_sal. + The routine may ignore debug info that is known to not be useful with + code, e.g., DW_TAG_type_unit for dwarf debug info. */ void expand_symtabs_with_fullname (const char *fullname); /* See quick_symbol_functions. */ diff --git a/gdb/psympriv.h b/gdb/psympriv.h index 4bd6decfaa4..a5395718b7a 100644 --- a/gdb/psympriv.h +++ b/gdb/psympriv.h @@ -518,9 +518,6 @@ struct psymbol_functions : public quick_symbol_functions void expand_all_symtabs (struct objfile *objfile) override; - void expand_symtabs_with_fullname (struct objfile *objfile, - const char *fullname) override; - void map_matching_symbols (struct objfile *, const lookup_name_info &lookup_name, diff --git a/gdb/psymtab.c b/gdb/psymtab.c index 8afeeb39fb7..7c73293ecf1 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -902,28 +902,6 @@ psymbol_functions::expand_all_symtabs (struct objfile *objfile) psymtab_to_symtab (objfile, psymtab); } -/* Psymtab version of expand_symtabs_with_fullname. See its definition in - the definition of quick_symbol_functions in symfile.h. */ - -void -psymbol_functions::expand_symtabs_with_fullname (struct objfile *objfile, - const char *fullname) -{ - for (partial_symtab *p : require_partial_symbols (objfile)) - { - /* Anonymous psymtabs don't have a name of a source file. */ - if (p->anonymous) - continue; - - /* psymtab_to_fullname tries to open the file which is slow. - Don't call it if we know the basenames don't match. */ - if ((basenames_may_differ - || filename_cmp (lbasename (fullname), lbasename (p->filename)) == 0) - && filename_cmp (fullname, psymtab_to_fullname (p)) == 0) - psymtab_to_symtab (objfile, p); - } -} - /* Psymtab version of map_symbol_filenames. See its definition in the definition of quick_symbol_functions in symfile.h. */ diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h index 1aa02e9ff4c..d883d7b0c1b 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -119,14 +119,6 @@ struct quick_symbol_functions /* Read all symbol tables associated with OBJFILE. */ virtual void expand_all_symtabs (struct objfile *objfile) = 0; - /* Read all symbol tables associated with OBJFILE which have - symtab_to_fullname equal to FULLNAME. - This is for the purposes of examining code only, e.g., expand_line_sal. - The routine may ignore debug info that is known to not be useful with - code, e.g., DW_TAG_type_unit for dwarf debug info. */ - virtual void expand_symtabs_with_fullname (struct objfile *objfile, - const char *fullname) = 0; - /* Find global or static symbols in all tables that are in DOMAIN and for which MATCH (symbol name, NAME) == 0, passing each to CALLBACK, reading in partial symbol tables as needed. Look diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c index deabea4737c..dd5a70b4356 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -334,8 +334,22 @@ objfile::expand_symtabs_with_fullname (const char *fullname) "qf->expand_symtabs_with_fullname (%s, \"%s\")\n", objfile_debug_name (this), fullname); + const char *basename = lbasename (fullname); + auto file_matcher = [&] (const char *filename, bool basenames) + { + return filename_cmp (basenames ? basename : fullname, filename) == 0; + }; + for (const auto &iter : qf) - iter->expand_symtabs_with_fullname (this, fullname); + iter->expand_symtabs_matching (this, + file_matcher, + nullptr, + nullptr, + nullptr, + (SEARCH_GLOBAL_BLOCK + | SEARCH_STATIC_BLOCK), + UNDEF_DOMAIN, + ALL_DOMAIN); } void -- 2.30.2