diff options
author | Tom Tromey <tromey@adacore.com> | 2019-07-12 10:45:34 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2019-09-10 08:30:45 -0600 |
commit | 199b4314efbd419d6957e366e13a14cd87cea5e4 (patch) | |
tree | f1844b4639994e943190a9e15a9940c8bd7318e4 /gdb/ada-lang.c | |
parent | aebcfb76fc165795e67917cb67cf985c4dfdc577 (diff) | |
download | gdb-199b4314efbd419d6957e366e13a14cd87cea5e4.zip gdb-199b4314efbd419d6957e366e13a14cd87cea5e4.tar.gz gdb-199b4314efbd419d6957e366e13a14cd87cea5e4.tar.bz2 |
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".
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 347c67f..d677acd 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -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); } |