Remove quick_symbol_functions::expand_symtabs_for_function

This removes quick_symbol_functions::expand_symtabs_for_function,
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>

	* symfile-debug.c (objfile::expand_symtabs_for_function):
	Rewrite.
	* quick-symbol.h (struct quick_symbol_functions)
	<expand_symtabs_for_function>: Remove.
	* psymtab.c (psymbol_functions::expand_symtabs_for_function):
	Remove.
	* psympriv.h (struct psymbol_functions)
	<expand_symtabs_for_function>: Remove.
	* objfiles.h (struct objfile) <expand_symtabs_for_function>:
	Update comment.
	* dwarf2/read.c (struct dwarf2_gdb_index)
	<expand_symtabs_for_function>: Remove.
	(struct dwarf2_debug_names_index) <expand_symtabs_for_function>:
	Remove.
	(find_slot_in_mapped_hash): Remove.
	(dw2_symtab_iter_init_common): Merge with dw2_symtab_iter_init.
	(dw2_symtab_iter_init): Remove one overload.
	(dwarf2_gdb_index::expand_symtabs_for_function)
	(dwarf2_debug_names_index::expand_symtabs_for_function): Remove.
This commit is contained in:
Tom Tromey 2021-04-17 09:35:04 -06:00
parent 536a40f3a8
commit 7089bd886e
7 changed files with 43 additions and 178 deletions

View File

@ -1,3 +1,25 @@
2021-04-17 Tom Tromey <tom@tromey.com>
* symfile-debug.c (objfile::expand_symtabs_for_function):
Rewrite.
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_for_function>: Remove.
* psymtab.c (psymbol_functions::expand_symtabs_for_function):
Remove.
* psympriv.h (struct psymbol_functions)
<expand_symtabs_for_function>: Remove.
* objfiles.h (struct objfile) <expand_symtabs_for_function>:
Update comment.
* dwarf2/read.c (struct dwarf2_gdb_index)
<expand_symtabs_for_function>: Remove.
(struct dwarf2_debug_names_index) <expand_symtabs_for_function>:
Remove.
(find_slot_in_mapped_hash): Remove.
(dw2_symtab_iter_init_common): Merge with dw2_symtab_iter_init.
(dw2_symtab_iter_init): Remove one overload.
(dwarf2_gdb_index::expand_symtabs_for_function)
(dwarf2_debug_names_index::expand_symtabs_for_function): Remove.
2021-04-17 Tom Tromey <tom@tromey.com>
* symfile-debug.c (objfile::map_symtabs_matching_filename):

View File

@ -2263,9 +2263,6 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
{
void dump (struct objfile *objfile) override;
void expand_symtabs_for_function (struct objfile *objfile,
const char *func_name) override;
void map_matching_symbols
(struct objfile *,
const lookup_name_info &lookup_name,
@ -2289,9 +2286,6 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions
{
void dump (struct objfile *objfile) override;
void expand_symtabs_for_function (struct objfile *objfile,
const char *func_name) override;
void map_matching_symbols
(struct objfile *,
const lookup_name_info &lookup_name,
@ -2939,68 +2933,6 @@ create_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
&per_bfd->obstack);
}
/* Find a slot in the mapped index INDEX for the object named NAME.
If NAME is found, set *VEC_OUT to point to the CU vector in the
constant pool and return true. If NAME cannot be found, return
false. */
static bool
find_slot_in_mapped_hash (struct mapped_index *index, const char *name,
offset_type **vec_out)
{
offset_type hash;
offset_type slot, step;
int (*cmp) (const char *, const char *);
gdb::unique_xmalloc_ptr<char> without_params;
if (current_language->la_language == language_cplus
|| current_language->la_language == language_fortran
|| current_language->la_language == language_d)
{
/* NAME is already canonical. Drop any qualifiers as .gdb_index does
not contain any. */
if (strchr (name, '(') != NULL)
{
without_params = cp_remove_params (name);
if (without_params != NULL)
name = without_params.get ();
}
}
/* Index version 4 did not support case insensitive searches. But the
indices for case insensitive languages are built in lowercase, therefore
simulate our NAME being searched is also lowercased. */
hash = mapped_index_string_hash ((index->version == 4
&& case_sensitivity == case_sensitive_off
? 5 : index->version),
name);
slot = hash & (index->symbol_table.size () - 1);
step = ((hash * 17) & (index->symbol_table.size () - 1)) | 1;
cmp = (case_sensitivity == case_sensitive_on ? strcmp : strcasecmp);
for (;;)
{
const char *str;
const auto &bucket = index->symbol_table[slot];
if (bucket.name == 0 && bucket.vec == 0)
return false;
str = index->constant_pool + MAYBE_SWAP (bucket.name);
if (!cmp (name, str))
{
*vec_out = (offset_type *) (index->constant_pool
+ MAYBE_SWAP (bucket.vec));
return true;
}
slot = (slot + step) & (index->symbol_table.size () - 1);
}
}
/* A helper function that reads the .gdb_index from BUFFER and fills
in MAP. FILENAME is the name of the file containing the data;
it is used for error reporting. DEPRECATED_OK is true if it is
@ -3402,43 +3334,6 @@ struct dw2_symtab_iterator
int global_seen;
};
/* Initialize the index symtab iterator ITER, common part. */
static void
dw2_symtab_iter_init_common (struct dw2_symtab_iterator *iter,
dwarf2_per_objfile *per_objfile,
gdb::optional<block_enum> block_index,
domain_enum domain)
{
iter->per_objfile = per_objfile;
iter->block_index = block_index;
iter->domain = domain;
iter->next = 0;
iter->global_seen = 0;
iter->vec = NULL;
iter->length = 0;
}
/* Initialize the index symtab iterator ITER, const char *NAME variant. */
static void
dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
dwarf2_per_objfile *per_objfile,
gdb::optional<block_enum> block_index,
domain_enum domain,
const char *name)
{
dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain);
mapped_index *index = per_objfile->per_bfd->index_table.get ();
/* index is NULL if OBJF_READNOW. */
if (index == NULL)
return;
if (find_slot_in_mapped_hash (index, name, &iter->vec))
iter->length = MAYBE_SWAP (*iter->vec);
}
/* Initialize the index symtab iterator ITER, offset_type NAMEI variant. */
static void
@ -3447,7 +3342,13 @@ dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
gdb::optional<block_enum> block_index,
domain_enum domain, offset_type namei)
{
dw2_symtab_iter_init_common (iter, per_objfile, block_index, domain);
iter->per_objfile = per_objfile;
iter->block_index = block_index;
iter->domain = domain;
iter->next = 0;
iter->global_seen = 0;
iter->vec = NULL;
iter->length = 0;
mapped_index *index = per_objfile->per_bfd->index_table.get ();
/* index is NULL if OBJF_READNOW. */
@ -3604,22 +3505,6 @@ dwarf2_gdb_index::dump (struct objfile *objfile)
printf_filtered ("\n");
}
void
dwarf2_gdb_index::expand_symtabs_for_function (struct objfile *objfile,
const char *func_name)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
struct dw2_symtab_iterator iter;
struct dwarf2_per_cu_data *per_cu;
dw2_symtab_iter_init (&iter, per_objfile, {}, VAR_DOMAIN, func_name);
while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
dw2_instantiate_symtab (per_cu, per_objfile, false);
}
void
dwarf2_base_index_functions::expand_all_symtabs (struct objfile *objfile)
{
@ -5660,29 +5545,6 @@ dwarf2_debug_names_index::dump (struct objfile *objfile)
printf_filtered ("\n");
}
void
dwarf2_debug_names_index::expand_symtabs_for_function
(struct objfile *objfile, const char *func_name)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
/* per_objfile->per_bfd->debug_names_table is NULL if OBJF_READNOW. */
if (per_objfile->per_bfd->debug_names_table)
{
const mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
dw2_debug_names_iterator iter (map,
(SEARCH_GLOBAL_BLOCK
| SEARCH_STATIC_BLOCK),
VAR_DOMAIN, func_name,
per_objfile);
struct dwarf2_per_cu_data *per_cu;
while ((per_cu = iter.next ()) != NULL)
dw2_instantiate_symtab (per_cu, per_objfile, false);
}
}
void
dwarf2_debug_names_index::map_matching_symbols
(struct objfile *objfile,

View File

@ -606,7 +606,8 @@ public:
/* See quick_symbol_functions. */
void dump ();
/* See quick_symbol_functions. */
/* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
the corresponding symbol tables are loaded. */
void expand_symtabs_for_function (const char *func_name);
/* See quick_symbol_functions. */

View File

@ -516,9 +516,6 @@ struct psymbol_functions : public quick_symbol_functions
void dump (struct objfile *objfile) override;
void expand_symtabs_for_function (struct objfile *objfile,
const char *func_name) override;
void expand_all_symtabs (struct objfile *objfile) override;
void expand_symtabs_with_fullname (struct objfile *objfile,

View File

@ -892,29 +892,6 @@ psymbol_functions::dump (struct objfile *objfile)
}
}
/* Psymtab version of expand_symtabs_for_function. See its definition in
the definition of quick_symbol_functions in symfile.h. */
void
psymbol_functions::expand_symtabs_for_function (struct objfile *objfile,
const char *func_name)
{
lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
lookup_name_info lookup_name = base_lookup.make_ignore_params ();
for (partial_symtab *ps : require_partial_symbols (objfile))
{
if (ps->readin_p (objfile))
continue;
if ((lookup_partial_symbol (objfile, ps, lookup_name, 1, VAR_DOMAIN)
!= NULL)
|| (lookup_partial_symbol (objfile, ps, lookup_name, 0, VAR_DOMAIN)
!= NULL))
psymtab_to_symtab (objfile, ps);
}
}
/* Psymtab version of expand_all_symtabs. See its definition in
the definition of quick_symbol_functions in symfile.h. */

View File

@ -116,11 +116,6 @@ struct quick_symbol_functions
gdb_stdout. This is used for "maint print objfiles". */
virtual void dump (struct objfile *objfile) = 0;
/* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that
the corresponding symbol tables are loaded. */
virtual void expand_symtabs_for_function (struct objfile *objfile,
const char *func_name) = 0;
/* Read all symbol tables associated with OBJFILE. */
virtual void expand_all_symtabs (struct objfile *objfile) = 0;

View File

@ -300,8 +300,19 @@ objfile::expand_symtabs_for_function (const char *func_name)
"qf->expand_symtabs_for_function (%s, \"%s\")\n",
objfile_debug_name (this), func_name);
lookup_name_info base_lookup (func_name, symbol_name_match_type::FULL);
lookup_name_info lookup_name = base_lookup.make_ignore_params ();
for (const auto &iter : qf)
iter->expand_symtabs_for_function (this, func_name);
iter->expand_symtabs_matching (this,
nullptr,
&lookup_name,
nullptr,
nullptr,
(SEARCH_GLOBAL_BLOCK
| SEARCH_STATIC_BLOCK),
VAR_DOMAIN,
ALL_DOMAIN);
}
void