}
DISABLE_COPY_AND_ASSIGN (match_data);
- bool operator() (struct block_symbol *bsym);
+ void operator() (struct block_symbol *bsym);
void finish (const block *block);
/* A callback for add_nonlocal_symbols that adds symbol, found in
BSYM, to a list of symbols. */
-bool
+void
match_data::operator() (struct block_symbol *bsym)
{
const struct block *block = bsym->block;
struct symbol *sym = bsym->symbol;
if (sym->loc_class () == LOC_UNRESOLVED)
- return true;
+ return;
else if (sym->is_argument ())
arg_sym = sym;
else
found_sym = true;
add_defn_to_vec (*resultp, sym, block);
}
-
- return true;
}
/* Helper for add_nonlocal_symbols. Find symbols in DOMAIN which are
{
const struct block *block
= symtab->blockvector ()->block (block_kind);
- /* 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);
+ for_each_symbol (block, lookup_name, domain, data);
data.finish (block);
return iteration_status::keep_going;
};
ada_add_local_symbols (result, lookup_name, block, domain);
else
{
- /* In the !full_search case we're are being called by
- iterate_over_symbols, and we don't want to search
- superblocks. */
+ /* In the !full_search case we're being called by for_each_symbol, and
+ we don't want to search superblocks. */
ada_add_block_symbols (result, block, lookup_name, domain, NULL);
}
if (!result.empty () || !full_search)
/* See language.h. */
- bool iterate_over_symbols
+ void for_each_symbol
(const struct block *block, const lookup_name_info &name,
domain_search_flags domain,
- symbol_found_callback_ftype callback) const override
+ for_each_symbol_callback_ftype callback) const override
{
std::vector<struct block_symbol> results
= ada_lookup_symbol_list_worker (name, block, domain, 0);
for (block_symbol &sym : results)
- {
- if (!callback (&sym))
- return false;
- }
-
- return true;
+ callback (&sym);
}
/* See language.h. */
The caller is responsible for iterating up through superblocks
if desired.
- For each one, call CALLBACK with the symbol. If CALLBACK
- returns false, the iteration ends at that point.
-
- This field may not be NULL. If the language does not need any
- special processing here, 'iterate_over_symbols' should be
- used as the definition. */
- virtual bool iterate_over_symbols
+ For each one, call CALLBACK with the symbol. */
+ virtual void for_each_symbol
(const struct block *block, const lookup_name_info &name,
domain_search_flags domain,
- symbol_found_callback_ftype callback) const
+ for_each_symbol_callback_ftype callback) const
{
- return ::iterate_over_symbols (block, name, domain, callback);
+ ::for_each_symbol (block, name, domain, callback);
}
/* Return a pointer to the function that should be used to match a
std::vector<bound_minimal_symbol> *minimal_symbols;
/* Possibly add a symbol to the results. */
- bool add_symbol (block_symbol *bsym);
+ void add_symbol (block_symbol *bsym);
};
-bool
+void
collect_info::add_symbol (block_symbol *bsym)
{
if (record_all || bsym->symbol->loc_class () == LOC_BLOCK)
this->symbols->push_back (*bsym);
-
- /* Continue iterating. */
- return true;
}
/* Token types */
static void iterate_over_file_blocks
(struct symtab *symtab, const lookup_name_info &name,
domain_search_flags domain,
- symbol_found_callback_ftype callback);
+ for_each_symbol_callback_ftype callback);
static void initialize_defaults (struct symtab **default_symtab,
int *default_line);
const lookup_name_info &lookup_name,
const domain_search_flags domain,
struct program_space *search_pspace, bool include_inline,
- symbol_found_callback_ftype callback)
+ for_each_symbol_callback_ftype callback)
{
for (struct program_space *pspace : program_spaces)
{
for (i = FIRST_LOCAL_BLOCK; i < bv->num_blocks (); i++)
{
block = bv->block (i);
- state->language->iterate_over_symbols
+ state->language->for_each_symbol
(block, lookup_name, domain,
[&] (block_symbol *bsym)
{
/* Restrict calls to CALLBACK to symbols
representing inline symbols only. */
if (bsym->symbol->is_inlined ())
- return callback (bsym);
- return true;
+ callback (bsym);
});
}
}
iterate_over_file_blocks
(struct symtab *symtab, const lookup_name_info &name,
domain_search_flags domain,
- symbol_found_callback_ftype callback)
+ for_each_symbol_callback_ftype callback)
{
const struct block *block;
for (block = symtab->compunit ()->blockvector ()->static_block ();
block != NULL;
block = block->superblock ())
- current_language->iterate_over_symbols (block, name, domain, callback);
+ current_language->for_each_symbol (block, name, domain, callback);
}
/* A helper for find_method. This finds all methods in type T of
namespace {
-/* A function object that serves as symbol_found_callback_ftype
- callback for iterate_over_symbols. This is used by
+/* A function object that serves as for_each_symbol_callback_ftype
+ callback for for_each_symbol. This is used by
lookup_prefix_sym to collect type symbols. */
class decode_compound_collector
{
return std::move (m_symbols);
}
- /* Callable as a symbol_found_callback_ftype callback. */
- bool operator () (block_symbol *bsym);
+ /* Callable as a for_each_symbol_callback_ftype callback. */
+ void operator () (block_symbol *bsym);
private:
/* A hash table of all symbols we found. We use this to avoid
std::vector<block_symbol> m_symbols;
};
-bool
+void
decode_compound_collector::operator () (block_symbol *bsym)
{
struct type *t;
struct symbol *sym = bsym->symbol;
if (sym->loc_class () != LOC_TYPEDEF)
- return true; /* Continue iterating. */
+ return;
t = sym->type ();
t = check_typedef (t);
if (t->code () != TYPE_CODE_STRUCT
&& t->code () != TYPE_CODE_UNION
&& t->code () != TYPE_CODE_NAMESPACE)
- return true; /* Continue iterating. */
+ return;
if (m_unique_syms.insert (sym).second)
m_symbols.push_back (*bsym);
-
- return true; /* Continue iterating. */
}
} // namespace
auto add_symbol = [&] (block_symbol *bsym)
{
- return info->add_symbol (bsym);
+ info->add_symbol (bsym);
};
for (const auto &elt : info->file_symtabs)
/* Iterate over all LWPs, calling CALLBACK for every LWP.
- Only consider the LWPs matching FILTER. */
+ Only consider the LWPs that match FILTER. */
static void
for_each_lwp (ptid_t filter, for_each_lwp_ftype callback)
(*orig_lp)->status = 0;
}
-/* Return non-zero if LP has been resumed. */
+/* Return true if LP has been resumed. */
static bool
resumed_callback (struct lwp_info *lp)
/* Iterate over all LWPs, calling CALLBACK for every LWP.
- Only consider the LWPs with that pid. */
+ Only consider the LWPs that match PID. */
extern void for_each_lwp (int pid, for_each_lwp_ftype callback);
/* See symtab.h. */
-bool
-iterate_over_symbols (const struct block *block,
- const lookup_name_info &name,
- const domain_search_flags domain,
- symbol_found_callback_ftype callback)
+void
+for_each_symbol (const struct block *block, const lookup_name_info &name,
+ const domain_search_flags domain,
+ for_each_symbol_callback_ftype callback)
{
for (struct symbol *sym : block_iterator_range (block, &name))
- {
- if (sym->matches (domain))
- {
- struct block_symbol block_sym = {sym, block};
+ if (sym->matches (domain))
+ {
+ block_symbol block_sym = { sym, block };
- if (!callback (&block_sym))
- return false;
- }
- }
- return true;
+ callback (&block_sym);
+ }
}
/* Find the compunit symtab associated with PC and SECTION.
std::vector<const linetable_entry *> find_linetable_entries_for_symtab_line
(struct symtab *symtab, int line, const linetable_entry **best_entry);
-/* Prototype for callbacks for LA_ITERATE_OVER_SYMBOLS. The callback
- is called once per matching symbol SYM. The callback should return
- true to indicate that LA_ITERATE_OVER_SYMBOLS should continue
- iterating, or false to indicate that the iteration should end. */
+/* Callback type for function for_each_symbol. */
-using symbol_found_callback_ftype = gdb::function_view<bool (block_symbol *)>;
+using for_each_symbol_callback_ftype
+ = gdb::function_view<void (block_symbol *)>;
/* Iterate over the symbols named NAME, matching DOMAIN, in BLOCK.
- For each symbol that matches, CALLBACK is called. The symbol is
- passed to the callback.
+ For each symbol that matches, call CALLBACK with the symbol. */
- If CALLBACK returns false, the iteration ends and this function
- returns false. Otherwise, the search continues, and the function
- eventually returns true. */
-
-bool iterate_over_symbols (const struct block *block,
- const lookup_name_info &name,
- const domain_search_flags domain,
- symbol_found_callback_ftype callback);
+void for_each_symbol (const struct block *block, const lookup_name_info &name,
+ const domain_search_flags domain,
+ for_each_symbol_callback_ftype callback);
/* Storage type used by demangle_for_lookup. demangle_for_lookup
either returns a const char * pointer that points to either of the