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  <tom@tromey.com>

	* quick-symbol.h (struct quick_symbol_functions)
	<expand_symtabs_with_fullname>: Remove.
	* psymtab.c (psymbol_functions::expand_symtabs_with_fullname):
	Remove.
	* psympriv.h (struct psymbol_functions)
	<expand_symtabs_with_fullname>: Remove.
	* dwarf2/read.c (struct dwarf2_base_index_functions)
	<expand_symtabs_with_fullname>: Remove.
	(dwarf2_base_index_functions::expand_symtabs_with_fullname):
	Remove.
	* objfiles.h (struct objfile) <expand_symtabs_with_fullname>:
	Update comment.
	* symfile-debug.c (objfile::expand_symtabs_with_fullname):
	Rewrite.
This commit is contained in:
Tom Tromey 2021-04-17 09:35:04 -06:00
parent 7089bd886e
commit 90160b5703
7 changed files with 37 additions and 72 deletions

View File

@ -1,3 +1,20 @@
2021-04-17 Tom Tromey <tom@tromey.com>
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_with_fullname>: Remove.
* psymtab.c (psymbol_functions::expand_symtabs_with_fullname):
Remove.
* psympriv.h (struct psymbol_functions)
<expand_symtabs_with_fullname>: Remove.
* dwarf2/read.c (struct dwarf2_base_index_functions)
<expand_symtabs_with_fullname>: Remove.
(dwarf2_base_index_functions::expand_symtabs_with_fullname):
Remove.
* objfiles.h (struct objfile) <expand_symtabs_with_fullname>:
Update comment.
* symfile-debug.c (objfile::expand_symtabs_with_fullname):
Rewrite.
2021-04-17 Tom Tromey <tom@tromey.com>
* symfile-debug.c (objfile::expand_symtabs_for_function):

View File

@ -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,

View File

@ -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. */

View File

@ -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,

View File

@ -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. */

View File

@ -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

View File

@ -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