aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/index-write.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-11-22 17:05:55 -0700
committerTom Tromey <tom@tromey.com>2022-04-20 09:10:03 -0600
commita827b8ec32f9e0ed10b2bf647ce983db813a3d3c (patch)
tree9226cd00839bc1cfce10251a42651834f0ceaa78 /gdb/dwarf2/index-write.c
parentf75a1d3a732d96ed4adadddaaeafe17732453256 (diff)
downloadbinutils-a827b8ec32f9e0ed10b2bf647ce983db813a3d3c.zip
binutils-a827b8ec32f9e0ed10b2bf647ce983db813a3d3c.tar.gz
binutils-a827b8ec32f9e0ed10b2bf647ce983db813a3d3c.tar.bz2
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.
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r--gdb/dwarf2/index-write.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 58b0f0b..b7a2e21 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -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"));
}