summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
diff options
context:
space:
mode:
authorWolfgang Pieb <Wolfgang.Pieb@sony.com>2018-10-19 19:23:16 +0000
committerWolfgang Pieb <Wolfgang.Pieb@sony.com>2018-10-19 19:23:16 +0000
commit6214c11cb7ddb7813ecc2c37923ed95d35c53cef (patch)
tree88a6a9d12f53eeabb8d288191cf55fb8e3d18fdb /llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
parent8365cc3a1f4b5edfccda28edc364b35c539faa50 (diff)
downloadbcm5719-llvm-6214c11cb7ddb7813ecc2c37923ed95d35c53cef.tar.gz
bcm5719-llvm-6214c11cb7ddb7813ecc2c37923ed95d35c53cef.zip
[DWARF] Make llvm-dwarfdump display location lists in a .dwp file correctly. Fixes PR38990.
Considers the index when extracting location lists from a .dwp file. Majority of the patch by David Blaikie. Reviewers: dblaikie Differential revision: https://reviews.llvm.org/D53155 llvm-svn: 344807
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp48
1 files changed, 30 insertions, 18 deletions
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;
OpenPOWER on IntegriCloud