llvm-symbolizer: Avoid infinite recursion walking dwos where the dwo contains a dwo_name attribute
The dwo_name was added to dwo files to improve diagnostics in dwp, but it confuses tools that attempt to load any dwo named by a dwo_name, even ones inside dwos. Avoid this by keeping track of whether a unit is already a dwo unit, and if so, not loading further dwos. llvm-svn: 267241
This commit is contained in:
parent
efa3fe14d1
commit
e438cff475
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<UnitType>(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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -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
|
Loading…
Reference in New Issue