summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2017-05-20 03:32:49 +0000
committerDavid Blaikie <dblaikie@gmail.com>2017-05-20 03:32:49 +0000
commit8d039d40c5fd32ed44d14f2cabd4514818b9a9c9 (patch)
treee4840da567e846bea2f6eeb958002c5d1441d290
parent4eff87c36d6b104aa5fefa8b9c291e007b9ee48b (diff)
downloadbcm5719-llvm-8d039d40c5fd32ed44d14f2cabd4514818b9a9c9.tar.gz
bcm5719-llvm-8d039d40c5fd32ed44d14f2cabd4514818b9a9c9.zip
llvm-symbolizer: Support multiple CUs in a single DWO file
llvm-svn: 303482
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h2
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp17
-rw-r--r--llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwobin0 -> 1040 bytes
-rw-r--r--llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.obin0 -> 2992 bytes
-rw-r--r--llvm/test/DebugInfo/llvm-symbolizer.test7
5 files changed, 19 insertions, 7 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index c15e27f36a8..9d69f60e4c1 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -149,7 +149,7 @@ class DWARFUnit {
DWARFUnit *DWOU = nullptr;
public:
- DWOHolder(StringRef DWOPath);
+ DWOHolder(StringRef DWOPath, uint64_t DWOId);
DWARFUnit *getUnit() const { return DWOU; }
};
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index 3835d4da9ae..a784968e269 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -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;
}
diff --git a/llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo b/llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo
new file mode 100644
index 00000000000..4df9894b089
--- /dev/null
+++ b/llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo
Binary files differ
diff --git a/llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o b/llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o
new file mode 100644
index 00000000000..aa4ab4bc76f
--- /dev/null
+++ b/llvm/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o
Binary files differ
diff --git a/llvm/test/DebugInfo/llvm-symbolizer.test b/llvm/test/DebugInfo/llvm-symbolizer.test
index 7ea062e6c9e..542a10fcbe9 100644
--- a/llvm/test/DebugInfo/llvm-symbolizer.test
+++ b/llvm/test/DebugInfo/llvm-symbolizer.test
@@ -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
OpenPOWER on IntegriCloud