Move dwarf2_per_bfd::index_addrmap to mapped_gdb_index

dwarf2_per_bfd::index_addrmap is only used by the .gdb_index reader,
so this field can be moved to mapped_gdb_index instead.  Then,
cooked_index_functions::find_per_cu can be removed in favor of a
method on the index object.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31821
Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey
2024-05-30 10:39:17 -06:00
parent 5df6499c83
commit 2e3b7a3893
5 changed files with 25 additions and 37 deletions

View File

@@ -91,6 +91,9 @@ struct mapped_gdb_index final : public mapped_index_base
/* The shortcut table data. */
gdb::array_view<const gdb_byte> shortcut_table;
/* An address map that maps from PC to dwarf2_per_cu_data. */
addrmap_fixed *index_addrmap = nullptr;
/* Return the index into the constant pool of the name of the IDXth
symbol in the symbol table. */
offset_type symbol_name_index (offset_type idx) const
@@ -129,6 +132,15 @@ struct mapped_gdb_index final : public mapped_index_base
{
return version >= 8;
}
dwarf2_per_cu_data *lookup (unrelocated_addr addr) override
{
if (index_addrmap == nullptr)
return nullptr;
void *obj = index_addrmap->find (static_cast<CORE_ADDR> (addr));
return static_cast<dwarf2_per_cu_data *> (obj);
}
};
struct dwarf2_gdb_index : public dwarf2_base_index_functions
@@ -528,8 +540,7 @@ create_signatured_type_table_from_gdb_index
per_bfd->signatured_types = std::move (sig_types_hash);
}
/* Read the address map data from the mapped GDB index, and use it to
populate the index_addrmap. */
/* Read the address map data from the mapped GDB index. */
static void
create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile,
@@ -570,7 +581,7 @@ create_addrmap_from_gdb_index (dwarf2_per_objfile *per_objfile,
mutable_map.set_empty (lo, hi - 1, per_bfd->get_cu (cu_index));
}
per_bfd->index_addrmap
index->index_addrmap
= new (&per_bfd->obstack) addrmap_fixed (&per_bfd->obstack, &mutable_map);
}