diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h index bae3154b3b5f..bba3abe6e9e9 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h @@ -19,10 +19,10 @@ public: DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, StringRef LS, bool LE, - const DWARFUnitSectionBase &UnitSection, + bool IsDWO, const DWARFUnitSectionBase &UnitSection, const DWARFUnitIndex::Entry *Entry) - : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection, - Entry) {} + : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, IsDWO, + UnitSection, Entry) {} void dump(raw_ostream &OS); static const DWARFSectionKind Section = DW_SECT_INFO; // VTable anchor. diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h index 894a88dce440..a697edd32072 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h @@ -21,11 +21,11 @@ private: public: DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, StringRef LS, bool LE, + StringRef SOS, StringRef AOS, StringRef LS, bool LE, bool IsDWO, const DWARFUnitSectionBase &UnitSection, const DWARFUnitIndex::Entry *Entry) - : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection, - Entry) {} + : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, IsDWO, + UnitSection, Entry) {} uint32_t getHeaderSize() const override { return DWARFUnit::getHeaderSize() + 12; } diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h index 30e0c106fd6c..da513bf7443d 100644 --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h @@ -47,7 +47,7 @@ protected: virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, StringRef LS, - bool isLittleEndian) = 0; + bool isLittleEndian, bool isDWO) = 0; ~DWARFUnitSectionBase() = default; }; @@ -80,7 +80,8 @@ public: private: void parseImpl(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, StringRef LS, bool LE) override { + StringRef SOS, StringRef AOS, StringRef LS, bool LE, + bool IsDWO) override { if (Parsed) return; const auto &Index = getDWARFUnitIndex(Context, UnitType::Section); @@ -88,7 +89,7 @@ private: uint32_t Offset = 0; while (Data.isValidOffset(Offset)) { auto U = llvm::make_unique(Context, Section, DA, RS, SS, SOS, - AOS, LS, LE, *this, + AOS, LS, LE, IsDWO, *this, Index.getFromOffset(Offset)); if (!U->extract(Data, &Offset)) break; @@ -113,6 +114,7 @@ class DWARFUnit { StringRef AddrOffsetSection; uint32_t AddrOffsetSectionBase; bool isLittleEndian; + bool isDWO; const DWARFUnitSectionBase &UnitSection; uint32_t Offset; @@ -144,7 +146,7 @@ protected: public: DWARFUnit(DWARFContext &Context, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, - StringRef SOS, StringRef AOS, StringRef LS, bool LE, + StringRef SOS, StringRef AOS, StringRef LS, bool LE, bool IsDWO, const DWARFUnitSectionBase &UnitSection, const DWARFUnitIndex::Entry *IndexEntry = nullptr); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp index 0430265ae74e..13c2b508bfa3 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -20,7 +20,7 @@ using namespace dwarf; void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) { parseImpl(C, Section, C.getDebugAbbrev(), C.getRangeSection(), C.getStringSection(), StringRef(), C.getAddrSection(), - C.getLineSection().Data, C.isLittleEndian()); + C.getLineSection().Data, C.isLittleEndian(), false); } void DWARFUnitSectionBase::parseDWO(DWARFContext &C, @@ -28,13 +28,14 @@ void DWARFUnitSectionBase::parseDWO(DWARFContext &C, DWARFUnitIndex *Index) { parseImpl(C, DWOSection, C.getDebugAbbrevDWO(), C.getRangeDWOSection(), C.getStringDWOSection(), C.getStringOffsetDWOSection(), - C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian()); + C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian(), + true); } DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section, const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS, StringRef SOS, StringRef AOS, StringRef LS, bool LE, - const DWARFUnitSectionBase &UnitSection, + bool IsDWO, const DWARFUnitSectionBase &UnitSection, const DWARFUnitIndex::Entry *IndexEntry) : Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS), LineSection(LS), StringSection(SS), StringOffsetSection([&]() { @@ -43,8 +44,8 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section, return SOS.slice(C->Offset, C->Offset + C->Length); return SOS; }()), - AddrOffsetSection(AOS), isLittleEndian(LE), UnitSection(UnitSection), - IndexEntry(IndexEntry) { + AddrOffsetSection(AOS), isLittleEndian(LE), isDWO(IsDWO), + UnitSection(UnitSection), IndexEntry(IndexEntry) { clear(); } @@ -281,6 +282,8 @@ DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath) } bool DWARFUnit::parseDWO() { + if (isDWO) + return false; if (DWO.get()) return false; extractDIEsIfNeeded(true); diff --git a/llvm/test/DebugInfo/Inputs/split-dwarf-empty.dwo b/llvm/test/DebugInfo/Inputs/split-dwarf-empty.dwo new file mode 100644 index 000000000000..f1d0b678369d Binary files /dev/null and b/llvm/test/DebugInfo/Inputs/split-dwarf-empty.dwo differ diff --git a/llvm/test/DebugInfo/Inputs/split-dwarf-empty.o b/llvm/test/DebugInfo/Inputs/split-dwarf-empty.o new file mode 100644 index 000000000000..95e2ae125915 Binary files /dev/null and b/llvm/test/DebugInfo/Inputs/split-dwarf-empty.o differ diff --git a/llvm/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test b/llvm/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test new file mode 100644 index 000000000000..14c3f3b2bef6 --- /dev/null +++ b/llvm/test/DebugInfo/llvm-symbolizer-split-dwarf-empty.test @@ -0,0 +1,10 @@ +REQUIRES: shell +RUN: cd Output +RUN: cp %p/Inputs/split-dwarf-empty.dwo %T +RUN: echo "%p/Inputs/split-dwarf-empty.o 0xdeadbeef" > %t.input + +RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \ +RUN: --default-arch=i386 < %t.input | FileCheck %s + +CHECK: ?? +CHECK: ??:0:0