[llvm] r253377 - dwarfdump: Reference the appropriate line table segment when dumping dwp files
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 17 13:08:05 PST 2015
Author: dblaikie
Date: Tue Nov 17 15:08:05 2015
New Revision: 253377
URL: http://llvm.org/viewvc/llvm-project?rev=253377&view=rev
Log:
dwarfdump: Reference the appropriate line table segment when dumping dwp files
Also improves .dwo type unit dumping which didn't handle this either.
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
llvm/trunk/test/DebugInfo/dwarfdump-dwp.test
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h?rev=253377&r1=253376&r2=253377&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h Tue Nov 17 15:08:05 2015
@@ -18,10 +18,10 @@ class DWARFCompileUnit : public DWARFUni
public:
DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
- StringRef SOS, StringRef AOS, bool LE,
+ StringRef SOS, StringRef AOS, StringRef LS, bool LE,
const DWARFUnitSectionBase &UnitSection,
const DWARFUnitIndex::Entry *Entry)
- : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection,
+ : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection,
Entry) {}
void dump(raw_ostream &OS);
static const DWARFSectionKind Section = DW_SECT_INFO;
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h?rev=253377&r1=253376&r2=253377&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h Tue Nov 17 15:08:05 2015
@@ -21,10 +21,10 @@ private:
public:
DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
- StringRef SOS, StringRef AOS, bool LE,
+ StringRef SOS, StringRef AOS, StringRef LS, bool LE,
const DWARFUnitSectionBase &UnitSection,
const DWARFUnitIndex::Entry *Entry)
- : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LE, UnitSection,
+ : DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection,
Entry) {}
uint32_t getHeaderSize() const override {
return DWARFUnit::getHeaderSize() + 12;
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h?rev=253377&r1=253376&r2=253377&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Tue Nov 17 15:08:05 2015
@@ -46,7 +46,8 @@ public:
protected:
virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
- StringRef SOS, StringRef AOS, bool isLittleEndian) = 0;
+ StringRef SOS, StringRef AOS, StringRef LS,
+ bool isLittleEndian) = 0;
~DWARFUnitSectionBase() = default;
};
@@ -83,16 +84,16 @@ public:
private:
void parseImpl(DWARFContext &Context, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
- StringRef SOS, StringRef AOS, bool LE) override {
+ StringRef SOS, StringRef AOS, StringRef LS, bool LE) override {
if (Parsed)
return;
const auto &Index = getDWARFUnitIndex(Context, UnitType::Section);
DataExtractor Data(Section.Data, LE, 0);
uint32_t Offset = 0;
while (Data.isValidOffset(Offset)) {
- auto U =
- llvm::make_unique<UnitType>(Context, Section, DA, RS, SS, SOS, AOS,
- LE, *this, Index.getFromOffset(Offset));
+ auto U = llvm::make_unique<UnitType>(Context, Section, DA, RS, SS, SOS,
+ AOS, LS, LE, *this,
+ Index.getFromOffset(Offset));
if (!U->extract(Data, &Offset))
break;
this->push_back(std::move(U));
@@ -110,6 +111,7 @@ class DWARFUnit {
const DWARFDebugAbbrev *Abbrev;
StringRef RangeSection;
uint32_t RangeSectionBase;
+ StringRef LineSection;
StringRef StringSection;
StringRef StringOffsetSection;
StringRef AddrOffsetSection;
@@ -146,7 +148,7 @@ protected:
public:
DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
- StringRef SOS, StringRef AOS, bool LE,
+ StringRef SOS, StringRef AOS, StringRef LS, bool LE,
const DWARFUnitSectionBase &UnitSection,
const DWARFUnitIndex::Entry *IndexEntry = nullptr);
@@ -154,6 +156,7 @@ public:
DWARFContext& getContext() const { return Context; }
+ StringRef getLineSection() const { return LineSection; }
StringRef getStringSection() const { return StringSection; }
StringRef getStringOffsetSection() const { return StringOffsetSection; }
void setAddrOffsetSection(StringRef AOS, uint32_t Base) {
@@ -251,12 +254,19 @@ public:
assert(!DieArray.empty());
auto it = std::lower_bound(
DieArray.begin(), DieArray.end(), Offset,
- [=](const DWARFDebugInfoEntryMinimal &LHS, uint32_t Offset) {
+ [](const DWARFDebugInfoEntryMinimal &LHS, uint32_t Offset) {
return LHS.getOffset() < Offset;
});
return it == DieArray.end() ? nullptr : &*it;
}
+ uint32_t getLineTableOffset() const {
+ if (IndexEntry)
+ if (const auto *Contrib = IndexEntry->getOffset(DW_SECT_LINE))
+ return Contrib->Offset;
+ return 0;
+ }
+
private:
/// Size in bytes of the .debug_info data associated with this compile unit.
size_t getDebugInfoSize() const { return Length + 4 - getHeaderSize(); }
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=253377&r1=253376&r2=253377&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Tue Nov 17 15:08:05 2015
@@ -382,20 +382,23 @@ const DWARFLineTable *
DWARFContext::getLineTableForUnit(DWARFUnit *U) {
if (!Line)
Line.reset(new DWARFDebugLine(&getLineSection().Relocs));
+
const auto *UnitDIE = U->getUnitDIE();
if (UnitDIE == nullptr)
return nullptr;
+
unsigned stmtOffset =
UnitDIE->getAttributeValueAsSectionOffset(U, DW_AT_stmt_list, -1U);
if (stmtOffset == -1U)
return nullptr; // No line table for this compile unit.
+ stmtOffset += U->getLineTableOffset();
// See if the line table is cached.
if (const DWARFLineTable *lt = Line->getLineTable(stmtOffset))
return lt;
// We have to parse it first.
- DataExtractor lineData(getLineSection().Data, isLittleEndian(),
+ DataExtractor lineData(U->getLineSection(), isLittleEndian(),
U->getAddressByteSize());
return Line->getOrParseLineTable(lineData, stmtOffset);
}
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=253377&r1=253376&r2=253377&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Tue Nov 17 15:08:05 2015
@@ -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.isLittleEndian());
+ C.getLineSection().Data, C.isLittleEndian());
}
void DWARFUnitSectionBase::parseDWO(DWARFContext &C,
@@ -28,17 +28,18 @@ void DWARFUnitSectionBase::parseDWO(DWAR
DWARFUnitIndex *Index) {
parseImpl(C, DWOSection, C.getDebugAbbrevDWO(), C.getRangeDWOSection(),
C.getStringDWOSection(), C.getStringOffsetDWOSection(),
- C.getAddrSection(), C.isLittleEndian());
+ C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian());
}
DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
- StringRef SOS, StringRef AOS, bool LE,
+ StringRef SOS, StringRef AOS, StringRef LS, bool LE,
const DWARFUnitSectionBase &UnitSection,
const DWARFUnitIndex::Entry *IndexEntry)
: Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),
- StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),
- isLittleEndian(LE), UnitSection(UnitSection), IndexEntry(IndexEntry) {
+ LineSection(LS), StringSection(SS), StringOffsetSection(SOS),
+ AddrOffsetSection(AOS), isLittleEndian(LE), UnitSection(UnitSection),
+ IndexEntry(IndexEntry) {
clear();
}
Modified: llvm/trunk/test/DebugInfo/dwarfdump-dwp.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dwarfdump-dwp.test?rev=253377&r1=253376&r2=253377&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/dwarfdump-dwp.test (original)
+++ llvm/trunk/test/DebugInfo/dwarfdump-dwp.test Tue Nov 17 15:08:05 2015
@@ -9,7 +9,7 @@ RUN: llvm-dwarfdump %p/Inputs/dwarfdump-
; bar b() {
; }
-; CHECK: .debug_info.dwo contents:
+; CHECK-LABEL: .debug_info.dwo contents:
; CHECK: Compile Unit
; Verify that the second CU uses the index for its abbrev offset
@@ -21,8 +21,20 @@ RUN: llvm-dwarfdump %p/Inputs/dwarfdump-
; CHECK: DW_AT_name {{.*}} "a.cpp"
; Verify that abbreviations are decoded using the abbrev offset in the index
-; CHECK: DW_TAG_subprogram
; CHECK: DW_TAG_structure_type
+; CHECK: DW_TAG_subprogram
+
+; CHECK-LABEL: .debug_types.dwo contents:
+; CHECK: Type Unit
+; CHECK: DW_TAG_type_unit
+; CHECK: DW_AT_stmt_list {{.*}}(0x00000000)
+; CHECK: DW_TAG_structure_type
+; CHECK: DW_AT_decl_file {{.*}} ("a.cpp")
+; CHECK: Type Unit
+; CHECK: DW_TAG_type_unit
+; CHECK: DW_AT_stmt_list {{.*}}(0x00000000)
+; CHECK: DW_TAG_structure_type
+; CHECK: DW_AT_decl_file {{.*}} ("b.cpp")
; CHECK: .debug_cu_index contents:
; CHECK-NEXT: version = 2 slots = 16
More information about the llvm-commits
mailing list