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

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri May 19 20:32:49 PDT 2017


Author: dblaikie
Date: Fri May 19 22:32:49 2017
New Revision: 303482

URL: http://llvm.org/viewvc/llvm-project?rev=303482&view=rev
Log:
llvm-symbolizer: Support multiple CUs in a single DWO file

Added:
    llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo
    llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o
Modified:
    llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h
    llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
    llvm/trunk/test/DebugInfo/llvm-symbolizer.test

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=303482&r1=303481&r2=303482&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFUnit.h Fri May 19 22:32:49 2017
@@ -149,7 +149,7 @@ class DWARFUnit {
     DWARFUnit *DWOU = nullptr;
 
   public:
-    DWOHolder(StringRef DWOPath);
+    DWOHolder(StringRef DWOPath, uint64_t DWOId);
 
     DWARFUnit *getUnit() const { return DWOU; }
   };

Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp?rev=303482&r1=303481&r2=303482&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFUnit.cpp Fri May 19 22:32:49 2017
@@ -249,7 +249,7 @@ size_t DWARFUnit::extractDIEsIfNeeded(bo
   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(StringRe
   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;
   }

Added: llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo?rev=303482&view=auto
==============================================================================
Binary files llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo (added) and llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.dwo Fri May 19 22:32:49 2017 differ

Added: llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o?rev=303482&view=auto
==============================================================================
Binary files llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o (added) and llvm/trunk/test/DebugInfo/Inputs/split-dwarf-multiple-cu.o Fri May 19 22:32:49 2017 differ

Modified: llvm/trunk/test/DebugInfo/llvm-symbolizer.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/llvm-symbolizer.test?rev=303482&r1=303481&r2=303482&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/llvm-symbolizer.test (original)
+++ llvm/trunk/test/DebugInfo/llvm-symbolizer.test Fri May 19 22:32:49 2017
@@ -23,6 +23,8 @@ RUN: cp %p/Inputs/split-dwarf-test.dwo %
 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-inlini
 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
 




More information about the llvm-commits mailing list