summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF
diff options
context:
space:
mode:
authorSourabh Singh Tomar <SourabhSingh.Tomar@amd.com>2019-11-23 20:04:36 +0530
committerSourabh Singh Tomar <SourabhSingh.Tomar@amd.com>2019-11-23 20:10:23 +0530
commit0e02977b6e64810bdf9265260a39d80fda031aa3 (patch)
tree3f3b19d8c9642273878367748a2ce7969d8fe5cd /llvm/lib/DebugInfo/DWARF
parent02cb4b2fd699564c68d30c1dd22cb74d671fe14b (diff)
downloadbcm5719-llvm-0e02977b6e64810bdf9265260a39d80fda031aa3.tar.gz
bcm5719-llvm-0e02977b6e64810bdf9265260a39d80fda031aa3.zip
Recommit "[DWARF] Support for loclist.dwo section in llvm and llvm-dwarfdump."
The original commit message follows. This patch adds support for debug_loclists.dwo section in llvm and llvm-dwarfdump. Also Fixes PR43622, PR43623. Reviewers: dblaikie, probinson, labath, aprantl, jini.susan.george Differential Revision: https://reviews.llvm.org/D69462
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp13
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDie.cpp1
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp32
3 files changed, 38 insertions, 8 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index f7b3fb495f9..012bab35460 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -404,6 +404,14 @@ void DWARFContext::dump(
dumpLoclistsSection(OS, LLDumpOpts, Data, getRegisterInfo(), *Off);
}
if (const auto *Off =
+ shouldDump(ExplicitDWO, ".debug_loclists.dwo", DIDT_ID_DebugLoclists,
+ DObj->getLoclistsDWOSection().Data)) {
+ DWARFDataExtractor Data(*DObj, DObj->getLoclistsDWOSection(),
+ isLittleEndian(), 0);
+ dumpLoclistsSection(OS, LLDumpOpts, Data, getRegisterInfo(), *Off);
+ }
+
+ if (const auto *Off =
shouldDump(ExplicitDWO, ".debug_loc.dwo", DIDT_ID_DebugLoc,
DObj->getLocDWOSection().Data)) {
DWARFDataExtractor Data(*DObj, DObj->getLocDWOSection(), isLittleEndian(),
@@ -1385,6 +1393,7 @@ class DWARFObjInMemory final : public DWARFObject {
DWARFSectionMap LocSection;
DWARFSectionMap LoclistsSection;
+ DWARFSectionMap LoclistsDWOSection;
DWARFSectionMap LineSection;
DWARFSectionMap RangesSection;
DWARFSectionMap RnglistsSection;
@@ -1411,6 +1420,7 @@ class DWARFObjInMemory final : public DWARFObject {
return StringSwitch<DWARFSectionMap *>(Name)
.Case("debug_loc", &LocSection)
.Case("debug_loclists", &LoclistsSection)
+ .Case("debug_loclists.dwo", &LoclistsDWOSection)
.Case("debug_line", &LineSection)
.Case("debug_frame", &FrameSection)
.Case("eh_frame", &EHFrameSection)
@@ -1741,6 +1751,9 @@ public:
const DWARFSection &getRnglistsDWOSection() const override {
return RnglistsDWOSection;
}
+ const DWARFSection &getLoclistsDWOSection() const override {
+ return LoclistsDWOSection;
+ }
const DWARFSection &getAddrSection() const override { return AddrSection; }
StringRef getCUIndexSection() const override { return CUIndexSection; }
StringRef getGdbIndexSection() const override { return GdbIndexSection; }
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
index 6cf30270539..cc3d021b0dd 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
@@ -89,6 +89,7 @@ static void dumpLocation(raw_ostream &OS, DWARFFormValue &FormValue,
if (FormValue.getForm() == DW_FORM_loclistx) {
FormValue.dump(OS, DumpOpts);
+
if (auto LoclistOffset = U->getLoclistOffset(Offset))
Offset = *LoclistOffset + U->getLocSectionBase();
else
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index e5d33e13644..b662e88816f 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -186,9 +186,16 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
if (auto *IndexEntry = Header.getIndexEntry())
if (const auto *C = IndexEntry->getOffset(DW_SECT_LOC))
Data = Data.substr(C->Offset, C->Length);
- LocTable = std::make_unique<DWARFDebugLoclists>(
- DWARFDataExtractor(Data, isLittleEndian, getAddressByteSize()),
- Header.getVersion());
+
+ DWARFDataExtractor DWARFData =
+ Header.getVersion() >= 5
+ ? DWARFDataExtractor(Context.getDWARFObj(),
+ Context.getDWARFObj().getLoclistsDWOSection(),
+ isLittleEndian, getAddressByteSize())
+ : DWARFDataExtractor(Data, isLittleEndian, getAddressByteSize());
+ LocTable =
+ std::make_unique<DWARFDebugLoclists>(DWARFData, Header.getVersion());
+
} else if (Header.getVersion() >= 5) {
LocTable = std::make_unique<DWARFDebugLoclists>(
DWARFDataExtractor(Context.getDWARFObj(),
@@ -502,14 +509,23 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
RangeSectionBase = RngListTable->getHeaderSize();
}
- // FIXME: add loclists.dwo support
- setLocSection(&Context.getDWARFObj().getLoclistsSection(),
- toSectionOffset(UnitDie.find(DW_AT_loclists_base), 0));
+ // In a split dwarf unit, there is no DW_AT_loclists_base attribute.
+ // Setting LocSectionBase to point past the table header.
+ if (IsDWO)
+ setLocSection(&Context.getDWARFObj().getLoclistsDWOSection(),
+ DWARFListTableHeader::getHeaderSize(Header.getFormat()));
+ else
+ setLocSection(&Context.getDWARFObj().getLoclistsSection(),
+ toSectionOffset(UnitDie.find(DW_AT_loclists_base), 0));
if (LocSection->Data.size()) {
- LoclistTableHeader.emplace(".debug_loclists", "locations");
- uint64_t Offset = LocSectionBase;
+ if (IsDWO)
+ LoclistTableHeader.emplace(".debug_loclists.dwo", "locations");
+ else
+ LoclistTableHeader.emplace(".debug_loclists", "locations");
+
uint64_t HeaderSize = DWARFListTableHeader::getHeaderSize(Header.getFormat());
+ uint64_t Offset = getLocSectionBase();
DWARFDataExtractor Data(Context.getDWARFObj(), *LocSection,
isLittleEndian, getAddressByteSize());
if (Offset < HeaderSize)
OpenPOWER on IntegriCloud