/* Look up ADDR in the address map, and return either the
corresponding CU, or nullptr if the address could not be
found. */
- dwarf2_per_cu_data *lookup (unrelocated_addr addr);
+ dwarf2_per_cu_data *lookup (unrelocated_addr addr) override;
/* Return a new vector of all the addrmaps used by all the indexes
held by this object. */
return table;
}
- dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc) override;
-
struct compunit_symtab *find_compunit_symtab_by_address
(struct objfile *objfile, CORE_ADDR address) override;
virtual void wait_completely ()
{
}
+
+ /* Look up ADDR, and return either the corresponding CU, or nullptr
+ if the address could not be found. */
+ virtual dwarf2_per_cu_data *lookup (unrelocated_addr addr)
+ { return nullptr; }
};
/* Base class containing bits shared by both .gdb_index and
/* 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
{
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
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,
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);
}
return NULL;
}
-dwarf2_per_cu_data *
-dwarf2_base_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc)
-{
- if (per_bfd->index_addrmap == nullptr)
- return nullptr;
-
- void *obj = per_bfd->index_addrmap->find ((CORE_ADDR) adjusted_pc);
- return static_cast<dwarf2_per_cu_data *> (obj);
-}
-
struct compunit_symtab *
dwarf2_base_index_functions::find_pc_sect_compunit_symtab
(struct objfile *objfile,
struct compunit_symtab *result;
dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+ dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
+
+ if (per_bfd->index_table == nullptr)
+ return nullptr;
CORE_ADDR baseaddr = objfile->text_section_offset ();
struct dwarf2_per_cu_data *data
- = find_per_cu (per_objfile->per_bfd, (unrelocated_addr) (pc - baseaddr));
+ = per_bfd->index_table->lookup ((unrelocated_addr) (pc - baseaddr));
if (data == nullptr)
return nullptr;
index_dies (reader, reader->info_ptr, nullptr, false);
}
-dwarf2_per_cu_data *
-cooked_index_functions::find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc)
-{
- cooked_index *table
- = (gdb::checked_static_cast<cooked_index *>
- (per_bfd->index_table.get ()));
- return table->lookup (adjusted_pc);
-}
-
struct compunit_symtab *
cooked_index_functions::find_compunit_symtab_by_address
(struct objfile *objfile, CORE_ADDR address)
std::unordered_map<sect_offset, std::vector<sect_offset>,
gdb::hash_enum<sect_offset>>
abstract_to_concrete;
-
- /* The address map that is used by the DWARF index code. */
- addrmap_fixed *index_addrmap = nullptr;
};
/* An iterator for all_units that is based on index. This
void expand_all_symtabs (struct objfile *objfile) override;
- /* A helper function that finds the per-cu object from an "adjusted"
- PC -- a PC with the base text offset removed. */
- virtual dwarf2_per_cu_data *find_per_cu (dwarf2_per_bfd *per_bfd,
- unrelocated_addr adjusted_pc);
-
struct compunit_symtab *find_pc_sect_compunit_symtab
(struct objfile *objfile, struct bound_minimal_symbol msymbol,
CORE_ADDR pc, struct obj_section *section, int warn_if_readin)