/* Helper struct for building the address table. */
struct addrmap_index_data
{
- addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_)
- : addr_vec (addr_vec_), cu_index_htab (cu_index_htab_)
+ addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_,
+ bool using_index_)
+ : addr_vec (addr_vec_),
+ cu_index_htab (cu_index_htab_),
+ using_index (using_index_)
{}
data_buf &addr_vec;
int operator() (CORE_ADDR start_addr, void *obj);
+ /* True if the DWARF reader uses the new DWARF indexer. */
+ bool using_index;
/* True if the previous_* fields are valid.
We can't write an entry until we see the next entry (since it is only then
that we know the end of the entry). */
int
addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj)
{
- dwarf2_psymtab *pst = (dwarf2_psymtab *) obj;
+ dwarf2_per_cu_data *per_cu;
+ if (using_index)
+ per_cu = (dwarf2_per_cu_data *) obj;
+ else
+ per_cu = obj == nullptr ? nullptr : ((dwarf2_psymtab *) obj)->per_cu_data;
if (previous_valid)
add_address_entry (addr_vec,
previous_cu_index);
previous_cu_start = start_addr;
- if (pst != NULL)
+ if (per_cu != NULL)
{
- const auto it = cu_index_htab.find (pst->per_cu_data);
+ const auto it = cu_index_htab.find (per_cu);
gdb_assert (it != cu_index_htab.cend ());
previous_cu_index = it->second;
previous_valid = true;
static void
write_address_map (struct addrmap *addrmap, data_buf &addr_vec,
- cu_index_map &cu_index_htab)
+ cu_index_map &cu_index_htab, bool using_index)
{
- struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab);
+ struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab,
+ using_index);
addrmap_foreach (addrmap, addrmap_index_data);
/* Dump the address map. */
data_buf addr_vec;
- write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap,
- addr_vec, cu_index_htab);
+ if (per_objfile->per_bfd->using_index)
+ {
+ std::vector<addrmap *> addrmaps
+ = per_objfile->per_bfd->cooked_index_table->get_addrmaps ();
+ for (auto map : addrmaps)
+ write_address_map (map, addr_vec, cu_index_htab, true);
+ }
+ else
+ write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap,
+ addr_vec, cu_index_htab,
+ per_objfile->per_bfd->using_index);
/* Now that we've processed all symbols we can shrink their cu_indices
lists. */