mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 23:49:22 +08:00
Have DWARFUnit store a *reference* to SymbolFileDWARF
Previously it was storing a *pointer*, which left open the possibility of this pointer being null. We never made use of that possibility (it does not make sense), and most of the code was already assuming that. However, there were a couple of null-checks scattered around the code. This patch replaces the reference with a pointer, making the non-null-ness explicit, and removes the remaining null-checks. llvm-svn: 363381
This commit is contained in:
@@ -47,7 +47,7 @@ ReadAddressFromDebugAddrSection(const DWARFUnit *dwarf_cu,
|
||||
dw_offset_t addr_base = dwarf_cu->GetAddrBase();
|
||||
lldb::offset_t offset = addr_base + index * index_size;
|
||||
return dwarf_cu->GetSymbolFileDWARF()
|
||||
->GetDWARFContext()
|
||||
.GetDWARFContext()
|
||||
.getOrLoadAddrData()
|
||||
.GetMaxU64(&offset, index_size);
|
||||
}
|
||||
@@ -2750,7 +2750,7 @@ bool DWARFExpression::AddressRangeForLocationListEntry(
|
||||
return false;
|
||||
|
||||
DWARFExpression::LocationListFormat format =
|
||||
dwarf_cu->GetSymbolFileDWARF()->GetLocationListFormat();
|
||||
dwarf_cu->GetSymbolFileDWARF().GetLocationListFormat();
|
||||
switch (format) {
|
||||
case NonLocationList:
|
||||
return false;
|
||||
|
||||
@@ -155,8 +155,8 @@ TypeSP DWARFASTParserClang::ParseTypeFromDWO(const DWARFDIE &die, Log *log) {
|
||||
|
||||
// Since this this type is defined in one of the Clang modules imported by
|
||||
// this symbol file, search all of them.
|
||||
auto *sym_file = die.GetCU()->GetSymbolFileDWARF();
|
||||
for (const auto &name_module : sym_file->getExternalTypeModules()) {
|
||||
auto &sym_file = die.GetCU()->GetSymbolFileDWARF();
|
||||
for (const auto &name_module : sym_file.getExternalTypeModules()) {
|
||||
if (!name_module.second)
|
||||
continue;
|
||||
SymbolVendor *sym_vendor = name_module.second->GetSymbolVendor();
|
||||
|
||||
@@ -99,7 +99,7 @@ dw_offset_t DWARFBaseDIE::GetOffset() const {
|
||||
|
||||
SymbolFileDWARF *DWARFBaseDIE::GetDWARF() const {
|
||||
if (m_cu)
|
||||
return m_cu->GetSymbolFileDWARF();
|
||||
return &m_cu->GetSymbolFileDWARF();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -70,10 +70,10 @@ void DWARFCompileUnit::BuildAddressRangeTable(
|
||||
// We got nothing from the functions, maybe we have a line tables only
|
||||
// situation. Check the line tables and build the arange table from this.
|
||||
SymbolContext sc;
|
||||
sc.comp_unit = m_dwarf->GetCompUnitForDWARFCompUnit(*this);
|
||||
sc.comp_unit = m_dwarf.GetCompUnitForDWARFCompUnit(*this);
|
||||
if (sc.comp_unit) {
|
||||
SymbolFileDWARFDebugMap *debug_map_sym_file =
|
||||
m_dwarf->GetDebugMapSymfile();
|
||||
m_dwarf.GetDebugMapSymfile();
|
||||
if (debug_map_sym_file == nullptr) {
|
||||
if (LineTable *line_table = sc.comp_unit->GetLineTable()) {
|
||||
LineTable::FileAddressRanges file_ranges;
|
||||
@@ -88,7 +88,7 @@ void DWARFCompileUnit::BuildAddressRangeTable(
|
||||
}
|
||||
}
|
||||
} else
|
||||
debug_map_sym_file->AddOSOARanges(m_dwarf, debug_aranges);
|
||||
debug_map_sym_file->AddOSOARanges(&m_dwarf, debug_aranges);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ void DWARFCompileUnit::BuildAddressRangeTable(
|
||||
// We got nothing from the functions, maybe we have a line tables only
|
||||
// situation. Check the line tables and build the arange table from this.
|
||||
SymbolContext sc;
|
||||
sc.comp_unit = m_dwarf->GetCompUnitForDWARFCompUnit(*this);
|
||||
sc.comp_unit = m_dwarf.GetCompUnitForDWARFCompUnit(*this);
|
||||
if (sc.comp_unit) {
|
||||
if (LineTable *line_table = sc.comp_unit->GetLineTable()) {
|
||||
LineTable::FileAddressRanges file_ranges;
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
static bool classof(const DWARFUnit *unit) { return !unit->IsTypeUnit(); }
|
||||
|
||||
private:
|
||||
DWARFCompileUnit(SymbolFileDWARF *dwarf, lldb::user_id_t uid,
|
||||
DWARFCompileUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
|
||||
const DWARFUnitHeader &header,
|
||||
const DWARFAbbreviationDeclarationSet &abbrevs,
|
||||
DIERef::Section section)
|
||||
|
||||
@@ -30,21 +30,14 @@ using namespace lldb_private;
|
||||
using namespace std;
|
||||
|
||||
// Constructor
|
||||
DWARFDebugInfo::DWARFDebugInfo(lldb_private::DWARFContext &context)
|
||||
: m_dwarf2Data(nullptr), m_context(context), m_units(), m_cu_aranges_up() {}
|
||||
|
||||
// SetDwarfData
|
||||
void DWARFDebugInfo::SetDwarfData(SymbolFileDWARF *dwarf2Data) {
|
||||
m_dwarf2Data = dwarf2Data;
|
||||
m_units.clear();
|
||||
}
|
||||
DWARFDebugInfo::DWARFDebugInfo(SymbolFileDWARF &dwarf,
|
||||
lldb_private::DWARFContext &context)
|
||||
: m_dwarf(dwarf), m_context(context), m_units(), m_cu_aranges_up() {}
|
||||
|
||||
llvm::Expected<DWARFDebugAranges &> DWARFDebugInfo::GetCompileUnitAranges() {
|
||||
if (m_cu_aranges_up)
|
||||
return *m_cu_aranges_up;
|
||||
|
||||
assert(m_dwarf2Data);
|
||||
|
||||
m_cu_aranges_up = llvm::make_unique<DWARFDebugAranges>();
|
||||
const DWARFDataExtractor &debug_aranges_data =
|
||||
m_context.getOrLoadArangesData();
|
||||
@@ -81,8 +74,8 @@ void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) {
|
||||
: m_context.getOrLoadDebugInfoData();
|
||||
lldb::offset_t offset = 0;
|
||||
while (data.ValidOffset(offset)) {
|
||||
llvm::Expected<DWARFUnitSP> unit_sp = DWARFUnit::extract(
|
||||
m_dwarf2Data, m_units.size(), data, section, &offset);
|
||||
llvm::Expected<DWARFUnitSP> unit_sp =
|
||||
DWARFUnit::extract(m_dwarf, m_units.size(), data, section, &offset);
|
||||
|
||||
if (!unit_sp) {
|
||||
// FIXME: Propagate this error up.
|
||||
@@ -105,8 +98,6 @@ void DWARFDebugInfo::ParseUnitsFor(DIERef::Section section) {
|
||||
void DWARFDebugInfo::ParseUnitHeadersIfNeeded() {
|
||||
if (!m_units.empty())
|
||||
return;
|
||||
if (!m_dwarf2Data)
|
||||
return;
|
||||
|
||||
ParseUnitsFor(DIERef::Section::DebugInfo);
|
||||
ParseUnitsFor(DIERef::Section::DebugTypes);
|
||||
|
||||
@@ -37,8 +37,8 @@ public:
|
||||
const dw_offset_t next_offset,
|
||||
const uint32_t depth, void *userData);
|
||||
|
||||
explicit DWARFDebugInfo(lldb_private::DWARFContext &context);
|
||||
void SetDwarfData(SymbolFileDWARF *dwarf2Data);
|
||||
explicit DWARFDebugInfo(SymbolFileDWARF &dwarf,
|
||||
lldb_private::DWARFContext &context);
|
||||
|
||||
size_t GetNumUnits();
|
||||
DWARFUnit *GetUnitAtIndex(lldb::user_id_t idx);
|
||||
@@ -65,8 +65,7 @@ public:
|
||||
protected:
|
||||
typedef std::vector<DWARFUnitSP> UnitColl;
|
||||
|
||||
// Member variables
|
||||
SymbolFileDWARF *m_dwarf2Data;
|
||||
SymbolFileDWARF &m_dwarf;
|
||||
lldb_private::DWARFContext &m_context;
|
||||
UnitColl m_units;
|
||||
std::unique_ptr<DWARFDebugAranges>
|
||||
|
||||
@@ -52,7 +52,7 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor &data,
|
||||
lldb::offset_t offset = *offset_ptr;
|
||||
auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
|
||||
if (abbrevDecl == nullptr) {
|
||||
cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
|
||||
cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
|
||||
"{0x%8.8x}: invalid abbreviation code %u, please file a bug and "
|
||||
"attach the file at the start of this error message",
|
||||
m_offset, (unsigned)abbr_idx);
|
||||
@@ -208,7 +208,7 @@ static DWARFRangeList GetRangesOrReportError(const DWARFUnit &unit,
|
||||
: unit.FindRnglistFromOffset(value.Unsigned());
|
||||
if (expected_ranges)
|
||||
return std::move(*expected_ranges);
|
||||
unit.GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
|
||||
unit.GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
|
||||
"{0x%8.8x}: DIE has DW_AT_ranges(0x%" PRIx64 ") attribute, but "
|
||||
"range extraction failed (%s), please file a bug "
|
||||
"and attach the file at the start of this error message",
|
||||
@@ -239,8 +239,8 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
|
||||
|
||||
auto abbrevDecl = GetAbbreviationDeclarationPtr(cu);
|
||||
|
||||
SymbolFileDWARF *dwarf2Data = cu->GetSymbolFileDWARF();
|
||||
lldb::ModuleSP module = dwarf2Data->GetObjectFile()->GetModule();
|
||||
SymbolFileDWARF &dwarf = cu->GetSymbolFileDWARF();
|
||||
lldb::ModuleSP module = dwarf.GetObjectFile()->GetModule();
|
||||
|
||||
if (abbrevDecl) {
|
||||
const DWARFDataExtractor &data = cu->GetData();
|
||||
@@ -348,8 +348,7 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
|
||||
*frame_base = DWARFExpression(module, data, cu,
|
||||
block_offset, block_length);
|
||||
} else {
|
||||
const DWARFDataExtractor &debug_loc_data =
|
||||
dwarf2Data->DebugLocData();
|
||||
const DWARFDataExtractor &debug_loc_data = dwarf.DebugLocData();
|
||||
const dw_offset_t debug_loc_offset = form_value.Unsigned();
|
||||
|
||||
size_t loc_list_length = DWARFExpression::LocationListSize(
|
||||
@@ -395,7 +394,7 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
|
||||
if (ranges.IsEmpty() || name == nullptr || mangled == nullptr) {
|
||||
for (const DIERef &die_ref : die_refs) {
|
||||
if (die_ref.die_offset != DW_INVALID_OFFSET) {
|
||||
DWARFDIE die = dwarf2Data->GetDIE(die_ref);
|
||||
DWARFDIE die = dwarf.GetDIE(die_ref);
|
||||
if (die)
|
||||
die.GetDIE()->GetDIENamesAndRanges(die.GetCU(), name, mangled, ranges,
|
||||
decl_file, decl_line, decl_column,
|
||||
@@ -489,7 +488,7 @@ void DWARFDebugInfoEntry::DumpAttribute(
|
||||
|
||||
s.PutCString("( ");
|
||||
|
||||
SymbolFileDWARF *dwarf2Data = cu->GetSymbolFileDWARF();
|
||||
SymbolFileDWARF &dwarf = cu->GetSymbolFileDWARF();
|
||||
|
||||
// Check to see if we have any special attribute formatters
|
||||
switch (attr) {
|
||||
@@ -520,10 +519,8 @@ void DWARFDebugInfoEntry::DumpAttribute(
|
||||
// We have a location list offset as the value that is the offset into
|
||||
// the .debug_loc section that describes the value over it's lifetime
|
||||
uint64_t debug_loc_offset = form_value.Unsigned();
|
||||
if (dwarf2Data) {
|
||||
DWARFExpression::PrintDWARFLocationList(
|
||||
s, cu, dwarf2Data->DebugLocData(), debug_loc_offset);
|
||||
}
|
||||
DWARFExpression::PrintDWARFLocationList(s, cu, dwarf.DebugLocData(),
|
||||
debug_loc_offset);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ static uint64_t ReadAddressFromDebugAddrSection(const DWARFUnit *cu,
|
||||
dw_offset_t addr_base = cu->GetAddrBase();
|
||||
lldb::offset_t offset = addr_base + index * index_size;
|
||||
return cu->GetSymbolFileDWARF()
|
||||
->GetDWARFContext()
|
||||
.GetDWARFContext()
|
||||
.getOrLoadAddrData()
|
||||
.GetMaxU64(&offset, index_size);
|
||||
}
|
||||
|
||||
@@ -451,26 +451,20 @@ void DWARFFormValue::Dump(Stream &s) const {
|
||||
}
|
||||
|
||||
const char *DWARFFormValue::AsCString() const {
|
||||
SymbolFileDWARF *symbol_file = m_unit->GetSymbolFileDWARF();
|
||||
SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
|
||||
|
||||
if (m_form == DW_FORM_string) {
|
||||
return m_value.value.cstr;
|
||||
} else if (m_form == DW_FORM_strp) {
|
||||
if (!symbol_file)
|
||||
return nullptr;
|
||||
|
||||
return symbol_file->GetDWARFContext().getOrLoadStrData().PeekCStr(
|
||||
return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
|
||||
m_value.value.uval);
|
||||
} else if (m_form == DW_FORM_GNU_str_index) {
|
||||
if (!symbol_file)
|
||||
return nullptr;
|
||||
|
||||
uint32_t index_size = 4;
|
||||
lldb::offset_t offset = m_value.value.uval * index_size;
|
||||
dw_offset_t str_offset =
|
||||
symbol_file->GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
|
||||
symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
|
||||
&offset, index_size);
|
||||
return symbol_file->GetDWARFContext().getOrLoadStrData().PeekCStr(
|
||||
return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
|
||||
str_offset);
|
||||
}
|
||||
|
||||
@@ -479,28 +473,24 @@ const char *DWARFFormValue::AsCString() const {
|
||||
m_form == DW_FORM_strx4) {
|
||||
|
||||
// The same code as above.
|
||||
if (!symbol_file)
|
||||
return nullptr;
|
||||
|
||||
uint32_t indexSize = 4;
|
||||
lldb::offset_t offset =
|
||||
m_unit->GetStrOffsetsBase() + m_value.value.uval * indexSize;
|
||||
dw_offset_t strOffset =
|
||||
symbol_file->GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
|
||||
symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
|
||||
&offset, indexSize);
|
||||
return symbol_file->GetDWARFContext().getOrLoadStrData().PeekCStr(
|
||||
strOffset);
|
||||
return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(strOffset);
|
||||
}
|
||||
|
||||
if (m_form == DW_FORM_line_strp)
|
||||
return symbol_file->GetDWARFContext().getOrLoadLineStrData().PeekCStr(
|
||||
return symbol_file.GetDWARFContext().getOrLoadLineStrData().PeekCStr(
|
||||
m_value.value.uval);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dw_addr_t DWARFFormValue::Address() const {
|
||||
SymbolFileDWARF *symbol_file = m_unit->GetSymbolFileDWARF();
|
||||
SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
|
||||
|
||||
if (m_form == DW_FORM_addr)
|
||||
return Unsigned();
|
||||
@@ -510,13 +500,10 @@ dw_addr_t DWARFFormValue::Address() const {
|
||||
m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 ||
|
||||
m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4);
|
||||
|
||||
if (!symbol_file)
|
||||
return 0;
|
||||
|
||||
uint32_t index_size = m_unit->GetAddressByteSize();
|
||||
dw_offset_t addr_base = m_unit->GetAddrBase();
|
||||
lldb::offset_t offset = addr_base + m_value.value.uval * index_size;
|
||||
return symbol_file->GetDWARFContext().getOrLoadAddrData().GetMaxU64(
|
||||
return symbol_file.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
|
||||
&offset, index_size);
|
||||
}
|
||||
|
||||
@@ -532,7 +519,7 @@ DWARFDIE DWARFFormValue::Reference() const {
|
||||
// unit relative or we will get this wrong
|
||||
value += m_unit->GetOffset();
|
||||
if (!m_unit->ContainsDIEOffset(value)) {
|
||||
m_unit->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
|
||||
m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
|
||||
"DW_FORM_ref* DIE reference 0x%" PRIx64 " is outside of its CU",
|
||||
value);
|
||||
return {};
|
||||
@@ -541,10 +528,10 @@ DWARFDIE DWARFFormValue::Reference() const {
|
||||
|
||||
case DW_FORM_ref_addr: {
|
||||
DWARFUnit *ref_cu =
|
||||
m_unit->GetSymbolFileDWARF()->DebugInfo()->GetUnitContainingDIEOffset(
|
||||
m_unit->GetSymbolFileDWARF().DebugInfo()->GetUnitContainingDIEOffset(
|
||||
DIERef::Section::DebugInfo, value);
|
||||
if (!ref_cu) {
|
||||
m_unit->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
|
||||
m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
|
||||
"DW_FORM_ref_addr DIE reference 0x%" PRIx64 " has no matching CU",
|
||||
value);
|
||||
return {};
|
||||
@@ -554,7 +541,7 @@ DWARFDIE DWARFFormValue::Reference() const {
|
||||
|
||||
case DW_FORM_ref_sig8: {
|
||||
DWARFTypeUnit *tu =
|
||||
m_unit->GetSymbolFileDWARF()->DebugInfo()->GetTypeUnitForHash(value);
|
||||
m_unit->GetSymbolFileDWARF().DebugInfo()->GetTypeUnitForHash(value);
|
||||
if (!tu)
|
||||
return {};
|
||||
return tu->GetDIE(tu->GetTypeOffset());
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
static bool classof(const DWARFUnit *unit) { return unit->IsTypeUnit(); }
|
||||
|
||||
private:
|
||||
DWARFTypeUnit(SymbolFileDWARF *dwarf, lldb::user_id_t uid,
|
||||
DWARFTypeUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
|
||||
const DWARFUnitHeader &header,
|
||||
const DWARFAbbreviationDeclarationSet &abbrevs,
|
||||
DIERef::Section section)
|
||||
|
||||
@@ -29,7 +29,7 @@ using namespace std;
|
||||
|
||||
extern int g_verbose;
|
||||
|
||||
DWARFUnit::DWARFUnit(SymbolFileDWARF *dwarf, lldb::user_id_t uid,
|
||||
DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
|
||||
const DWARFUnitHeader &header,
|
||||
const DWARFAbbreviationDeclarationSet &abbrevs,
|
||||
DIERef::Section section)
|
||||
@@ -90,7 +90,7 @@ void DWARFUnit::ExtractDIEsIfNeeded() {
|
||||
// and no ExtractDIEsIfNeeded() has been executed during this ScopedExtractDIEs
|
||||
// lifetime.
|
||||
DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
|
||||
ScopedExtractDIEs scoped(this);
|
||||
ScopedExtractDIEs scoped(*this);
|
||||
|
||||
{
|
||||
llvm::sys::ScopedReader lock(m_die_array_mutex);
|
||||
@@ -109,8 +109,7 @@ DWARFUnit::ScopedExtractDIEs DWARFUnit::ExtractDIEsScoped() {
|
||||
return scoped;
|
||||
}
|
||||
|
||||
DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit *cu) : m_cu(cu) {
|
||||
lldbassert(m_cu);
|
||||
DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(DWARFUnit &cu) : m_cu(&cu) {
|
||||
m_cu->m_die_array_scoped_mutex.lock_shared();
|
||||
}
|
||||
|
||||
@@ -266,7 +265,7 @@ static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) {
|
||||
lldb::offset_t baseOffset = 0;
|
||||
|
||||
const DWARFDataExtractor &strOffsets =
|
||||
dwo_cu->GetSymbolFileDWARF()->GetDWARFContext().getOrLoadStrOffsetsData();
|
||||
dwo_cu->GetSymbolFileDWARF().GetDWARFContext().getOrLoadStrOffsetsData();
|
||||
uint64_t length = strOffsets.GetU32(&baseOffset);
|
||||
if (length == 0xffffffff)
|
||||
length = strOffsets.GetU64(&baseOffset);
|
||||
@@ -326,7 +325,7 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry &cu_die) {
|
||||
}
|
||||
|
||||
std::unique_ptr<SymbolFileDWARFDwo> dwo_symbol_file =
|
||||
m_dwarf->GetDwoSymbolFileForCompileUnit(*this, cu_die);
|
||||
m_dwarf.GetDwoSymbolFileForCompileUnit(*this, cu_die);
|
||||
if (!dwo_symbol_file)
|
||||
return;
|
||||
|
||||
@@ -438,14 +437,11 @@ void DWARFUnit::ClearDIEsRWLocked() {
|
||||
}
|
||||
|
||||
lldb::ByteOrder DWARFUnit::GetByteOrder() const {
|
||||
return m_dwarf->GetObjectFile()->GetByteOrder();
|
||||
return m_dwarf.GetObjectFile()->GetByteOrder();
|
||||
}
|
||||
|
||||
TypeSystem *DWARFUnit::GetTypeSystem() {
|
||||
if (m_dwarf)
|
||||
return m_dwarf->GetTypeSystemForLanguage(GetLanguageType());
|
||||
else
|
||||
return nullptr;
|
||||
return m_dwarf.GetTypeSystemForLanguage(GetLanguageType());
|
||||
}
|
||||
|
||||
void DWARFUnit::SetBaseAddress(dw_addr_t base_addr) { m_base_addr = base_addr; }
|
||||
@@ -477,7 +473,7 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
|
||||
return DWARFDIE(this, &(*pos));
|
||||
}
|
||||
} else
|
||||
GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError(
|
||||
GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
|
||||
"GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
|
||||
die_offset, GetOffset());
|
||||
}
|
||||
@@ -520,8 +516,6 @@ bool DWARFUnit::Supports_unnamed_objc_bitfields() {
|
||||
// info
|
||||
}
|
||||
|
||||
SymbolFileDWARF *DWARFUnit::GetSymbolFileDWARF() const { return m_dwarf; }
|
||||
|
||||
void DWARFUnit::ParseProducerInfo() {
|
||||
m_producer_version_major = UINT32_MAX;
|
||||
m_producer_version_minor = UINT32_MAX;
|
||||
@@ -645,7 +639,7 @@ const FileSpec &DWARFUnit::GetAbsolutePath() {
|
||||
}
|
||||
|
||||
FileSpec DWARFUnit::GetFile(size_t file_idx) {
|
||||
return m_dwarf->GetFile(*this, file_idx);
|
||||
return m_dwarf.GetFile(*this, file_idx);
|
||||
}
|
||||
|
||||
// DWARF2/3 suggests the form hostname:pathname for compilation directory.
|
||||
@@ -796,9 +790,9 @@ DWARFUnitHeader::extract(const DWARFDataExtractor &data, DIERef::Section section
|
||||
}
|
||||
|
||||
llvm::Expected<DWARFUnitSP>
|
||||
DWARFUnit::extract(SymbolFileDWARF *dwarf, user_id_t uid,
|
||||
const DWARFDataExtractor &debug_info, DIERef::Section section,
|
||||
lldb::offset_t *offset_ptr) {
|
||||
DWARFUnit::extract(SymbolFileDWARF &dwarf, user_id_t uid,
|
||||
const DWARFDataExtractor &debug_info,
|
||||
DIERef::Section section, lldb::offset_t *offset_ptr) {
|
||||
assert(debug_info.ValidOffset(*offset_ptr));
|
||||
|
||||
auto expected_header =
|
||||
@@ -806,13 +800,13 @@ DWARFUnit::extract(SymbolFileDWARF *dwarf, user_id_t uid,
|
||||
if (!expected_header)
|
||||
return expected_header.takeError();
|
||||
|
||||
const DWARFDebugAbbrev *abbr = dwarf->DebugAbbrev();
|
||||
const DWARFDebugAbbrev *abbr = dwarf.DebugAbbrev();
|
||||
if (!abbr)
|
||||
return llvm::make_error<llvm::object::GenericBinaryError>(
|
||||
"No debug_abbrev data");
|
||||
|
||||
bool abbr_offset_OK =
|
||||
dwarf->GetDWARFContext().getOrLoadAbbrevData().ValidOffset(
|
||||
dwarf.GetDWARFContext().getOrLoadAbbrevData().ValidOffset(
|
||||
expected_header->GetAbbrOffset());
|
||||
if (!abbr_offset_OK)
|
||||
return llvm::make_error<llvm::object::GenericBinaryError>(
|
||||
@@ -833,8 +827,8 @@ DWARFUnit::extract(SymbolFileDWARF *dwarf, user_id_t uid,
|
||||
|
||||
const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const {
|
||||
return m_section == DIERef::Section::DebugTypes
|
||||
? m_dwarf->GetDWARFContext().getOrLoadDebugTypesData()
|
||||
: m_dwarf->GetDWARFContext().getOrLoadDebugInfoData();
|
||||
? m_dwarf.GetDWARFContext().getOrLoadDebugTypesData()
|
||||
: m_dwarf.GetDWARFContext().getOrLoadDebugInfoData();
|
||||
}
|
||||
|
||||
uint32_t DWARFUnit::GetHeaderByteSize() const {
|
||||
@@ -857,10 +851,10 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) const {
|
||||
const DWARFDebugRangesBase *debug_ranges;
|
||||
llvm::StringRef section;
|
||||
if (GetVersion() <= 4) {
|
||||
debug_ranges = m_dwarf->GetDebugRanges();
|
||||
debug_ranges = m_dwarf.GetDebugRanges();
|
||||
section = "debug_ranges";
|
||||
} else {
|
||||
debug_ranges = m_dwarf->GetDebugRngLists();
|
||||
debug_ranges = m_dwarf.GetDebugRngLists();
|
||||
section = "debug_rnglists";
|
||||
}
|
||||
if (!debug_ranges)
|
||||
@@ -874,7 +868,7 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) const {
|
||||
|
||||
llvm::Expected<DWARFRangeList>
|
||||
DWARFUnit::FindRnglistFromIndex(uint32_t index) const {
|
||||
const DWARFDebugRangesBase *debug_rnglists = m_dwarf->GetDebugRngLists();
|
||||
const DWARFDebugRangesBase *debug_rnglists = m_dwarf.GetDebugRngLists();
|
||||
if (!debug_rnglists)
|
||||
return llvm::make_error<llvm::object::GenericBinaryError>(
|
||||
"No debug_rnglists section");
|
||||
|
||||
@@ -74,7 +74,7 @@ class DWARFUnit : public lldb_private::UserID {
|
||||
|
||||
public:
|
||||
static llvm::Expected<DWARFUnitSP>
|
||||
extract(SymbolFileDWARF *dwarf2Data, lldb::user_id_t uid,
|
||||
extract(SymbolFileDWARF &dwarf2Data, lldb::user_id_t uid,
|
||||
const lldb_private::DWARFDataExtractor &debug_info,
|
||||
DIERef::Section section, lldb::offset_t *offset_ptr);
|
||||
virtual ~DWARFUnit();
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
DWARFUnit *m_cu;
|
||||
public:
|
||||
bool m_clear_dies = false;
|
||||
ScopedExtractDIEs(DWARFUnit *cu);
|
||||
ScopedExtractDIEs(DWARFUnit &cu);
|
||||
~ScopedExtractDIEs();
|
||||
DISALLOW_COPY_AND_ASSIGN(ScopedExtractDIEs);
|
||||
ScopedExtractDIEs(ScopedExtractDIEs &&rhs);
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
|
||||
bool Supports_unnamed_objc_bitfields();
|
||||
|
||||
SymbolFileDWARF *GetSymbolFileDWARF() const;
|
||||
SymbolFileDWARF &GetSymbolFileDWARF() const { return m_dwarf; }
|
||||
|
||||
DWARFProducer GetProducer();
|
||||
|
||||
@@ -225,12 +225,12 @@ public:
|
||||
llvm::Expected<DWARFRangeList> FindRnglistFromIndex(uint32_t index) const;
|
||||
|
||||
protected:
|
||||
DWARFUnit(SymbolFileDWARF *dwarf, lldb::user_id_t uid,
|
||||
DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
|
||||
const DWARFUnitHeader &header,
|
||||
const DWARFAbbreviationDeclarationSet &abbrevs,
|
||||
DIERef::Section section);
|
||||
|
||||
llvm::Error ExtractHeader(SymbolFileDWARF *dwarf,
|
||||
llvm::Error ExtractHeader(SymbolFileDWARF &dwarf,
|
||||
const lldb_private::DWARFDataExtractor &data,
|
||||
lldb::offset_t *offset_ptr);
|
||||
|
||||
@@ -252,7 +252,7 @@ protected:
|
||||
return &m_die_array[0];
|
||||
}
|
||||
|
||||
SymbolFileDWARF *m_dwarf = nullptr;
|
||||
SymbolFileDWARF &m_dwarf;
|
||||
std::unique_ptr<SymbolFileDWARFDwo> m_dwo_symbol_file;
|
||||
DWARFUnitHeader m_header;
|
||||
const DWARFAbbreviationDeclarationSet *m_abbrevs = nullptr;
|
||||
|
||||
@@ -88,7 +88,8 @@ void ManualDWARFIndex::Index() {
|
||||
}
|
||||
|
||||
void ManualDWARFIndex::IndexUnit(DWARFUnit &unit, IndexSet &set) {
|
||||
assert(!unit.GetSymbolFileDWARF()->GetBaseCompileUnit() &&
|
||||
assert(
|
||||
!unit.GetSymbolFileDWARF().GetBaseCompileUnit() &&
|
||||
"DWARFUnit associated with .dwo or .dwp should not be indexed directly");
|
||||
|
||||
Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS);
|
||||
|
||||
@@ -589,10 +589,8 @@ DWARFDebugInfo *SymbolFileDWARF::DebugInfo() {
|
||||
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
|
||||
Timer scoped_timer(func_cat, "%s this = %p", LLVM_PRETTY_FUNCTION,
|
||||
static_cast<void *>(this));
|
||||
if (m_context.getOrLoadDebugInfoData().GetByteSize() > 0) {
|
||||
m_info = llvm::make_unique<DWARFDebugInfo>(m_context);
|
||||
m_info->SetDwarfData(this);
|
||||
}
|
||||
if (m_context.getOrLoadDebugInfoData().GetByteSize() > 0)
|
||||
m_info = llvm::make_unique<DWARFDebugInfo>(*this, m_context);
|
||||
}
|
||||
return m_info.get();
|
||||
}
|
||||
@@ -654,8 +652,8 @@ lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
|
||||
// We already parsed this compile unit, had out a shared pointer to it
|
||||
cu_sp = comp_unit->shared_from_this();
|
||||
} else {
|
||||
if (dwarf_cu.GetSymbolFileDWARF() != this) {
|
||||
return dwarf_cu.GetSymbolFileDWARF()->ParseCompileUnit(dwarf_cu);
|
||||
if (&dwarf_cu.GetSymbolFileDWARF() != this) {
|
||||
return dwarf_cu.GetSymbolFileDWARF().ParseCompileUnit(dwarf_cu);
|
||||
} else if (dwarf_cu.GetOffset() == 0 && GetDebugMapSymfile()) {
|
||||
// Let the debug map create the compile unit
|
||||
cu_sp = m_debug_map_symfile->GetCompileUnit(this);
|
||||
|
||||
@@ -51,7 +51,7 @@ SymbolFileDWARFDwo::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
|
||||
assert(GetCompileUnit() == &dwarf_cu &&
|
||||
"SymbolFileDWARFDwo::ParseCompileUnit called with incompatible "
|
||||
"compile unit");
|
||||
return GetBaseSymbolFile()->ParseCompileUnit(m_base_dwarf_cu);
|
||||
return GetBaseSymbolFile().ParseCompileUnit(m_base_dwarf_cu);
|
||||
}
|
||||
|
||||
DWARFUnit *SymbolFileDWARFDwo::GetCompileUnit() {
|
||||
@@ -68,47 +68,47 @@ SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
|
||||
}
|
||||
|
||||
SymbolFileDWARF::DIEToTypePtr &SymbolFileDWARFDwo::GetDIEToType() {
|
||||
return GetBaseSymbolFile()->GetDIEToType();
|
||||
return GetBaseSymbolFile().GetDIEToType();
|
||||
}
|
||||
|
||||
SymbolFileDWARF::DIEToVariableSP &SymbolFileDWARFDwo::GetDIEToVariable() {
|
||||
return GetBaseSymbolFile()->GetDIEToVariable();
|
||||
return GetBaseSymbolFile().GetDIEToVariable();
|
||||
}
|
||||
|
||||
SymbolFileDWARF::DIEToClangType &
|
||||
SymbolFileDWARFDwo::GetForwardDeclDieToClangType() {
|
||||
return GetBaseSymbolFile()->GetForwardDeclDieToClangType();
|
||||
return GetBaseSymbolFile().GetForwardDeclDieToClangType();
|
||||
}
|
||||
|
||||
SymbolFileDWARF::ClangTypeToDIE &
|
||||
SymbolFileDWARFDwo::GetForwardDeclClangTypeToDie() {
|
||||
return GetBaseSymbolFile()->GetForwardDeclClangTypeToDie();
|
||||
return GetBaseSymbolFile().GetForwardDeclClangTypeToDie();
|
||||
}
|
||||
|
||||
size_t SymbolFileDWARFDwo::GetObjCMethodDIEOffsets(
|
||||
lldb_private::ConstString class_name, DIEArray &method_die_offsets) {
|
||||
return GetBaseSymbolFile()->GetObjCMethodDIEOffsets(
|
||||
class_name, method_die_offsets);
|
||||
return GetBaseSymbolFile().GetObjCMethodDIEOffsets(class_name,
|
||||
method_die_offsets);
|
||||
}
|
||||
|
||||
UniqueDWARFASTTypeMap &SymbolFileDWARFDwo::GetUniqueDWARFASTTypeMap() {
|
||||
return GetBaseSymbolFile()->GetUniqueDWARFASTTypeMap();
|
||||
return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
|
||||
}
|
||||
|
||||
lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
|
||||
const DWARFDeclContext &die_decl_ctx) {
|
||||
return GetBaseSymbolFile()->FindDefinitionTypeForDWARFDeclContext(
|
||||
return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
|
||||
die_decl_ctx);
|
||||
}
|
||||
|
||||
lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
|
||||
const DWARFDIE &die, lldb_private::ConstString type_name,
|
||||
bool must_be_implementation) {
|
||||
return GetBaseSymbolFile()->FindCompleteObjCDefinitionTypeForDIE(
|
||||
return GetBaseSymbolFile().FindCompleteObjCDefinitionTypeForDIE(
|
||||
die, type_name, must_be_implementation);
|
||||
}
|
||||
|
||||
SymbolFileDWARF *SymbolFileDWARFDwo::GetBaseSymbolFile() {
|
||||
SymbolFileDWARF &SymbolFileDWARFDwo::GetBaseSymbolFile() {
|
||||
return m_base_dwarf_cu.GetSymbolFileDWARF();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ SymbolFileDWARFDwo::GetLocationListFormat() const {
|
||||
|
||||
TypeSystem *
|
||||
SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType language) {
|
||||
return GetBaseSymbolFile()->GetTypeSystemForLanguage(language);
|
||||
return GetBaseSymbolFile().GetTypeSystemForLanguage(language);
|
||||
}
|
||||
|
||||
DWARFDIE
|
||||
|
||||
@@ -65,7 +65,7 @@ protected:
|
||||
const DWARFDIE &die, lldb_private::ConstString type_name,
|
||||
bool must_be_implementation) override;
|
||||
|
||||
SymbolFileDWARF *GetBaseSymbolFile();
|
||||
SymbolFileDWARF &GetBaseSymbolFile();
|
||||
|
||||
lldb::ObjectFileSP m_obj_file_sp;
|
||||
DWARFCompileUnit &m_base_dwarf_cu;
|
||||
|
||||
Reference in New Issue
Block a user