[Lldb-commits] [PATCH] D157609: WIP: [lldb] Search debug file paths when looking for split DWARF files
David Spickett via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 10 06:06:40 PDT 2023
DavidSpickett created this revision.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, jplehr, sstefan1.
Herald added a project: LLDB.
DavidSpickett planned changes to this revision.
Herald added a subscriber: JDevlieghere.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157609
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
@@ -1731,7 +1731,11 @@
const char *comp_dir = nullptr;
FileSpec dwo_file(dwo_name);
FileSystem::Instance().Resolve(dwo_file);
- if (dwo_file.IsRelative()) {
+ bool found = false;
+
+ if (!dwo_file.IsRelative()) {
+ found = FileSystem::Instance().Exists(dwo_file);
+ } else {
comp_dir = cu_die.GetAttributeValueAsString(dwarf_cu, DW_AT_comp_dir,
nullptr);
if (!comp_dir) {
@@ -1744,18 +1748,52 @@
}
dwo_file.SetFile(comp_dir, FileSpec::Style::native);
- if (dwo_file.IsRelative()) {
+
+ if (!dwo_file.IsRelative()) {
+ // TODO: should we also search debug file paths here?
+ FileSystem::Instance().Resolve(dwo_file);
+ dwo_file.AppendPathComponent(dwo_name);
+ found = FileSystem::Instance().Exists(dwo_file);
+ } else {
+ FileSpecList dwo_paths;
+
// 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.
- dwo_file.PrependPathComponent(
+ FileSpec relative_to_binary = dwo_file;
+ relative_to_binary.PrependPathComponent(
m_objfile_sp->GetFileSpec().GetDirectory().GetStringRef());
+ FileSystem::Instance().Resolve(relative_to_binary);
+ relative_to_binary.AppendPathComponent(dwo_name);
+ dwo_paths.Append(relative_to_binary);
+
+ // Or it's relative to one of the user specified debug directories.
+ const FileSpecList &debug_file_search_paths =
+ Target::GetDefaultDebugFileSearchPaths();
+ size_t num_directories = debug_file_search_paths.GetSize();
+ for (size_t idx = 0; idx < num_directories; ++idx) {
+ FileSpec dirspec = debug_file_search_paths.GetFileSpecAtIndex(idx);
+ dirspec.AppendPathComponent(comp_dir);
+ FileSystem::Instance().Resolve(dirspec);
+ if (!FileSystem::Instance().IsDirectory(dirspec))
+ continue;
+
+ dirspec.AppendPathComponent(dwo_name);
+ dwo_paths.Append(dirspec);
+ }
+
+ size_t num_possible = dwo_paths.GetSize();
+ for (size_t idx = 0; idx < num_possible && !found; ++idx) {
+ FileSpec dwo_spec = dwo_paths.GetFileSpecAtIndex(idx);
+ if (FileSystem::Instance().Exists(dwo_spec)) {
+ dwo_file = dwo_spec;
+ found = true;
+ }
+ }
}
- FileSystem::Instance().Resolve(dwo_file);
- dwo_file.AppendPathComponent(dwo_name);
}
- if (!FileSystem::Instance().Exists(dwo_file)) {
+ if (!found) {
unit.SetDwoError(Status::createWithFormat(
"unable to locate .dwo debug file \"{0}\" for skeleton DIE "
"{1:x16}",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157609.549001.patch
Type: text/x-patch
Size: 2952 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230810/f4352d52/attachment.bin>
More information about the lldb-commits
mailing list