-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Add more ways to find the .dwp file. #81067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3c2f603
Add more ways to find the .dwp file.
clayborg 9d58f41
Address review comments.
clayborg 214fe97
Fix comment.
clayborg b843d92
Run clang format.
clayborg cfeb6c4
Added logging for split DWARF DWP file locating.
clayborg 660cb95
Run clang format.
clayborg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4349,26 +4349,60 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() { | |
|
||
const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() { | ||
llvm::call_once(m_dwp_symfile_once_flag, [this]() { | ||
// Create a list of files to try and append .dwp to. | ||
FileSpecList symfiles; | ||
// Append the module's object file path. | ||
const FileSpec module_fspec = m_objfile_sp->GetModule()->GetFileSpec(); | ||
symfiles.Append(module_fspec); | ||
// Append the object file for this SymbolFile only if it is different from | ||
// the module's file path. Our main module could be "a.out", our symbol file | ||
// could be "a.debug" and our ".dwp" file might be "a.debug.dwp" instead of | ||
// "a.out.dwp". | ||
const FileSpec symfile_fspec(m_objfile_sp->GetFileSpec()); | ||
if (symfile_fspec != module_fspec) { | ||
symfiles.Append(symfile_fspec); | ||
} else { | ||
// If we don't have a separate debug info file, then try stripping the | ||
// extension. The main module could be "a.debug" and the .dwp file could | ||
// be "a.dwp" instead of "a.debug.dwp". | ||
ConstString filename_no_ext = | ||
module_fspec.GetFileNameStrippingExtension(); | ||
if (filename_no_ext != module_fspec.GetFilename()) { | ||
FileSpec module_spec_no_ext(module_fspec); | ||
module_spec_no_ext.SetFilename(filename_no_ext); | ||
symfiles.Append(module_spec_no_ext); | ||
} | ||
} | ||
Log *log = GetLog(DWARFLog::SplitDwarf); | ||
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths(); | ||
ModuleSpec module_spec; | ||
module_spec.GetFileSpec() = m_objfile_sp->GetFileSpec(); | ||
module_spec.GetSymbolFileSpec() = | ||
FileSpec(m_objfile_sp->GetModule()->GetFileSpec().GetPath() + ".dwp"); | ||
|
||
module_spec.GetUUID() = m_objfile_sp->GetUUID(); | ||
FileSpecList search_paths = Target::GetDefaultDebugFileSearchPaths(); | ||
FileSpec dwp_filespec = | ||
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); | ||
if (FileSystem::Instance().Exists(dwp_filespec)) { | ||
DataBufferSP dwp_file_data_sp; | ||
lldb::offset_t dwp_file_data_offset = 0; | ||
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin( | ||
GetObjectFile()->GetModule(), &dwp_filespec, 0, | ||
FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp, | ||
dwp_file_data_offset); | ||
if (!dwp_obj_file) | ||
return; | ||
m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>( | ||
*this, dwp_obj_file, DIERef::k_file_index_mask); | ||
for (const auto &symfile : symfiles.files()) { | ||
module_spec.GetSymbolFileSpec() = | ||
FileSpec(symfile.GetPath() + ".dwp", symfile.GetPathStyle()); | ||
LLDB_LOG(log, "Searching for DWP using: \"{0}\"", | ||
module_spec.GetSymbolFileSpec()); | ||
FileSpec dwp_filespec = | ||
PluginManager::LocateExecutableSymbolFile(module_spec, search_paths); | ||
if (FileSystem::Instance().Exists(dwp_filespec)) { | ||
LLDB_LOG(log, "Found DWP file: \"{0}\"", dwp_filespec); | ||
DataBufferSP dwp_file_data_sp; | ||
lldb::offset_t dwp_file_data_offset = 0; | ||
ObjectFileSP dwp_obj_file = ObjectFile::FindPlugin( | ||
GetObjectFile()->GetModule(), &dwp_filespec, 0, | ||
FileSystem::Instance().GetByteSize(dwp_filespec), dwp_file_data_sp, | ||
dwp_file_data_offset); | ||
if (dwp_obj_file) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar, adding a logging saying - found a matching dwp file and use it. |
||
m_dwp_symfile = std::make_shared<SymbolFileDWARFDwo>( | ||
*this, dwp_obj_file, DIERef::k_file_index_mask); | ||
break; | ||
} | ||
} | ||
} | ||
if (!m_dwp_symfile) { | ||
LLDB_LOG(log, "Unable to locate for DWP file for: \"{0}\"", | ||
m_objfile_sp->GetModule()->GetFileSpec()); | ||
} | ||
}); | ||
return m_dwp_symfile; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a logging for each probing entries.
One thing I noticed that Microsoft debugger (like windbg) does well is they provide an option to show debug artifacts probing paths for both local and symbol servers. This provides an important self servicing capability for end users - even they do not know the debug info file locating algorithms, they can use the probing paths to figure out and rename to match the expected probing.