diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -763,28 +763,13 @@ 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. - Status kernel_search_error; - if (IsKernel()) { - if (Symbols::DownloadObjectAndSymbolFile(module_spec, - kernel_search_error, true)) { - if (FileSystem::Instance().Exists(module_spec.GetFileSpec())) { - m_module_sp = std::make_shared(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. // PlatformDarwinKernel does a special scan for kexts on the local // system. PlatformSP platform_sp(target.GetPlatform()); - if (!m_module_sp && platform_sp) { + if (platform_sp) { static ConstString g_platform_name( PlatformDarwinKernel::GetPluginNameStatic()); if (platform_sp->GetPluginName() == g_platform_name.GetStringRef()) { @@ -807,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_spec.GetFileSpec(), + target.GetArchitecture()); + } + } + } + if (IsKernel() && !m_module_sp) { Stream &s = target.GetDebugger().GetErrorStream(); s.Printf("WARNING: Unable to locate kernel binary on the debugger "