aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog24
-rw-r--r--gdb/ada-lang.c41
-rw-r--r--gdb/dwarf2/read.c42
-rw-r--r--gdb/objfiles.h3
-rw-r--r--gdb/psympriv.h3
-rw-r--r--gdb/psymtab.c23
-rw-r--r--gdb/quick-symbol.h15
-rw-r--r--gdb/symfile-debug.c9
8 files changed, 76 insertions, 84 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6de85cb..33a0997 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,29 @@
2021-04-17 Tom Tromey <tom@tromey.com>
+ * psymtab.c (psymbol_functions::expand_matching_symbols): Rename
+ from map_matching_symbols. Change parameters.
+ * psympriv.h (struct psymbol_functions) <expand_matching_symbols>:
+ Rename from map_matching_symbols. Change parameters.
+ * dwarf2/read.c (struct dwarf2_gdb_index)
+ <expand_matching_symbols>: Rename from map_matching_symbols.
+ Change parameters.
+ (struct dwarf2_debug_names_index) <expand_matching_symbols>:
+ Rename from map_matching_symbols. Change parameters.
+ (dwarf2_gdb_index::expand_matching_symbols): Rename from
+ dw2_map_matching_symbols. Change parameters.
+ (dwarf2_gdb_index::expand_matching_symbols): Remove old
+ implementation.
+ (dwarf2_debug_names_index::expand_matching_symbols): Rename from
+ map_matching_symbols. Change parameters.
+ * objfiles.h (struct objfile) <expand_matching_symbols>: Rename
+ from map_matching_symbols. Change parameters.
+ * symfile-debug.c (objfile::expand_matching_symbols): Rename from
+ map_matching_symbols. Change parameters.
+ * ada-lang.c (map_matching_symbols): New function.
+ (add_nonlocal_symbols): Update.
+
+2021-04-17 Tom Tromey <tom@tromey.com>
+
* quick-symbol.h (struct quick_symbol_functions)
<expand_symtabs_with_fullname>: Remove.
* psymtab.c (psymbol_functions::expand_symtabs_with_fullname):
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 589fbf1..d170a1e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5175,6 +5175,33 @@ 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);
+
+ 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, data))
+ 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
@@ -5191,10 +5218,8 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
for (objfile *objfile : current_program_space->objfiles ())
{
- data.objfile = objfile;
-
- objfile->map_matching_symbols (lookup_name, domain, global, data,
- is_wild_match ? NULL : compare_names);
+ map_matching_symbols (objfile, lookup_name, is_wild_match, domain,
+ global, data);
for (compunit_symtab *cu : objfile->compunits ())
{
@@ -5214,12 +5239,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, data,
- compare_names);
- }
- }
+ map_matching_symbols (objfile, name1, false, domain, global, data);
+ }
}
/* Find symbols in DOMAIN matching LOOKUP_NAME, in BLOCK and, if
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 6befb77..22a5f33 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2260,12 +2260,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
@@ -2283,12 +2282,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
@@ -3538,11 +3536,10 @@ dw2_expand_symtabs_matching_one
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify);
void
-dwarf2_gdb_index::map_matching_symbols
+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. */
@@ -3581,18 +3578,6 @@ dwarf2_gdb_index::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;
- }
}
/* Starting from a search name, return the string that finds the upper
@@ -5509,11 +5494,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);
@@ -5523,7 +5507,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;
@@ -5549,23 +5532,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
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 90ea49e..5a8a782 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -621,10 +621,9 @@ public:
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. */
diff --git a/gdb/psympriv.h b/gdb/psympriv.h
index a539571..59dd66f 100644
--- a/gdb/psympriv.h
+++ b/gdb/psympriv.h
@@ -518,12 +518,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
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 7c73293..75a307c 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -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);
}
}
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index d883d7b..f06ceff 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -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.
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index dd5a70b..b839194 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -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