@@ -5180,6 +5180,38 @@ ada_lookup_name (const lookup_name_info &lookup_name)
return lookup_name.ada ().lookup_name ().c_str ();
}
+/* A helper for add_nonlocal_symbols. Call expand_matching_symbols
+ for OBJFILE, then walk the objfile's symtabs and update the
+ results. */
+
+static void
+map_matching_symbols (struct objfile *objfile,
+ const lookup_name_info &lookup_name,
+ bool is_wild_match,
+ domain_enum domain,
+ int global,
+ match_data *data)
+{
+ data->objfile = objfile;
+ objfile->expand_matching_symbols (lookup_name, domain, global,
+ is_wild_match ? nullptr : compare_names);
+
+ auto callback = [&] (struct block_symbol *bsym)
+ {
+ return aux_add_nonlocal_symbols (bsym, data);
+ };
+
+ const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
+ for (compunit_symtab *symtab : objfile->compunits ())
+ {
+ const struct block *block
+ = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (symtab), block_kind);
+ if (!iterate_over_symbols_terminated (block, lookup_name,
+ domain, callback))
+ break;
+ }
+}
+
/* Add to RESULT all non-local symbols whose name and domain match
LOOKUP_NAME and DOMAIN respectively. The search is performed on
GLOBAL_BLOCK symbols if GLOBAL is non-zero, or on STATIC_BLOCK
@@ -5194,17 +5226,10 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
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;
-
- objfile->map_matching_symbols (lookup_name, domain, global, callback,
- is_wild_match ? NULL : compare_names);
+ map_matching_symbols (objfile, lookup_name, is_wild_match, domain,
+ global, &data);
for (compunit_symtab *cu : objfile->compunits ())
{
@@ -5224,12 +5249,8 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
lookup_name_info name1 (bracket_name, symbol_name_match_type::FULL);
for (objfile *objfile : current_program_space->objfiles ())
- {
- data.objfile = objfile;
- objfile->map_matching_symbols (name1, domain, global, callback,
- compare_names);
- }
- }
+ map_matching_symbols (objfile, name1, false, domain, global, &data);
+ }
}
/* Find symbols in DOMAIN matching LOOKUP_NAME, in BLOCK and, if
@@ -2231,12 +2231,11 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
{
void dump (struct objfile *objfile) override;
- void map_matching_symbols
+ void expand_matching_symbols
(struct objfile *,
const lookup_name_info &lookup_name,
domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare) override;
bool expand_symtabs_matching
@@ -2254,12 +2253,11 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions
{
void dump (struct objfile *objfile) override;
- void map_matching_symbols
+ void expand_matching_symbols
(struct objfile *,
const lookup_name_info &lookup_name,
domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare) override;
bool expand_symtabs_matching
@@ -3508,12 +3506,11 @@ dw2_expand_symtabs_matching_one
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify);
-static void
-dw2_map_matching_symbols
+void
+dwarf2_gdb_index::expand_matching_symbols
(struct objfile *objfile,
const lookup_name_info &name, domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare)
{
/* Used for Ada. */
@@ -3552,30 +3549,6 @@ dw2_map_matching_symbols
/* We have -readnow: no .gdb_index, but no partial symtabs either. So,
proceed assuming all symtabs have been read in. */
}
-
- for (compunit_symtab *cust : objfile->compunits ())
- {
- const struct block *block;
-
- if (cust == NULL)
- continue;
- block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
- if (!iterate_over_symbols_terminated (block, name,
- domain, callback))
- return;
- }
-}
-
-void
-dwarf2_gdb_index::map_matching_symbols
- (struct objfile *objfile,
- const lookup_name_info &name, domain_enum domain,
- int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
- symbol_compare_ftype *ordered_compare)
-{
- dw2_map_matching_symbols (objfile, name, domain, global, callback,
- ordered_compare);
}
/* Starting from a search name, return the string that finds the upper
@@ -5508,11 +5481,10 @@ dwarf2_debug_names_index::dump (struct objfile *objfile)
}
void
-dwarf2_debug_names_index::map_matching_symbols
+dwarf2_debug_names_index::expand_matching_symbols
(struct objfile *objfile,
const lookup_name_info &name, domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
@@ -5522,7 +5494,6 @@ dwarf2_debug_names_index::map_matching_symbols
return;
mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
- const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
const block_search_flags block_flags
= global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK;
@@ -5548,23 +5519,6 @@ dwarf2_debug_names_index::map_matching_symbols
nullptr);
return true;
}, per_objfile);
-
- /* It's a shame we couldn't do this inside the
- dw2_expand_symtabs_matching_symbol callback, but that skips CUs
- that have already been expanded. Instead, this loop matches what
- the psymtab code does. */
- for (dwarf2_per_cu_data *per_cu : per_objfile->per_bfd->all_comp_units)
- {
- compunit_symtab *symtab = per_objfile->get_symtab (per_cu);
- if (symtab != nullptr)
- {
- const struct block *block
- = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (symtab), block_kind);
- if (!iterate_over_symbols_terminated (block, name,
- domain, callback))
- break;
- }
- }
}
bool
@@ -593,10 +593,9 @@ struct objfile
void expand_symtabs_with_fullname (const char *fullname);
/* See quick_symbol_functions. */
- void map_matching_symbols
+ void expand_matching_symbols
(const lookup_name_info &name, domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare);
/* See quick_symbol_functions. */
@@ -517,12 +517,11 @@ struct psymbol_functions : public quick_symbol_functions
void expand_all_symtabs (struct objfile *objfile) override;
- void map_matching_symbols
+ void expand_matching_symbols
(struct objfile *,
const lookup_name_info &lookup_name,
domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare) override;
bool expand_symtabs_matching
@@ -979,36 +979,23 @@ psymtab_to_fullname (struct partial_symtab *ps)
return ps->fullname;
}
-/* Psymtab version of map_matching_symbols. See its definition in
+/* Psymtab version of expand_matching_symbols. See its definition in
the definition of quick_symbol_functions in symfile.h. */
void
-psymbol_functions::map_matching_symbols
+psymbol_functions::expand_matching_symbols
(struct objfile *objfile,
const lookup_name_info &name, domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare)
{
- const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
-
for (partial_symtab *ps : require_partial_symbols (objfile))
{
QUIT;
- if (ps->readin_p (objfile)
- || match_partial_symbol (objfile, ps, global, name, domain,
+ if (!ps->readin_p (objfile)
+ && match_partial_symbol (objfile, ps, global, name, domain,
ordered_compare))
- {
- struct compunit_symtab *cust = psymtab_to_symtab (objfile, ps);
- const struct block *block;
-
- if (cust == NULL)
- continue;
- block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
- if (!iterate_over_symbols_terminated (block, name,
- domain, callback))
- return;
- }
+ psymtab_to_symtab (objfile, ps);
}
}
@@ -120,11 +120,10 @@ struct quick_symbol_functions
virtual void expand_all_symtabs (struct objfile *objfile) = 0;
/* Find global or static symbols in all tables that are in DOMAIN
- and for which MATCH (symbol name, NAME) == 0, passing each to
- CALLBACK, reading in partial symbol tables as needed. Look
- through global symbols if GLOBAL and otherwise static symbols.
- Passes NAME and NAMESPACE to CALLBACK with each symbol
- found. After each block is processed, passes NULL to CALLBACK.
+ and for which MATCH (symbol name, NAME) == 0, reading in partial
+ symbol tables as needed. Look through global symbols if GLOBAL
+ and otherwise static symbols.
+
MATCH must be weaker than strcmp_iw_ordered in the sense that
strcmp_iw_ordered(x,y) == 0 --> MATCH(x,y) == 0. ORDERED_COMPARE,
if non-null, must be an ordering relation compatible with
@@ -133,15 +132,13 @@ struct quick_symbol_functions
and
strcmp_iw_ordered(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0
(allowing strcmp_iw_ordered(x,y) < 0 while ORDERED_COMPARE(x, y) == 0).
- CALLBACK returns true to indicate that the scan should continue, or
- false to indicate that the scan should be terminated. */
+ */
- virtual void map_matching_symbols
+ virtual void expand_matching_symbols
(struct objfile *,
const lookup_name_info &lookup_name,
domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare) = 0;
/* Expand all symbol tables in OBJFILE matching some criteria.
@@ -353,22 +353,21 @@ objfile::expand_symtabs_with_fullname (const char *fullname)
}
void
-objfile::map_matching_symbols
+objfile::expand_matching_symbols
(const lookup_name_info &name, domain_enum domain,
int global,
- gdb::function_view<symbol_found_callback_ftype> callback,
symbol_compare_ftype *ordered_compare)
{
if (debug_symfile)
fprintf_filtered (gdb_stdlog,
- "qf->map_matching_symbols (%s, %s, %d, %s)\n",
+ "qf->expand_matching_symbols (%s, %s, %d, %s)\n",
objfile_debug_name (this),
domain_name (domain), global,
host_address_to_string (ordered_compare));
for (const auto &iter : qf)
- iter->map_matching_symbols (this, name, domain, global,
- callback, ordered_compare);
+ iter->expand_matching_symbols (this, name, domain, global,
+ ordered_compare);
}
bool