[Lldb-commits] [PATCH] D38568: [lldb] Enable using out-of-tree dwps

Alexander Shaposhnikov via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Oct 4 16:14:31 PDT 2017


alexshap created this revision.
Herald added subscribers: JDevlieghere, aprantl.

Previously LLDB required dwp to be located next to the executable file
(see the code in SymbolFileDWARF::GetDwpSymbolFile).
This diff uses the helper function Symbols::LocateExecutableSymbolFile
to search for DWP files in the standard locations for debug symbols.

Test plan:

Build a toy test example 
main.cpp
clang -gsplit-dwarf -g -O0 main.cpp -o main.exe
llvm-dwp -e main.exe -o main.exe.dwp
mkdir -p debug_symbols
mv main.exe.dwp debug_symbols/main.exe.dwp
rm -f main.dwo

Run lldb:
lldb
settings set target.debug-file-search-paths ./debug_symbols
file ./main.exe
br set --name f
r

Check that debugging works 
(setting breakpoints, printing local variables (this was not working before))


Repository:
  rL LLVM

https://reviews.llvm.org/D38568

Files:
  source/Host/common/Symbols.cpp
  source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -30,6 +30,7 @@
 
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
+#include "lldb/Host/Symbols.h"
 
 #include "lldb/Interpreter/OptionValueFileSpecList.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
@@ -4352,7 +4353,11 @@
 
 SymbolFileDWARFDwp *SymbolFileDWARF::GetDwpSymbolFile() {
   llvm::call_once(m_dwp_symfile_once_flag, [this]() {
-    FileSpec dwp_filespec(m_obj_file->GetFileSpec().GetPath() + ".dwp", false);
+    ModuleSpec module_spec;
+    module_spec.GetFileSpec() = m_obj_file->GetFileSpec();
+    module_spec.GetSymbolFileSpec() =
+        FileSpec(m_obj_file->GetFileSpec().GetPath() + ".dwp", false);
+    FileSpec dwp_filespec = Symbols::LocateExecutableSymbolFile(module_spec);
     if (dwp_filespec.Exists()) {
       m_dwp_symfile = SymbolFileDWARFDwp::Create(GetObjectFile()->GetModule(),
                                                  dwp_filespec);
Index: source/Host/common/Symbols.cpp
===================================================================
--- source/Host/common/Symbols.cpp
+++ source/Host/common/Symbols.cpp
@@ -285,7 +285,13 @@
           if (num_specs == 1) {
             ModuleSpec mspec;
             if (specs.GetModuleSpecAtIndex(0, mspec)) {
-              if (mspec.GetUUID() == module_uuid)
+              // FIXME: at the moment llvm-dwp doesn't output build ids,
+              // nor does binutils dwp. Thus in the case of DWPs
+              // we skip uuids check. This needs to be fixed
+              // to avoid consistency issues as soon as
+              // llvm-dwp and binutils dwp gain support for build ids.
+              if (file_spec.GetFileNameExtension().GetStringRef() == "dwp" ||
+                  mspec.GetUUID() == module_uuid)
                 return file_spec;
             }
           }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38568.117755.patch
Type: text/x-patch
Size: 2036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171004/76eabdc6/attachment.bin>


More information about the lldb-commits mailing list