cmtice updated this revision to Diff 327523.
cmtice added a comment.

Upload the correct patch this time. (sorry!)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97786/new/

https://reviews.llvm.org/D97786

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1639,6 +1639,18 @@
       return nullptr;
 
     dwo_file.SetFile(comp_dir, FileSpec::Style::native);
+    if (dwo_file.IsRelative()) {
+      // if DW_AT_comp_dir is relative, it should be relative to the location
+      // of the executable, not to the location from which the debugger was
+      // launched.
+      ModuleSpec module_spec;
+      module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
+      module_spec.GetSymbolFileSpec() =
+          FileSpec(m_objfile_sp->GetModule()->GetFileSpec().GetPath());
+      llvm::StringRef exe_dir =
+          module_spec.GetFileSpec().GetDirectory().GetStringRef();
+      dwo_file.PrependPathComponent(exe_dir);
+    }
     FileSystem::Instance().Resolve(dwo_file);
     dwo_file.AppendPathComponent(dwo_name);
   }


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1639,6 +1639,18 @@
       return nullptr;
 
     dwo_file.SetFile(comp_dir, FileSpec::Style::native);
+    if (dwo_file.IsRelative()) {
+      // if DW_AT_comp_dir is relative, it should be relative to the location
+      // of the executable, not to the location from which the debugger was
+      // launched.
+      ModuleSpec module_spec;
+      module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec();
+      module_spec.GetSymbolFileSpec() =
+          FileSpec(m_objfile_sp->GetModule()->GetFileSpec().GetPath());
+      llvm::StringRef exe_dir =
+          module_spec.GetFileSpec().GetDirectory().GetStringRef();
+      dwo_file.PrependPathComponent(exe_dir);
+    }
     FileSystem::Instance().Resolve(dwo_file);
     dwo_file.AppendPathComponent(dwo_name);
   }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to