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

	* symfile-debug.c (objfile::map_symtabs_matching_filename):
	Rewrite.
	* quick-symbol.h (struct quick_symbol_functions)
	<map_symtabs_matching_filename>: Remove.
	* psymtab.c (partial_map_expand_apply)
	(psymbol_functions::map_symtabs_matching_filename): Remove.
	* psympriv.h (struct psymbol_functions)
	<map_symtabs_matching_filename>: Remove.
	* objfiles.h (struct objfile) <map_symtabs_matching_filename>:
	Update comment.
	* dwarf2/read.c (struct dwarf2_base_index_functions)
	<map_symtabs_matching_filename>: Remove.
	(dw2_map_expand_apply)
	(dwarf2_base_index_functions::map_symtabs_matching_filename):
	Remove.
This commit is contained in:
Tom Tromey
2021-04-17 09:35:04 -06:00
parent 84d865e39c
commit 536a40f3a8
7 changed files with 77 additions and 215 deletions

View File

@@ -87,96 +87,6 @@ psymbol_functions::require_partial_symbols (struct objfile *objfile)
return m_partial_symtabs->range ();
}
/* Helper function for psym_map_symtabs_matching_filename that
expands the symtabs and calls the iterator. */
static bool
partial_map_expand_apply (struct objfile *objfile,
const char *name,
const char *real_path,
struct partial_symtab *pst,
gdb::function_view<bool (symtab *)> callback)
{
struct compunit_symtab *last_made = objfile->compunit_symtabs;
/* Shared psymtabs should never be seen here. Instead they should
be handled properly by the caller. */
gdb_assert (pst->user == NULL);
/* Don't visit already-expanded psymtabs. */
if (pst->readin_p (objfile))
return 0;
/* This may expand more than one symtab, and we want to iterate over
all of them. */
psymtab_to_symtab (objfile, pst);
return iterate_over_some_symtabs (name, real_path, objfile->compunit_symtabs,
last_made, callback);
}
/* Psymtab version of map_symtabs_matching_filename. See its definition in
the definition of quick_symbol_functions in symfile.h. */
bool
psymbol_functions::map_symtabs_matching_filename
(struct objfile *objfile,
const char *name,
const char *real_path,
gdb::function_view<bool (symtab *)> callback)
{
const char *name_basename = lbasename (name);
for (partial_symtab *pst : require_partial_symbols (objfile))
{
/* Anonymous psymtabs don't have a file name. */
if (pst->anonymous)
continue;
if (compare_filenames_for_search (pst->filename, name))
{
while (pst->user)
pst = pst->user;
if (partial_map_expand_apply (objfile, name, real_path,
pst, callback))
return true;
continue;
}
/* Before we invoke realpath, which can get expensive when many
files are involved, do a quick comparison of the basenames. */
if (! basenames_may_differ
&& FILENAME_CMP (name_basename, lbasename (pst->filename)) != 0)
continue;
if (compare_filenames_for_search (psymtab_to_fullname (pst), name))
{
if (partial_map_expand_apply (objfile, name, real_path,
pst, callback))
return true;
continue;
}
/* If the user gave us an absolute path, try to find the file in
this symtab and use its absolute path. */
if (real_path != NULL)
{
gdb_assert (IS_ABSOLUTE_PATH (real_path));
gdb_assert (IS_ABSOLUTE_PATH (name));
if (filename_cmp (psymtab_to_fullname (pst), real_path) == 0)
{
if (partial_map_expand_apply (objfile, name, real_path,
pst, callback))
return true;
continue;
}
}
}
return false;
}
/* Find which partial symtab contains PC and SECTION starting at psymtab PST.
We may find a different psymtab than PST. See FIND_PC_SECT_PSYMTAB. */