1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

llvm-symbolizer: Support multiple CUs in a single DWO file

llvm-svn: 303482
This commit is contained in:
David Blaikie 2017-05-20 03:32:49 +00:00
parent 6bcda35ff2
commit e643a800fc
5 changed files with 19 additions and 7 deletions

View File

@ -149,7 +149,7 @@ class DWARFUnit {
DWARFUnit *DWOU = nullptr;
public:
DWOHolder(StringRef DWOPath);
DWOHolder(StringRef DWOPath, uint64_t DWOId);
DWARFUnit *getUnit() const { return DWOU; }
};

View File

@ -249,7 +249,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
return DieArray.size();
}
DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath) {
DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath, uint64_t DWOId) {
auto Obj = object::ObjectFile::createObjectFile(DWOPath);
if (!Obj) {
// TODO: Actually report errors helpfully.
@ -259,8 +259,11 @@ DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath) {
DWOFile = std::move(Obj.get());
DWOContext.reset(
cast<DWARFContext>(new DWARFContextInMemory(*DWOFile.getBinary())));
if (DWOContext->getNumDWOCompileUnits() > 0)
DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
for (const auto &DWOCU : DWOContext->dwo_compile_units())
if (DWOCU->getDWOId() == DWOId) {
DWOU = DWOCU.get();
return;
}
}
bool DWARFUnit::parseDWO() {
@ -281,10 +284,12 @@ bool DWARFUnit::parseDWO() {
sys::path::append(AbsolutePath, *CompilationDir);
}
sys::path::append(AbsolutePath, *DWOFileName);
DWO = llvm::make_unique<DWOHolder>(AbsolutePath);
auto DWOId = getDWOId();
if (!DWOId)
return false;
DWO = llvm::make_unique<DWOHolder>(AbsolutePath, *DWOId);
DWARFUnit *DWOCU = DWO->getUnit();
// Verify that compile unit in .dwo file is valid.
if (!DWOCU || DWOCU->getDWOId() != getDWOId()) {
if (!DWOCU) {
DWO.reset();
return false;
}

Binary file not shown.

Binary file not shown.

View File

@ -23,6 +23,8 @@ RUN: cp %p/Inputs/split-dwarf-test.dwo %T
RUN: echo "%p/Inputs/split-dwarf-test 0x4005d4" >> %t.input
RUN: echo "%p/Inputs/split-dwarf-test 0x4005c4" >> %t.input
RUN: echo "%p/Inputs/cross-cu-inlining.x86_64-macho.o 0x17" >> %t.input
RUN: cp %p/Inputs/split-dwarf-multiple-cu.dwo %T
RUN: echo "%p/Inputs/split-dwarf-multiple-cu.o 0x4" >> %t.input
RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
RUN: --default-arch=i386 < %t.input | FileCheck --check-prefix=CHECK --check-prefix=SPLIT --check-prefix=DWO %s
@ -133,6 +135,11 @@ CHECK-NEXT: /tmp{{[/\\]}}cross-cu-inlining.c:16:3
CHECK-NEXT: main
CHECK-NEXT: /tmp{{[/\\]}}cross-cu-inlining.c:11:0
CHECK: f2
CHECK-NEXT: b.cpp:3:3
CHECK-NEXT: f3
CHECK-NEXT: b.cpp:6:0
RUN: echo "unexisting-file 0x1234" > %t.input2
RUN: llvm-symbolizer < %t.input2 2>&1 | FileCheck %s --check-prefix=MISSING-FILE