The dwarf2_per_bfd object has a separate field for each possible kind
of index. Until an earlier patch in this series, two of these were
even derived from a common base class, but still had separate slots.
This patch unifies all the index fields using the common base class
that was introduced earlier in this series. This makes it more
obvious that only a single index can be active at a time, and also
removes some code from dwarf2_initialize_objfile.
/* Write the contents of the internal "cooked" index. */
static void
/* Write the contents of the internal "cooked" index. */
static void
-write_cooked_index (dwarf2_per_objfile *per_objfile,
+write_cooked_index (cooked_index_vector *table,
const cu_index_map &cu_index_htab,
struct mapped_symtab *symtab)
{
const cu_index_map &cu_index_htab,
struct mapped_symtab *symtab)
{
- for (const cooked_index_entry *entry
- : per_objfile->per_bfd->cooked_index_table->all_entries ())
+ for (const cooked_index_entry *entry : table->all_entries ())
{
const auto it = cu_index_htab.find (entry->per_cu);
gdb_assert (it != cu_index_htab.cend ());
{
const auto it = cu_index_htab.find (entry->per_cu);
gdb_assert (it != cu_index_htab.cend ());
- write_cooked_index (per_objfile, cu_index_htab, &symtab);
+ cooked_index_vector *table
+ = (static_cast<cooked_index_vector *>
+ (per_objfile->per_bfd->index_table.get ()));
+ write_cooked_index (table, cu_index_htab, &symtab);
/* Dump the address map. */
data_buf addr_vec;
/* Dump the address map. */
data_buf addr_vec;
- std::vector<addrmap *> addrmaps
- = per_objfile->per_bfd->cooked_index_table->get_addrmaps ();
- for (auto map : addrmaps)
+ for (auto map : table->get_addrmaps ())
write_address_map (map, addr_vec, cu_index_htab);
/* Now that we've processed all symbols we can shrink their cu_indices
write_address_map (map, addr_vec, cu_index_htab);
/* Now that we've processed all symbols we can shrink their cu_indices
- per_objfile->per_bfd->tu_stats.nr_tus));
gdb_assert (types_counter == per_objfile->per_bfd->tu_stats.nr_tus);
- per_objfile->per_bfd->tu_stats.nr_tus));
gdb_assert (types_counter == per_objfile->per_bfd->tu_stats.nr_tus);
- for (const cooked_index_entry *entry
- : per_objfile->per_bfd->cooked_index_table->all_entries ())
+ cooked_index_vector *table
+ = (static_cast<cooked_index_vector *>
+ (per_objfile->per_bfd->index_table.get ()));
+ for (const cooked_index_entry *entry : table->all_entries ())
nametable.insert (entry);
nametable.build ();
nametable.insert (entry);
nametable.build ();
{
struct objfile *objfile = per_objfile->objfile;
{
struct objfile *objfile = per_objfile->objfile;
- if (per_objfile->per_bfd->cooked_index_table == nullptr)
+ cooked_index_vector *table
+ = (static_cast<cooked_index_vector *>
+ (per_objfile->per_bfd->index_table.get ()));
+ if (table == nullptr)
- if (per_objfile->per_bfd->index_table != nullptr
- || per_objfile->per_bfd->debug_names_table != nullptr)
+ if (per_objfile->per_bfd->index_table != nullptr)
error (_("Cannot use an index to create the index"));
error (_("No debugging symbols"));
}
error (_("Cannot use an index to create the index"));
error (_("No debugging symbols"));
}
dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
dwarf2_per_objfile *per_objfile,
gdb::optional<block_enum> block_index,
dw2_symtab_iter_init (struct dw2_symtab_iterator *iter,
dwarf2_per_objfile *per_objfile,
gdb::optional<block_enum> block_index,
- domain_enum domain, offset_type namei)
+ domain_enum domain, offset_type namei,
+ mapped_index &index)
{
iter->per_objfile = per_objfile;
iter->block_index = block_index;
{
iter->per_objfile = per_objfile;
iter->block_index = block_index;
iter->vec = {};
iter->length = 0;
iter->vec = {};
iter->length = 0;
- mapped_index *index = per_objfile->per_bfd->index_table.get ();
-
- gdb_assert (!index->symbol_name_slot_invalid (namei));
- offset_type vec_idx = index->symbol_vec_index (namei);
+ gdb_assert (!index.symbol_name_slot_invalid (namei));
+ offset_type vec_idx = index.symbol_vec_index (namei);
- iter->vec = offset_view (index->constant_pool.slice (vec_idx));
+ iter->vec = offset_view (index.constant_pool.slice (vec_idx));
iter->length = iter->vec[0];
}
iter->length = iter->vec[0];
}
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- gdb_printf (".gdb_index: version %d\n",
- per_objfile->per_bfd->index_table->version);
+ mapped_index *index = (static_cast<mapped_index *>
+ (per_objfile->per_bfd->index_table.get ()));
+ gdb_printf (".gdb_index: version %d\n", index->version);
const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
const block_enum block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
- mapped_index &index = *per_objfile->per_bfd->index_table;
+ mapped_index &index
+ = (static_cast<mapped_index &>
+ (*per_objfile->per_bfd->index_table.get ()));
const char *match_name = name.ada ().lookup_name ().c_str ();
auto matcher = [&] (const char *symname)
const char *match_name = name.ada ().lookup_name ().c_str ();
auto matcher = [&] (const char *symname)
struct dw2_symtab_iterator iter;
struct dwarf2_per_cu_data *per_cu;
struct dw2_symtab_iterator iter;
struct dwarf2_per_cu_data *per_cu;
- dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, namei);
+ dw2_symtab_iter_init (&iter, per_objfile, block_kind, domain, namei,
+ index);
while ((per_cu = dw2_symtab_iter_next (&iter, index)) != NULL)
dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
nullptr);
while ((per_cu = dw2_symtab_iter_next (&iter, index)) != NULL)
dw2_expand_symtabs_matching_one (per_cu, per_objfile, nullptr,
nullptr);
{
offset_type vec_len, vec_idx;
bool global_seen = false;
{
offset_type vec_len, vec_idx;
bool global_seen = false;
- mapped_index &index = *per_objfile->per_bfd->index_table;
+ mapped_index &index
+ = (static_cast<mapped_index &>
+ (*per_objfile->per_bfd->index_table.get ()));
offset_view vec (index.constant_pool.slice (index.symbol_vec_index (idx)));
vec_len = vec[0];
offset_view vec (index.constant_pool.slice (index.symbol_vec_index (idx)));
vec_len = vec[0];
- mapped_index &index = *per_objfile->per_bfd->index_table;
+ mapped_index &index
+ = (static_cast<mapped_index &>
+ (*per_objfile->per_bfd->index_table.get ()));
bool result
= dw2_expand_symtabs_matching_symbol (index, *lookup_name,
bool result
= dw2_expand_symtabs_matching_symbol (index, *lookup_name,
create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges);
create_addrmap_from_aranges (per_objfile, &per_bfd->debug_aranges);
- per_bfd->debug_names_table = std::move (map);
+ per_bfd->index_table = std::move (map);
per_bfd->quick_file_names_table =
create_quick_file_names_table (per_bfd->all_comp_units.size ());
per_bfd->quick_file_names_table =
create_quick_file_names_table (per_bfd->all_comp_units.size ());
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
+ mapped_debug_names &map
+ = (static_cast<mapped_debug_names &>
+ (*per_objfile->per_bfd->index_table.get ()));
const block_search_flags block_flags
= global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK;
const block_search_flags block_flags
= global ? SEARCH_GLOBAL_BLOCK : SEARCH_STATIC_BLOCK;
- mapped_debug_names &map = *per_objfile->per_bfd->debug_names_table;
+ mapped_debug_names &map
+ = (static_cast<mapped_debug_names &>
+ (*per_objfile->per_bfd->index_table.get ()));
bool result
= dw2_expand_symtabs_matching_symbol (map, *lookup_name,
bool result
= dw2_expand_symtabs_matching_symbol (map, *lookup_name,
- /* Was a debug names index already read when we processed an objfile sharing
- PER_BFD? */
- if (per_bfd->debug_names_table != nullptr)
- {
- dwarf_read_debug_printf ("re-using shared debug names table");
- objfile->qf.push_front
- (per_bfd->debug_names_table->make_quick_functions ());
- return;
- }
-
/* Was a GDB index already read when we processed an objfile sharing
PER_BFD? */
if (per_bfd->index_table != nullptr)
{
/* Was a GDB index already read when we processed an objfile sharing
PER_BFD? */
if (per_bfd->index_table != nullptr)
{
- dwarf_read_debug_printf ("re-using shared index table");
+ dwarf_read_debug_printf ("re-using symbols");
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
return;
}
objfile->qf.push_front (per_bfd->index_table->make_quick_functions ());
return;
}
- if (per_bfd->cooked_index_table != nullptr)
- {
- dwarf_read_debug_printf ("re-using cooked index table");
- objfile->qf.push_front
- (per_bfd->cooked_index_table->make_quick_functions ());
- return;
- }
-
if (dwarf2_read_debug_names (per_objfile))
{
dwarf_read_debug_printf ("found debug names");
objfile->qf.push_front
if (dwarf2_read_debug_names (per_objfile))
{
dwarf_read_debug_printf ("found debug names");
objfile->qf.push_front
- (per_bfd->debug_names_table->make_quick_functions ());
+ (per_bfd->index_table->make_quick_functions ());
- if (per_objfile->per_bfd->cooked_index_table != nullptr)
+ if (per_objfile->per_bfd->index_table != nullptr)
}),
indexes.end ());
indexes.shrink_to_fit ();
}),
indexes.end ());
indexes.shrink_to_fit ();
- per_bfd->cooked_index_table.reset
- (new cooked_index_vector (std::move (indexes)));
- const cooked_index_entry *main_entry
- = per_bfd->cooked_index_table->get_main ();
+ cooked_index_vector *vec = new cooked_index_vector (std::move (indexes));
+ per_bfd->index_table.reset (vec);
+
+ const cooked_index_entry *main_entry = vec->get_main ();
if (main_entry != nullptr)
set_objfile_main_name (objfile, main_entry->name,
main_entry->per_cu->lang);
if (main_entry != nullptr)
set_objfile_main_name (objfile, main_entry->name,
main_entry->per_cu->lang);
int warn_if_readin)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
int warn_if_readin)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- if (per_objfile->per_bfd->cooked_index_table == nullptr)
+ if (per_objfile->per_bfd->index_table == nullptr)
return nullptr;
CORE_ADDR baseaddr = objfile->text_section_offset ();
return nullptr;
CORE_ADDR baseaddr = objfile->text_section_offset ();
- dwarf2_per_cu_data *per_cu
- = per_objfile->per_bfd->cooked_index_table->lookup (pc - baseaddr);
+ cooked_index_vector *table
+ = (static_cast<cooked_index_vector *>
+ (per_objfile->per_bfd->index_table.get ()));
+ dwarf2_per_cu_data *per_cu = table->lookup (pc - baseaddr);
if (per_cu == nullptr)
return nullptr;
if (per_cu == nullptr)
return nullptr;
return nullptr;
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
return nullptr;
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- if (per_objfile->per_bfd->cooked_index_table == nullptr)
+ if (per_objfile->per_bfd->index_table == nullptr)
return nullptr;
CORE_ADDR baseaddr = objfile->data_section_offset ();
return nullptr;
CORE_ADDR baseaddr = objfile->data_section_offset ();
- dwarf2_per_cu_data *per_cu
- = per_objfile->per_bfd->cooked_index_table->lookup (address - baseaddr);
+ cooked_index_vector *table
+ = (static_cast<cooked_index_vector *>
+ (per_objfile->per_bfd->index_table.get ()));
+ dwarf2_per_cu_data *per_cu = table->lookup (address - baseaddr);
if (per_cu == nullptr)
return nullptr;
if (per_cu == nullptr)
return nullptr;
symbol_compare_ftype *ordered_compare)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
symbol_compare_ftype *ordered_compare)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- if (per_objfile->per_bfd->cooked_index_table == nullptr)
+ if (per_objfile->per_bfd->index_table == nullptr)
return;
const block_search_flags search_flags = (global
? SEARCH_GLOBAL_BLOCK
return;
const block_search_flags search_flags = (global
? SEARCH_GLOBAL_BLOCK
symbol_name_matcher_ftype *name_match
= lang->get_symbol_name_matcher (lookup_name);
symbol_name_matcher_ftype *name_match
= lang->get_symbol_name_matcher (lookup_name);
- for (const cooked_index_entry *entry
- : per_objfile->per_bfd->cooked_index_table->all_entries ())
+ cooked_index_vector *table
+ = (static_cast<cooked_index_vector *>
+ (per_objfile->per_bfd->index_table.get ()));
+ for (const cooked_index_entry *entry : table->all_entries ())
{
if (entry->parent_entry != nullptr)
continue;
{
if (entry->parent_entry != nullptr)
continue;
enum search_domain kind)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
enum search_domain kind)
{
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
- if (per_objfile->per_bfd->cooked_index_table == nullptr)
+ if (per_objfile->per_bfd->index_table == nullptr)
return true;
dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
return true;
dw_expand_symtabs_matching_file_matcher (per_objfile, file_matcher);
+ cooked_index_vector *table
+ = (static_cast<cooked_index_vector *>
+ (per_objfile->per_bfd->index_table.get ()));
for (enum language lang : unique_styles)
{
std::vector<gdb::string_view> name_vec
= lookup_name_without_params.split_name (lang);
for (enum language lang : unique_styles)
{
std::vector<gdb::string_view> name_vec
= lookup_name_without_params.split_name (lang);
- for (const cooked_index_entry *entry
- : per_objfile->per_bfd->cooked_index_table->find (name_vec.back (),
- completing))
+ for (const cooked_index_entry *entry : table->find (name_vec.back (),
+ completing))
{
/* No need to consider symbols from expanded CUs. */
if (per_objfile->symtab_set_p (entry->per_cu))
{
/* No need to consider symbols from expanded CUs. */
if (per_objfile->symtab_set_p (entry->per_cu))
VMA of 0. */
bool has_section_at_zero = false;
VMA of 0. */
bool has_section_at_zero = false;
- /* The mapped index, or NULL if .gdb_index is missing or not being used. */
- std::unique_ptr<mapped_index> index_table;
-
- /* The mapped index, or NULL if .debug_names is missing or not being used. */
- std::unique_ptr<mapped_debug_names> debug_names_table;
-
- /* The cooked index, or NULL if not using one. */
- std::unique_ptr<cooked_index_vector> cooked_index_table;
+ /* The mapped index, or NULL in the readnow case. */
+ std::unique_ptr<dwarf_scanner_base> index_table;
/* When using index_table, this keeps track of all quick_file_names entries.
TUs typically share line table entries with a CU, so we maintain a
/* When using index_table, this keeps track of all quick_file_names entries.
TUs typically share line table entries with a CU, so we maintain a