diff options
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDie.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp | 48 | ||||
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp | 14 |
3 files changed, 42 insertions, 30 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp index cf10c1134a7..6b69b822aad 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp @@ -101,12 +101,10 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue, FormValue.dump(OS, DumpOpts); if (FormValue.isFormClass(DWARFFormValue::FC_SectionOffset)) { - const DWARFSection &LocSection = Obj.getLocSection(); - const DWARFSection &LocDWOSection = Obj.getLocDWOSection(); uint32_t Offset = *FormValue.getAsSectionOffset(); - if (!LocSection.Data.empty()) { + if (!U->isDWOUnit()) { DWARFDebugLoc DebugLoc; - DWARFDataExtractor Data(Obj, LocSection, Ctx.isLittleEndian(), + DWARFDataExtractor Data(Obj, *U->getLocSection(), Ctx.isLittleEndian(), Obj.getAddressSize()); auto LL = DebugLoc.parseOneLocationList(Data, &Offset); if (LL) { @@ -117,8 +115,8 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue, Indent); } else OS << "error extracting location list."; - } else if (!LocDWOSection.Data.empty()) { - DataExtractor Data(LocDWOSection.Data, Ctx.isLittleEndian(), 0); + } else { + DataExtractor Data(U->getLocSectionData(), Ctx.isLittleEndian(), 0); auto LL = DWARFDebugLocDWO::parseOneLocationList(Data, &Offset); if (LL) LL->dump(OS, Ctx.isLittleEndian(), Obj.getAddressSize(), MRI, Indent); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 6c3c62d86ef..dbac5a82b57 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -39,9 +39,10 @@ void DWARFUnitVector::addUnitsForSection(DWARFContext &C, DWARFSectionKind SectionKind) { const DWARFObject &D = C.getDWARFObj(); addUnitsImpl(C, D, Section, C.getDebugAbbrev(), &D.getRangeSection(), - D.getStringSection(), D.getStringOffsetSection(), - &D.getAddrSection(), D.getLineSection(), D.isLittleEndian(), - false, false, SectionKind); + &D.getLocSection(), D.getStringSection(), + D.getStringOffsetSection(), &D.getAddrSection(), + D.getLineSection(), D.isLittleEndian(), false, false, + SectionKind); } void DWARFUnitVector::addUnitsForDWOSection(DWARFContext &C, @@ -50,16 +51,18 @@ void DWARFUnitVector::addUnitsForDWOSection(DWARFContext &C, bool Lazy) { const DWARFObject &D = C.getDWARFObj(); addUnitsImpl(C, D, DWOSection, C.getDebugAbbrevDWO(), &D.getRangeDWOSection(), - D.getStringDWOSection(), D.getStringOffsetDWOSection(), - &D.getAddrSection(), D.getLineDWOSection(), C.isLittleEndian(), - true, Lazy, SectionKind); + &D.getLocDWOSection(), D.getStringDWOSection(), + D.getStringOffsetDWOSection(), &D.getAddrSection(), + D.getLineDWOSection(), C.isLittleEndian(), true, Lazy, + SectionKind); } void DWARFUnitVector::addUnitsImpl( DWARFContext &Context, const DWARFObject &Obj, const DWARFSection &Section, - const DWARFDebugAbbrev *DA, const DWARFSection *RS, StringRef SS, - const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, - bool LE, bool IsDWO, bool Lazy, DWARFSectionKind SectionKind) { + const DWARFDebugAbbrev *DA, const DWARFSection *RS, + const DWARFSection *LocSection, StringRef SS, const DWARFSection &SOS, + const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, + bool Lazy, DWARFSectionKind SectionKind) { DWARFDataExtractor Data(Obj, Section, LE, 0); // Lazy initialization of Parser, now that we have all section info. if (!Parser) { @@ -79,12 +82,12 @@ void DWARFUnitVector::addUnitsImpl( std::unique_ptr<DWARFUnit> U; if (Header.isTypeUnit()) U = llvm::make_unique<DWARFTypeUnit>(Context, InfoSection, Header, DA, - RS, SS, SOS, AOS, LS, LE, IsDWO, - *this); + RS, LocSection, SS, SOS, AOS, LS, + LE, IsDWO, *this); else U = llvm::make_unique<DWARFCompileUnit>(Context, InfoSection, Header, - DA, RS, SS, SOS, AOS, LS, LE, - IsDWO, *this); + DA, RS, LocSection, SS, SOS, + AOS, LS, LE, IsDWO, *this); return U; }; } @@ -164,16 +167,25 @@ DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) { } DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section, - const DWARFUnitHeader &Header, - const DWARFDebugAbbrev *DA, const DWARFSection *RS, + const DWARFUnitHeader &Header, const DWARFDebugAbbrev *DA, + const DWARFSection *RS, const DWARFSection *LocSection, StringRef SS, const DWARFSection &SOS, const DWARFSection *AOS, const DWARFSection &LS, bool LE, bool IsDWO, const DWARFUnitVector &UnitVector) : Context(DC), InfoSection(Section), Header(Header), Abbrev(DA), - RangeSection(RS), LineSection(LS), StringSection(SS), - StringOffsetSection(SOS), AddrOffsetSection(AOS), isLittleEndian(LE), - isDWO(IsDWO), UnitVector(UnitVector) { + RangeSection(RS), LocSection(LocSection), LineSection(LS), + StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS), + isLittleEndian(LE), isDWO(IsDWO), UnitVector(UnitVector) { clear(); + // For split DWARF we only need to keep track of the location list section's + // data (no relocations), and if we are reading a package file, we need to + // adjust the location list data based on the index entries. + if (IsDWO) { + LocSectionData = LocSection->Data; + if (auto *IndexEntry = Header.getIndexEntry()) + if (const auto *C = IndexEntry->getOffset(DW_SECT_LOC)) + LocSectionData = LocSectionData.substr(C->Offset, C->Length); + } } DWARFUnit::~DWARFUnit() = default; diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp index e78e13bf4af..d30600accd0 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -325,9 +325,10 @@ unsigned DWARFVerifier::verifyUnitSection(const DWARFSection &S, case dwarf::DW_UT_split_type: { Unit = TypeUnitVector.addUnit(llvm::make_unique<DWARFTypeUnit>( DCtx, S, Header, DCtx.getDebugAbbrev(), &DObj.getRangeSection(), - DObj.getStringSection(), DObj.getStringOffsetSection(), - &DObj.getAppleObjCSection(), DObj.getLineSection(), - DCtx.isLittleEndian(), false, TypeUnitVector)); + &DObj.getLocSection(), DObj.getStringSection(), + DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(), + DObj.getLineSection(), DCtx.isLittleEndian(), false, + TypeUnitVector)); break; } case dwarf::DW_UT_skeleton: @@ -338,9 +339,10 @@ unsigned DWARFVerifier::verifyUnitSection(const DWARFSection &S, case 0: { Unit = CompileUnitVector.addUnit(llvm::make_unique<DWARFCompileUnit>( DCtx, S, Header, DCtx.getDebugAbbrev(), &DObj.getRangeSection(), - DObj.getStringSection(), DObj.getStringOffsetSection(), - &DObj.getAppleObjCSection(), DObj.getLineSection(), - DCtx.isLittleEndian(), false, CompileUnitVector)); + &DObj.getLocSection(), DObj.getStringSection(), + DObj.getStringOffsetSection(), &DObj.getAppleObjCSection(), + DObj.getLineSection(), DCtx.isLittleEndian(), false, + CompileUnitVector)); break; } default: { llvm_unreachable("Invalid UnitType."); } |