[lldb/DWARF] Fix dwp search path in the separate-debug-file case
authorPavel Labath <pavel@labath.sk>
Mon, 24 Feb 2020 15:45:37 +0000 (16:45 +0100)
committerPavel Labath <pavel@labath.sk>
Mon, 24 Feb 2020 16:01:15 +0000 (17:01 +0100)
The convention is that the dwp file name is derived from the name of the
file holding the executable code, even if the linked portion of the
debug info is elsewhere (objcopy --only-keep-debug).

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/test/CMakeLists.txt
lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp [new file with mode: 0644]
lldb/test/Shell/helper/toolchain.py

index df1290c..c89ccb5 100644 (file)
@@ -3880,7 +3880,7 @@ const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
     ModuleSpec module_spec;
     module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
     module_spec.GetSymbolFileSpec() =
-        FileSpec(m_objfile_sp->GetFileSpec().GetPath() + ".dwp");
+        FileSpec(m_objfile_sp->GetModule()->GetFileSpec().GetPath() + ".dwp");
 
     FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths();
     FileSpec dwp_filespec =
index 21a0ca4..d5b9fab 100644 (file)
@@ -126,6 +126,7 @@ add_lldb_test_dependency(
   lli
   llvm-config
   llvm-dwarfdump
+  llvm-dwp
   llvm-nm
   llvm-mc
   llvm-objcopy
diff --git a/lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp b/lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp
new file mode 100644 (file)
index 0000000..26fd34d
--- /dev/null
@@ -0,0 +1,17 @@
+// REQUIRES: lld
+
+// RUN: %clang -target x86_64-pc-linux -gsplit-dwarf -c %s -o %t.o
+// RUN: ld.lld %t.o -o %t
+// RUN: llvm-dwp %t.dwo -o %t.dwp
+// RUN: rm %t.dwo
+// RUN: llvm-objcopy --only-keep-debug %t %t.debug
+// RUN: llvm-objcopy --strip-all --add-gnu-debuglink=%t.debug %t
+// RUN: %lldb %t -o "target variable a" -b | FileCheck %s
+
+// CHECK: (A) a = (x = 47)
+
+struct A {
+  int x = 47;
+};
+A a;
+int main() {}
index a4bd9f2..99e04b2 100644 (file)
@@ -149,7 +149,7 @@ def use_support_substitutions(config):
         config.available_features.add('lld')
 
 
-    support_tools = ['yaml2obj', 'obj2yaml', 'llvm-pdbutil',
+    support_tools = ['yaml2obj', 'obj2yaml', 'llvm-dwp', 'llvm-pdbutil',
                      'llvm-mc', 'llvm-readobj', 'llvm-objdump',
                      'llvm-objcopy', 'lli']
     additional_tool_dirs += [config.lldb_tools_dir, config.llvm_tools_dir]