Change map_matching_symbols to take a symbol_found_callback_ftype

This changes map_matching_symbols to take a
symbol_found_callback_ftype, rather than separate callback and data
parameters.  This enables a future patch to clean up some existing
code so that it can more readily be shared.

gdb/ChangeLog
2019-09-10  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (aux_add_nonlocal_symbols): Change type.
	(add_nonlocal_symbols): Update.
	* dwarf2read.c (dw2_map_matching_symbols): Change type.
	* psymtab.c (map_block, psym_map_matching_symbols): Change type.
	* symfile-debug.c (debug_qf_map_matching_symbols): Change type.
	* symfile.h (struct quick_symbol_functions) <map_matching_symbols>:
	Change type of "callback".  Remove "data".
This commit is contained in:
Tom Tromey 2019-07-12 10:45:34 -06:00
parent aebcfb76fc
commit 199b4314ef
6 changed files with 73 additions and 65 deletions

View file

@ -5331,8 +5331,8 @@ struct match_data
int found_sym;
};
/* A callback for add_nonlocal_symbols that adds SYM, found in BLOCK,
to a list of symbols. DATA0 is a pointer to a struct match_data *
/* A callback for add_nonlocal_symbols that adds symbol, found in BSYM,
to a list of symbols. DATA is a pointer to a struct match_data *
containing the obstack that collects the symbol list, the file that SYM
must come from, a flag indicating whether a non-argument symbol has
been found in the current block, and the last argument symbol
@ -5340,12 +5340,13 @@ struct match_data
marking the end of a block, the argument symbol is added if no
other has been found. */
static int
aux_add_nonlocal_symbols (const struct block *block, struct symbol *sym,
void *data0)
static bool
aux_add_nonlocal_symbols (struct block_symbol *bsym,
struct match_data *data)
{
struct match_data *data = (struct match_data *) data0;
const struct block *block = bsym->block;
struct symbol *sym = bsym->symbol;
if (sym == NULL)
{
if (!data->found_sym && data->arg_sym != NULL)
@ -5358,7 +5359,7 @@ aux_add_nonlocal_symbols (const struct block *block, struct symbol *sym,
else
{
if (SYMBOL_CLASS (sym) == LOC_UNRESOLVED)
return 0;
return true;
else if (SYMBOL_IS_ARGUMENT (sym))
data->arg_sym = sym;
else
@ -5369,7 +5370,7 @@ aux_add_nonlocal_symbols (const struct block *block, struct symbol *sym,
block);
}
}
return 0;
return true;
}
/* Helper for add_nonlocal_symbols. Find symbols in DOMAIN which are
@ -5540,20 +5541,23 @@ add_nonlocal_symbols (struct obstack *obstackp,
bool is_wild_match = lookup_name.ada ().wild_match_p ();
auto callback = [&] (struct block_symbol *bsym)
{
return aux_add_nonlocal_symbols (bsym, &data);
};
for (objfile *objfile : current_program_space->objfiles ())
{
data.objfile = objfile;
if (is_wild_match)
objfile->sf->qf->map_matching_symbols (objfile, lookup_name.name ().c_str (),
domain, global,
aux_add_nonlocal_symbols, &data,
domain, global, callback,
symbol_name_match_type::WILD,
NULL);
else
objfile->sf->qf->map_matching_symbols (objfile, lookup_name.name ().c_str (),
domain, global,
aux_add_nonlocal_symbols, &data,
domain, global, callback,
symbol_name_match_type::FULL,
compare_names);
@ -5577,9 +5581,7 @@ add_nonlocal_symbols (struct obstack *obstackp,
{
data.objfile = objfile;
objfile->sf->qf->map_matching_symbols (objfile, name1.c_str (),
domain, global,
aux_add_nonlocal_symbols,
&data,
domain, global, callback,
symbol_name_match_type::FULL,
compare_names);
}