aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-29 20:14:30 -0600
committerTom Tromey <tom@tromey.com>2022-04-20 09:10:03 -0600
commit045a7baed2e8039fc734b43f4f35393c76e59e55 (patch)
treecf38a54e1029fa6be202e26dc9a48c68aa9b9f8d /gdb/dwarf2
parentdfaa040b440084dd73ebd359326752d5f44fc02c (diff)
downloadgdb-045a7baed2e8039fc734b43f4f35393c76e59e55.zip
gdb-045a7baed2e8039fc734b43f4f35393c76e59e55.tar.gz
gdb-045a7baed2e8039fc734b43f4f35393c76e59e55.tar.bz2
Introduce readnow_functions
This introduces readnow_functions, a new subclass of dwarf2_base_index_functions, and changes the DWARF reader to use it. This lets us drop the "index is NULL" hack from the gdb index code.
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/read.c109
1 files changed, 56 insertions, 53 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 165bea9..83651f2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1841,6 +1841,40 @@ struct dwarf2_base_index_functions : public quick_symbol_functions
bool need_fullname) override;
};
+/* With OBJF_READNOW, the DWARF reader expands all CUs immediately.
+ It's handy in this case to have an empty implementation of the
+ quick symbol functions, to avoid special cases in the rest of the
+ code. */
+
+struct readnow_functions : public dwarf2_base_index_functions
+{
+ void dump (struct objfile *objfile) override
+ {
+ }
+
+ void expand_matching_symbols
+ (struct objfile *,
+ const lookup_name_info &lookup_name,
+ domain_enum domain,
+ int global,
+ symbol_compare_ftype *ordered_compare) override
+ {
+ }
+
+ bool expand_symtabs_matching
+ (struct objfile *objfile,
+ gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
+ const lookup_name_info *lookup_name,
+ gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
+ gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
+ block_search_flags search_flags,
+ domain_enum domain,
+ enum search_domain kind) override
+ {
+ return true;
+ }
+};
+
struct dwarf2_gdb_index : public dwarf2_base_index_functions
{
void dump (struct objfile *objfile) override;
@@ -1885,12 +1919,6 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions
enum search_domain kind) override;
};
-static quick_symbol_functions_up
-make_dwarf_gdb_index ()
-{
- return quick_symbol_functions_up (new dwarf2_gdb_index);
-}
-
quick_symbol_functions_up
mapped_index::make_quick_functions () const
{
@@ -2910,9 +2938,6 @@ dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
iter->length = 0;
mapped_index *index = per_objfile->per_bfd->index_table.get ();
- /* index is NULL if OBJF_READNOW. */
- if (index == NULL)
- return;
gdb_assert (!index->symbol_name_slot_invalid (namei));
offset_type vec_idx = index->symbol_vec_index (namei);
@@ -3048,14 +3073,8 @@ dwarf2_gdb_index::dump (struct objfile *objfile)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- gdb_printf (".gdb_index:");
- if (per_objfile->per_bfd->index_table != NULL)
- {
- gdb_printf (" version %d\n",
- per_objfile->per_bfd->index_table->version);
- }
- else
- gdb_printf (" faked for \"readnow\"\n");
+ gdb_printf (".gdb_index: version %d\n",
+ per_objfile->per_bfd->index_table->version);
gdb_printf ("\n");
}
@@ -3105,37 +3124,28 @@ dwarf2_gdb_index::expand_matching_symbols
const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
- if (per_objfile->per_bfd->index_table != nullptr)
- {
- mapped_index &index = *per_objfile->per_bfd->index_table;
+ mapped_index &index = *per_objfile->per_bfd->index_table;
- const char *match_name = name.ada ().lookup_name ().c_str ();
- auto matcher = [&] (const char *symname)
- {
- if (ordered_compare == nullptr)
- return true;
- return ordered_compare (symname, match_name) == 0;
- };
+ const char *match_name = name.ada ().lookup_name ().c_str ();
+ auto matcher = [&] (const char *symname)
+ {
+ if (ordered_compare == nullptr)
+ return true;
+ return ordered_compare (symname, match_name) == 0;
+ };
- dw2_expand_symtabs_matching_symbol (index, name, matcher,
- [&] (offset_type namei)
- {
- struct dw2_symtab_iterator iter;
- struct dwarf2_per_cu_data *per_cu;
-
- dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain,
- namei);
- while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
- dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
- nullptr);
- return true;
- }, per_objfile);
- }
- else
+ dw2_expand_symtabs_matching_symbol (index, name, matcher,
+ [&] (offset_type namei)
{
- /* We have -readnow: no .gdb_index, but no partial symtabs either. So,
- proceed assuming all symtabs have been read in. */
- }
+ struct dw2_symtab_iterator iter;
+ struct dwarf2_per_cu_data *per_cu;
+
+ dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, namei);
+ while ((per_cu = dw2_symtab_iter_next (&iter)) != NULL)
+ dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
+ nullptr);
+ return true;
+ }, per_objfile);
}
/* Starting from a search name, return the string that finds the upper
@@ -4151,10 +4161,6 @@ dwarf2_gdb_index::expand_symtabs_matching
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- /* index_table is NULL if OBJF_READNOW. */
- if (!per_objfile->per_bfd->index_table)
- return true;
-
dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
/* This invariant is documented in quick-functions.h. */
@@ -5269,10 +5275,7 @@ dwarf2_initialize_objfile (struct objfile *objfile)
per_bfd->quick_file_names_table
= create_quick_file_names_table (per_bfd->all_comp_units.size ());
- /* Arrange for gdb to see the "quick" functions. However, these
- functions will be no-ops because we will have expanded all
- symtabs. */
- objfile->qf.push_front (make_dwarf_gdb_index ());
+ objfile->qf.emplace_front (new readnow_functions);
return;
}