18#include "llvm/Support/Casting.h"
35 : m_dwarf(
dwarf), m_context(context), m_units(), m_cu_aranges_up() {}
49 std::set<dw_offset_t> cus_with_data;
53 cus_with_data.insert(offset);
65 for (
size_t idx = 0; idx < num_units; ++idx) {
69 if (cus_with_data.find(offset) == cus_with_data.end())
74 const bool minimize =
true;
86 llvm::Expected<DWARFUnitSP> expected_unit_sp =
89 if (!expected_unit_sp) {
92 LLDB_LOG(log,
"Unable to extract DWARFUnitHeader at {0:x}: {1}",
94 llvm::toString(expected_unit_sp.takeError()));
96 llvm::consumeError(expected_unit_sp.takeError());
103 assert((
bool)unit_sp);
109 if (unit_sp->GetUnitType() == lldb_private::dwarf::DW_UT_skeleton) {
110 if (std::optional<uint64_t> unit_dwo_id = unit_sp->GetHeaderDWOId())
115 offset = unit_sp->GetNextUnitOffset();
117 if (
auto *type_unit = llvm::dyn_cast<DWARFTypeUnit>(unit_sp.get())) {
130 if (!dwo_id.has_value())
156 for (uint32_t i = 0, num =
GetNumUnits(); i < num; ++i) {
158 if (unit->GetVersion() < 5) {
159 if (std::optional<uint64_t> unit_dwo_id = unit->GetDWOId())
160 m_dwarf4_dwo_id_to_skeleton_unit[*unit_dwo_id] = unit;
199 auto pos = llvm::upper_bound(
200 m_units, std::make_pair(section, offset),
201 [](
const std::pair<DIERef::Section, dw_offset_t> &lhs,
203 return lhs < std::make_pair(rhs->GetDebugSection(), rhs->GetOffset());
205 uint32_t idx = std::distance(
m_units.begin(), pos);
216 if (result && result->
GetOffset() != cu_offset) {
241 std::make_pair(hash, 0u), llvm::less_first());
258 return cu->GetNonSkeletonUnit().
GetDIE(die_offset);
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
A plug-in interface definition class for object file parsers.
virtual bool CanTrustAddressRanges()
Can we trust the address ranges accelerator associated with this object file to be complete.
ObjectFile * GetObjectFile() override
const DWARFDataExtractor & getOrLoadArangesData()
const DWARFDataExtractor & getOrLoadDebugTypesData()
const DWARFDataExtractor & getOrLoadDebugInfoData()
DWARFDIE GetDIE(dw_offset_t die_offset) const
const std::shared_ptr< SymbolFileDWARFDwo > & GetDwpSymbolFile()
DWARFUnit * GetSkeletonUnit(DWARFUnit *dwo_unit)
DWARFDebugInfo(SymbolFileDWARF &dwarf, DWARFContext &context)
SymbolFileDWARF & m_dwarf
llvm::once_flag m_dwarf4_dwo_id_to_skeleton_unit_once_flag
DWARFTypeUnit * GetTypeUnitForHash(uint64_t hash)
DWARFUnit * GetUnitAtOffset(DIERef::Section section, dw_offset_t cu_offset, uint32_t *idx_ptr=nullptr)
uint32_t FindUnitIndex(DIERef::Section section, dw_offset_t offset)
const DWARFDebugAranges & GetCompileUnitAranges()
void ParseUnitsFor(DIERef::Section section)
llvm::DenseMap< uint64_t, DWARFUnit * > m_dwarf4_dwo_id_to_skeleton_unit
llvm::DenseMap< uint64_t, DWARFUnit * > m_dwarf5_dwo_id_to_skeleton_unit
llvm::once_flag m_units_once_flag
std::vector< std::pair< uint64_t, uint32_t > > m_type_hash_to_unit_index
void ParseUnitHeadersIfNeeded()
DWARFDIE GetDIE(DIERef::Section section, dw_offset_t die_offset)
std::unique_ptr< DWARFDebugAranges > m_cu_aranges_up
DWARFUnit * GetUnitContainingDIEOffset(DIERef::Section section, dw_offset_t die_offset)
DWARFUnit * GetUnitAtIndex(size_t idx)
static llvm::Expected< DWARFUnitSP > extract(SymbolFileDWARF &dwarf2Data, lldb::user_id_t uid, const DWARFDataExtractor &debug_info, DIERef::Section section, lldb::offset_t *offset_ptr)
bool ContainsDIEOffset(dw_offset_t die_offset) const
dw_offset_t GetOffset() const
uint16_t GetVersion() const
virtual void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges)=0
std::optional< uint64_t > GetDWOId()
Get the DWO ID from the DWARFUnitHeader for DWARF5, or from the unit DIE's DW_AT_dwo_id or DW_AT_GNU_...
const std::shared_ptr< SymbolFileDWARFDwo > & GetDwpSymbolFile()
#define DW_INVALID_OFFSET
std::shared_ptr< DWARFUnit > DWARFUnitSP
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.