[Lldb-commits] [PATCH] D157165: [lldb] [darwin kernel debug] When looking for a Darwin kernel symbol file, call GetSharedModules before DownloadObjectAndSymbolFile
Jason Molenda via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 4 17:20:24 PDT 2023
jasonmolenda created this revision.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
jasonmolenda requested review of this revision.
Herald added a subscriber: lldb-commits.
ModuleList::GetSharedModule will call in to the DebugSymbols framework and may be able to find a file on the local system by Spotlight search, or by using the Platform's override of GetSharedModule, and may be faster than calling Symbols::DownloadObjectAndSymbolFile which calls out to an external program and is likely to do a network filesystem or download of the binary/symbol file.
A small perf improvement, NFC. This is very much jason code, not really looking for a review of this one.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157165
Files:
lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
Index: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
===================================================================
--- lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
+++ lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
@@ -763,20 +763,6 @@
module_spec.GetUUID() = m_uuid;
module_spec.GetArchitecture() = target.GetArchitecture();
- // For the kernel, we really do need an on-disk file copy of the binary
- // to do anything useful. This will force a call to dsymForUUID if it
- // exists, instead of depending on the DebugSymbols preferences being
- // set.
- if (IsKernel()) {
- Status error;
- if (Symbols::DownloadObjectAndSymbolFile(module_spec, error, true)) {
- if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
- m_module_sp = std::make_shared<Module>(module_spec.GetFileSpec(),
- target.GetArchitecture());
- }
- }
- }
-
// If the current platform is PlatformDarwinKernel, create a ModuleSpec
// with the filename set to be the bundle ID for this kext, e.g.
// "com.apple.filesystems.msdosfs", and ask the platform to find it.
@@ -806,6 +792,22 @@
m_module_sp = target.GetOrCreateModule(module_spec, true /* notify */);
}
+ // For the kernel, we really do need an on-disk file copy of the binary
+ // to do anything useful. This will force a call to dsymForUUID if it
+ // exists, instead of depending on the DebugSymbols preferences being
+ // set.
+ Status kernel_search_error;
+ if (IsKernel() &&
+ (!m_module_sp || !m_module_sp->GetSymbolFileFileSpec())) {
+ if (Symbols::DownloadObjectAndSymbolFile(module_spec,
+ kernel_search_error, true)) {
+ if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) {
+ m_module_sp = std::make_shared<Module>(module_spec.GetFileSpec(),
+ target.GetArchitecture());
+ }
+ }
+ }
+
if (IsKernel() && !m_module_sp) {
Stream &s = target.GetDebugger().GetOutputStream();
s.Printf("WARNING: Unable to locate kernel binary on the debugger "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157165.547416.patch
Type: text/x-patch
Size: 2395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230805/6ca15e0a/attachment-0001.bin>
More information about the lldb-commits
mailing list