mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 06:17:47 +08:00
Unify the DWARF index holders
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.
This commit is contained in:
@ -1087,12 +1087,11 @@ write_gdbindex_1 (FILE *out_file,
|
||||
/* 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)
|
||||
{
|
||||
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 ());
|
||||
@ -1178,13 +1177,14 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file,
|
||||
++this_counter;
|
||||
}
|
||||
|
||||
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;
|
||||
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
|
||||
@ -1250,8 +1250,10 @@ write_debug_names (dwarf2_per_objfile *per_objfile,
|
||||
- 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 ();
|
||||
@ -1388,10 +1390,12 @@ write_dwarf_index (dwarf2_per_objfile *per_objfile, const char *dir,
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user