From c9c09ef836b49dba0a6fc784f322a96a86a9b985 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Mon, 24 Feb 2020 16:45:37 +0100 Subject: [PATCH] [lldb/DWARF] Fix dwp search path in the separate-debug-file case 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). --- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 2 +- lldb/test/CMakeLists.txt | 1 + .../DWARF/dwp-separate-debug-file.cpp | 17 +++++++++++++++++ lldb/test/Shell/helper/toolchain.py | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index df1290c91782..c89ccb5bf960 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3880,7 +3880,7 @@ const std::shared_ptr &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 = diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 21a0ca47b716..d5b9fab1cd14 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -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 index 000000000000..26fd34d374a7 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp @@ -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() {} diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py index a4bd9f20feb1..99e04b2b6e35 100644 --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -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]