From: Tom Tromey Date: Thu, 23 Oct 2025 18:13:23 +0000 (-0600) Subject: Remove iterate_over_symbols_terminated X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45b219b3b75fd8786f579ced04622916a9a7639f;p=thirdparty%2Fbinutils-gdb.git Remove iterate_over_symbols_terminated iterate_over_symbols_terminated only has a single caller, in ada-lang.c. It's simpler to handle this case directly there. Approved-By: Simon Marchi --- diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 89c33a84d1d..0c6cdc653f5 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5432,12 +5432,26 @@ struct match_data bool operator() (struct block_symbol *bsym); + void finish (const block *block); + struct objfile *objfile = nullptr; std::vector *resultp; struct symbol *arg_sym = nullptr; bool found_sym = false; }; +/* Finish iteration over one block. If a symbol hasn't been found + already, add 'arg_sym' to the list of symbols. */ + +void +match_data::finish (const block *block) +{ + if (!found_sym && arg_sym != nullptr) + add_defn_to_vec (*resultp, arg_sym, block); + found_sym = false; + arg_sym = nullptr; +} + /* A callback for add_nonlocal_symbols that adds symbol, found in BSYM, to a list of symbols. */ @@ -5447,25 +5461,16 @@ match_data::operator() (struct block_symbol *bsym) const struct block *block = bsym->block; struct symbol *sym = bsym->symbol; - if (sym == NULL) - { - if (!found_sym && arg_sym != NULL) - add_defn_to_vec (*resultp, arg_sym, block); - found_sym = false; - arg_sym = NULL; - } + if (sym->loc_class () == LOC_UNRESOLVED) + return true; + else if (sym->is_argument ()) + arg_sym = sym; else { - if (sym->loc_class () == LOC_UNRESOLVED) - return true; - else if (sym->is_argument ()) - arg_sym = sym; - else - { - found_sym = true; - add_defn_to_vec (*resultp, sym, block); - } + found_sym = true; + add_defn_to_vec (*resultp, sym, block); } + return true; } @@ -5561,8 +5566,12 @@ map_matching_symbols (struct objfile *objfile, { const struct block *block = symtab->blockvector ()->block (block_kind); - return iterate_over_symbols_terminated (block, lookup_name, - domain, data); + /* match_data::operator() always returns true; we ignore the + result but assert just to be future-proof. */ + bool result = iterate_over_symbols (block, lookup_name, domain, data); + gdb_assert (result); + data.finish (block); + return true; }; objfile->search (nullptr, &lookup_name, nullptr, callback, diff --git a/gdb/symtab.c b/gdb/symtab.c index fd08ca7f15e..e65744bea23 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2698,21 +2698,6 @@ iterate_over_symbols (const struct block *block, return true; } -/* See symtab.h. */ - -bool -iterate_over_symbols_terminated - (const struct block *block, - const lookup_name_info &name, - const domain_search_flags domain, - gdb::function_view callback) -{ - if (!iterate_over_symbols (block, name, domain, callback)) - return false; - struct block_symbol block_sym = {nullptr, block}; - return callback (&block_sym); -} - /* Find the compunit symtab associated with PC and SECTION. This will read in debug info as necessary. */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 616119d50fb..6049d60a5dc 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -2826,16 +2826,6 @@ bool iterate_over_symbols (const struct block *block, const domain_search_flags domain, gdb::function_view callback); -/* Like iterate_over_symbols, but if all calls to CALLBACK return - true, then calls CALLBACK one additional time with a block_symbol - that has a valid block but a NULL symbol. */ - -bool iterate_over_symbols_terminated - (const struct block *block, - const lookup_name_info &name, - const domain_search_flags domain, - gdb::function_view callback); - /* Storage type used by demangle_for_lookup. demangle_for_lookup either returns a const char * pointer that points to either of the fields of this type, or a pointer to the input NAME. This is done