jasonmolenda created this revision. jasonmolenda added a project: LLDB. Herald added subscribers: lldb-commits, JDevlieghere. jasonmolenda requested review of this revision.
This started out with one small idea I had and then got a bit of PatchCreep while I was digging into a subsystem I haven't touched in a year or two. The patch is all isolated to darwin kernel debugging, it doesn't modify anything outside of that. The things I changed here: 1. When looking on the local filesystem for a kernel binary + dSYM pair, if that fails, look through any dSYMs that we saw alone without a binary, and load those as a binary+dSYM pair all by itself. It's not ideal, but it will mostly work. 2. Remove the 'platform.plugin.darwin-kernel.search-locally-for-kexts' setting. I originally added this setting when I first added the local filesystem scan for kexts/kernels, fearing that people would ask for a way to disable it. No one has ever asked. I thought of making the setting a no-op and documenting it as obsoleted, but eventually it'll have to be removed and someone will get an error in their .lldbinit file if they're still using it. Might as well make that now. 3. Change plugin.dynamic-loader.darwin-kernel.load-kexts so that it doesn't disable local kernel binary scanning. It was a nonobvious interaction, I see kernel developers trip over this occasionally. 4. Split up PlatformDarwinKernel::GetSharedModule into GetSharedModuleKext and GetSharedModuleKernel. This method was unnecessarily large and the blocks of code had no interaction with each other; splitting it out makes it easier to read and modify. 5. I keep track of possible kernel .dSYM.yaa (a file archive format) files that I come across during the scan, but I'm only reporting it in the statistics for now, I don't think I want to pay the cost of expanding these to see if they're a match. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D88632 Files: lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h lldb/source/Plugins/Platform/MacOSX/PlatformMacOSXProperties.td
Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSXProperties.td =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSXProperties.td +++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSXProperties.td @@ -1,10 +1,6 @@ include "../../../../include/lldb/Core/PropertiesBase.td" let Definition = "platformdarwinkernel" in { - def SearchForKexts: Property<"search-locally-for-kexts", "Boolean">, - Global, - DefaultTrue, - Desc<"Automatically search for kexts on the local system when doing kernel debugging.">; def KextDirectories: Property<"kext-directories", "FileSpecList">, DefaultStringValue<"">, Desc<"Directories/KDKs to search for kexts in when starting a kernel debug session.">; Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h +++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h @@ -126,7 +126,30 @@ // Returns true if there is a .dSYM bundle next to the kernel static bool - KernelHasdSYMSibling(const lldb_private::FileSpec &kext_bundle_filepath); + KernelHasdSYMSibling(const lldb_private::FileSpec &kernel_filepath); + + // Returns true if there is a .dSYM bundle with NO kernel binary next to it + static bool KerneldSYMHasNoSiblingBinary( + const lldb_private::FileSpec &kernel_dsym_filepath); + + // Given a dsym_bundle argument ('.../foo.dSYM'), return a FileSpec + // with the binary inside it ('.../foo.dSYM/Contents/Resources/DWARF/foo'). + // A dSYM bundle may have multiple DWARF binaries in them, so a vector + // of matches is returned. + static std::vector<lldb_private::FileSpec> + GetDWARFBinaryInDSYMBundle(lldb_private::FileSpec dsym_bundle); + + lldb_private::Status + GetSharedModuleKext(const lldb_private::ModuleSpec &module_spec, + lldb_private::Process *process, lldb::ModuleSP &module_sp, + const lldb_private::FileSpecList *module_search_paths_ptr, + lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr); + + lldb_private::Status GetSharedModuleKernel( + const lldb_private::ModuleSpec &module_spec, + lldb_private::Process *process, lldb::ModuleSP &module_sp, + const lldb_private::FileSpecList *module_search_paths_ptr, + lldb::ModuleSP *old_module_sp_ptr, bool *did_create_ptr); lldb_private::Status ExamineKextForMatchingUUID(const lldb_private::FileSpec &kext_bundle_path, @@ -170,6 +193,13 @@ // on local // filesystem, with // dSYMs next to them + KernelBinaryCollection m_kernel_dsyms_no_binaries; // list of kernel + // dsyms with no + // binaries next to + // them + KernelBinaryCollection m_kernel_dsyms_yaas; // list of kernel + // .dSYM.yaa files + lldb_private::LazyBool m_ios_debug_session; PlatformDarwinKernel(const PlatformDarwinKernel &) = delete; Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -199,13 +199,6 @@ virtual ~PlatformDarwinKernelProperties() {} - bool GetSearchForKexts() const { - const uint32_t idx = ePropertySearchForKexts; - return m_collection_sp->GetPropertyAtIndexAsBoolean( - NULL, idx, - g_platformdarwinkernel_properties[idx].default_uint_value != 0); - } - FileSpecList GetKextDirectories() const { const uint32_t idx = ePropertyKextDirectories; const OptionValueFileSpecList *option_value = @@ -245,14 +238,12 @@ m_name_to_kext_path_map_with_dsyms(), m_name_to_kext_path_map_without_dsyms(), m_search_directories(), m_search_directories_no_recursing(), m_kernel_binaries_with_dsyms(), - m_kernel_binaries_without_dsyms(), - m_ios_debug_session(is_ios_debug_session) + m_kernel_binaries_without_dsyms(), m_kernel_dsyms_no_binaries(), + m_kernel_dsyms_yaas(), m_ios_debug_session(is_ios_debug_session) { - if (GetGlobalProperties()->GetSearchForKexts()) { - CollectKextAndKernelDirectories(); - SearchForKextsAndKernelsRecursively(); - } + CollectKextAndKernelDirectories(); + SearchForKextsAndKernelsRecursively(); } /// Destructor. @@ -293,6 +284,10 @@ (int)m_kernel_binaries_with_dsyms.size()); strm.Printf(" Number of Kernel binaries without dSYMs indexed: %d\n", (int)m_kernel_binaries_without_dsyms.size()); + strm.Printf(" Number of Kernel dSYMs with no binaries indexed: %d\n", + (int)m_kernel_dsyms_no_binaries.size()); + strm.Printf(" Number of Kernel dSYM.yaa's indexed: %d\n", + (int)m_kernel_dsyms_yaas.size()); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); if (log) { @@ -305,14 +300,22 @@ for (auto pos : m_name_to_kext_path_map_without_dsyms) { LLDB_LOGF(log, "%s", pos.second.GetPath().c_str()); } - LLDB_LOGF(log, "\nkernels with dSYMS"); + LLDB_LOGF(log, "\nkernel binaries with dSYMS"); for (auto fs : m_kernel_binaries_with_dsyms) { LLDB_LOGF(log, "%s", fs.GetPath().c_str()); } - LLDB_LOGF(log, "\nkernels without dSYMS"); + LLDB_LOGF(log, "\nkernel binaries without dSYMS"); for (auto fs : m_kernel_binaries_without_dsyms) { LLDB_LOGF(log, "%s", fs.GetPath().c_str()); } + LLDB_LOGF(log, "\nkernel dSYMS with no binaries"); + for (auto fs : m_kernel_dsyms_no_binaries) { + LLDB_LOGF(log, "%s", fs.GetPath().c_str()); + } + LLDB_LOGF(log, "\nkernels .dSYM.yaa's"); + for (auto fs : m_kernel_dsyms_yaas) { + LLDB_LOGF(log, "%s", fs.GetPath().c_str()); + } LLDB_LOGF(log, "\n"); } } @@ -497,56 +500,80 @@ file_spec.GetPath().c_str()); PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton; + + bool is_kernel_filename = + file_spec.GetFilename().GetStringRef().startswith("kernel") || + file_spec.GetFilename().GetStringRef().startswith("mach"); + bool is_dsym_yaa = + file_spec.GetFilename().GetStringRef().endswith(".dSYM.yaa"); + if (ft == llvm::sys::fs::file_type::regular_file || ft == llvm::sys::fs::file_type::symlink_file) { - ConstString filename = file_spec.GetFilename(); - if ((strncmp(filename.GetCString(), "kernel", 6) == 0 || - strncmp(filename.GetCString(), "mach", 4) == 0) && - file_spec_extension != g_dsym_suffix) { - if (KernelHasdSYMSibling(file_spec)) - { - LLDB_LOGF(log, - "PlatformDarwinKernel registering kernel binary '%s' with " - "dSYM sibling", - file_spec.GetPath().c_str()); - thisp->m_kernel_binaries_with_dsyms.push_back(file_spec); + if (is_kernel_filename) { + if (file_spec_extension != g_dsym_suffix && !is_dsym_yaa) { + if (KernelHasdSYMSibling(file_spec)) { + LLDB_LOGF(log, + "PlatformDarwinKernel registering kernel binary '%s' with " + "dSYM sibling", + file_spec.GetPath().c_str()); + thisp->m_kernel_binaries_with_dsyms.push_back(file_spec); + } else { + LLDB_LOGF( + log, + "PlatformDarwinKernel registering kernel binary '%s', no dSYM", + file_spec.GetPath().c_str()); + thisp->m_kernel_binaries_without_dsyms.push_back(file_spec); + } } - else - { - LLDB_LOGF( - log, "PlatformDarwinKernel registering kernel binary '%s', no dSYM", - file_spec.GetPath().c_str()); - thisp->m_kernel_binaries_without_dsyms.push_back(file_spec); + if (is_dsym_yaa) { + LLDB_LOGF(log, "PlatformDarwinKernel registering kernel .dSYM.yaa '%s'", + file_spec.GetPath().c_str()); + thisp->m_kernel_dsyms_yaas.push_back(file_spec); } return FileSystem::eEnumerateDirectoryResultNext; } - } else if (ft == llvm::sys::fs::file_type::directory_file && - file_spec_extension == g_kext_suffix) { - AddKextToMap(thisp, file_spec); - // Look to see if there is a PlugIns subdir with more kexts - FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns"); - std::string search_here_too; - if (FileSystem::Instance().IsDirectory(contents_plugins)) { - search_here_too = contents_plugins.GetPath(); - } else { - FileSpec plugins(file_spec.GetPath() + "/PlugIns"); - if (FileSystem::Instance().IsDirectory(plugins)) { - search_here_too = plugins.GetPath(); - } - } + } else { + if (ft == llvm::sys::fs::file_type::directory_file) { + if (file_spec_extension == g_kext_suffix) { + AddKextToMap(thisp, file_spec); + // Look to see if there is a PlugIns subdir with more kexts + FileSpec contents_plugins(file_spec.GetPath() + "/Contents/PlugIns"); + std::string search_here_too; + if (FileSystem::Instance().IsDirectory(contents_plugins)) { + search_here_too = contents_plugins.GetPath(); + } else { + FileSpec plugins(file_spec.GetPath() + "/PlugIns"); + if (FileSystem::Instance().IsDirectory(plugins)) { + search_here_too = plugins.GetPath(); + } + } - if (!search_here_too.empty()) { - const bool find_directories = true; - const bool find_files = false; - const bool find_other = false; - FileSystem::Instance().EnumerateDirectory( - search_here_too.c_str(), find_directories, find_files, find_other, - recurse ? GetKernelsAndKextsInDirectoryWithRecursion - : GetKernelsAndKextsInDirectoryNoRecursion, - baton); + if (!search_here_too.empty()) { + const bool find_directories = true; + const bool find_files = false; + const bool find_other = false; + FileSystem::Instance().EnumerateDirectory( + search_here_too.c_str(), find_directories, find_files, find_other, + recurse ? GetKernelsAndKextsInDirectoryWithRecursion + : GetKernelsAndKextsInDirectoryNoRecursion, + baton); + } + return FileSystem::eEnumerateDirectoryResultNext; + } + // Do we have a kernel dSYM with no kernel binary? + if (is_kernel_filename && file_spec_extension == g_dsym_suffix) { + if (KerneldSYMHasNoSiblingBinary(file_spec)) { + LLDB_LOGF(log, + "PlatformDarwinKernel registering kernel dSYM '%s' with " + "no binary sibling", + file_spec.GetPath().c_str()); + thisp->m_kernel_dsyms_no_binaries.push_back(file_spec); + return FileSystem::eEnumerateDirectoryResultNext; + } + } } - return FileSystem::eEnumerateDirectoryResultNext; } + // Don't recurse into dSYM/kext/bundle directories if (recurse && file_spec_extension != g_dsym_suffix && file_spec_extension != g_kext_suffix && @@ -642,6 +669,62 @@ return FileSystem::Instance().IsDirectory(kernel_dsym); } +// Given a FileSpec of /dir/dir/mach.development.t7004.dSYM +// Return true if only the dSYM exists, no binary next to it. +// /dir/dir/mach.development.t7004.dSYM +// but no +// /dir/dir/mach.development.t7004 +bool PlatformDarwinKernel::KerneldSYMHasNoSiblingBinary( + const FileSpec &kernel_dsym) { + std::string possible_path = kernel_dsym.GetPath(); + if (!kernel_dsym.GetFilename().GetStringRef().endswith(".dSYM")) + return false; + + FileSpec binary_filespec = kernel_dsym; + std::string filename = binary_filespec.GetFilename().GetCString(); + filename.erase(filename.size() - 5, filename.size()); // chop off '.dSYM' + binary_filespec.GetFilename() = ConstString(filename); + + // Is there a binary next to this this? Then return false. + if (FileSystem::Instance().Exists(binary_filespec)) + return false; + + // If we have at least one binary in the DWARF subdir, then + // this is a properly formed dSYM and it has no binary next + // to it. + if (GetDWARFBinaryInDSYMBundle(kernel_dsym).size() > 0) + return true; + + return false; +} + +// TODO: This method returns a vector of FileSpec's because a +// dSYM bundle may contain multiple DWARF binaries, but it +// only implements returning the base name binary for now; +// it should iterate over every binary in the DWARF subdir +// and return them all. +std::vector<FileSpec> +PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(FileSpec dsym_bundle) { + std::vector<FileSpec> results; + if (!dsym_bundle.GetFilename().GetStringRef().endswith(".dSYM")) { + return results; + } + std::string filename = dsym_bundle.GetFilename().GetCString(); + std::string dirname = dsym_bundle.GetDirectory().GetCString(); + + // get rid of '.dSYM' + filename.erase(filename.size() - 5, filename.size()); + + std::string binary_filepath = dsym_bundle.GetPath(); + binary_filepath += "/Contents/Resources/DWARF/"; + binary_filepath += filename; + + FileSpec binary_fspec(binary_filepath); + if (FileSystem::Instance().Exists(binary_fspec)) + results.push_back(binary_fspec); + return results; +} + Status PlatformDarwinKernel::GetSharedModule( const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, @@ -653,111 +736,176 @@ // Treat the file's path as a kext bundle ID (e.g. // "com.apple.driver.AppleIRController") and search our kext index. std::string kext_bundle_id = platform_file.GetPath(); - if (!kext_bundle_id.empty()) { - ConstString kext_bundle_cs(kext_bundle_id.c_str()); - - // First look through the kext bundles that had a dsym next to them - if (m_name_to_kext_path_map_with_dsyms.count(kext_bundle_cs) > 0) { - for (BundleIDToKextIterator it = - m_name_to_kext_path_map_with_dsyms.begin(); - it != m_name_to_kext_path_map_with_dsyms.end(); ++it) { - if (it->first == kext_bundle_cs) { - error = ExamineKextForMatchingUUID(it->second, module_spec.GetUUID(), - module_spec.GetArchitecture(), - module_sp); - if (module_sp.get()) { - return error; - } - } - } - } + if (!kext_bundle_id.empty() && module_spec.GetUUID().IsValid()) { + if (kext_bundle_id == "mach_kernel") { + return GetSharedModuleKernel(module_spec, process, module_sp, + module_search_paths_ptr, old_module_sp_ptr, + did_create_ptr); + } else { + return GetSharedModuleKext(module_spec, process, module_sp, + module_search_paths_ptr, old_module_sp_ptr, + did_create_ptr); + } + } else { // Give the generic methods, including possibly calling into DebugSymbols // framework on macOS systems, a chance. - error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp, + return PlatformDarwin::GetSharedModule(module_spec, process, module_sp, module_search_paths_ptr, old_module_sp_ptr, did_create_ptr); - if (error.Success() && module_sp.get()) { - return error; + } +} + +Status PlatformDarwinKernel::GetSharedModuleKext( + const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, + const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, + bool *did_create_ptr) { + Status error; + module_sp.reset(); + const FileSpec &platform_file = module_spec.GetFileSpec(); + + // Treat the file's path as a kext bundle ID (e.g. + // "com.apple.driver.AppleIRController") and search our kext index. + ConstString kext_bundle(platform_file.GetPath().c_str()); + // First look through the kext bundles that had a dsym next to them + if (m_name_to_kext_path_map_with_dsyms.count(kext_bundle) > 0) { + for (BundleIDToKextIterator it = m_name_to_kext_path_map_with_dsyms.begin(); + it != m_name_to_kext_path_map_with_dsyms.end(); ++it) { + if (it->first == kext_bundle) { + error = ExamineKextForMatchingUUID(it->second, module_spec.GetUUID(), + module_spec.GetArchitecture(), + module_sp); + if (module_sp.get()) { + return error; + } + } } + } - // Lastly, look through the kext binarys without dSYMs - if (m_name_to_kext_path_map_without_dsyms.count(kext_bundle_cs) > 0) { - for (BundleIDToKextIterator it = - m_name_to_kext_path_map_without_dsyms.begin(); - it != m_name_to_kext_path_map_without_dsyms.end(); ++it) { - if (it->first == kext_bundle_cs) { - error = ExamineKextForMatchingUUID(it->second, module_spec.GetUUID(), - module_spec.GetArchitecture(), - module_sp); - if (module_sp.get()) { + // Give the generic methods, including possibly calling into DebugSymbols + // framework on macOS systems, a chance. + error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp, + module_search_paths_ptr, + old_module_sp_ptr, did_create_ptr); + if (error.Success() && module_sp.get()) { + return error; + } + + // Lastly, look through the kext binarys without dSYMs + if (m_name_to_kext_path_map_without_dsyms.count(kext_bundle) > 0) { + for (BundleIDToKextIterator it = + m_name_to_kext_path_map_without_dsyms.begin(); + it != m_name_to_kext_path_map_without_dsyms.end(); ++it) { + if (it->first == kext_bundle) { + error = ExamineKextForMatchingUUID(it->second, module_spec.GetUUID(), + module_spec.GetArchitecture(), + module_sp); + if (module_sp.get()) { + return error; + } + } + } + } + return error; +} + +Status PlatformDarwinKernel::GetSharedModuleKernel( + const ModuleSpec &module_spec, Process *process, ModuleSP &module_sp, + const FileSpecList *module_search_paths_ptr, ModuleSP *old_module_sp_ptr, + bool *did_create_ptr) { + Status error; + module_sp.reset(); + + // First try all kernel binaries that have a dSYM next to them + for (auto possible_kernel : m_kernel_binaries_with_dsyms) { + if (FileSystem::Instance().Exists(possible_kernel)) { + ModuleSpec kern_spec(possible_kernel); + kern_spec.GetUUID() = module_spec.GetUUID(); + ModuleSP module_sp(new Module(kern_spec)); + if (module_sp && module_sp->GetObjectFile() && + module_sp->MatchesModuleSpec(kern_spec)) { + // module_sp is an actual kernel binary we want to add. + if (process) { + process->GetTarget().GetImages().AppendIfNeeded(module_sp); + error.Clear(); + return error; + } else { + error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, NULL, + NULL); + if (module_sp && module_sp->GetObjectFile() && + module_sp->GetObjectFile()->GetType() != + ObjectFile::Type::eTypeCoreFile) { return error; } + module_sp.reset(); } } } } - if (kext_bundle_id == "mach_kernel" && module_spec.GetUUID().IsValid()) { - // First try all kernel binaries that have a dSYM next to them - for (auto possible_kernel : m_kernel_binaries_with_dsyms) { - if (FileSystem::Instance().Exists(possible_kernel)) { - ModuleSpec kern_spec(possible_kernel); - kern_spec.GetUUID() = module_spec.GetUUID(); - ModuleSP module_sp(new Module(kern_spec)); - if (module_sp && module_sp->GetObjectFile() && - module_sp->MatchesModuleSpec(kern_spec)) { - // module_sp is an actual kernel binary we want to add. - if (process) { - process->GetTarget().GetImages().AppendIfNeeded(module_sp); - error.Clear(); + // Next try all dSYMs that have no kernel binary next to them (load + // the kernel DWARF stub as the main binary) + for (auto possible_kernel_dsym : m_kernel_dsyms_no_binaries) { + std::vector<FileSpec> objfile_names = + GetDWARFBinaryInDSYMBundle(possible_kernel_dsym); + for (FileSpec objfile : objfile_names) { + ModuleSpec kern_spec(objfile); + kern_spec.GetUUID() = module_spec.GetUUID(); + kern_spec.GetSymbolFileSpec() = possible_kernel_dsym; + + ModuleSP module_sp(new Module(kern_spec)); + if (module_sp && module_sp->GetObjectFile() && + module_sp->MatchesModuleSpec(kern_spec)) { + // module_sp is an actual kernel binary we want to add. + if (process) { + process->GetTarget().GetImages().AppendIfNeeded(module_sp); + error.Clear(); + return error; + } else { + error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, NULL, + NULL); + if (module_sp && module_sp->GetObjectFile() && + module_sp->GetObjectFile()->GetType() != + ObjectFile::Type::eTypeCoreFile) { return error; - } else { - error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, - NULL, NULL); - if (module_sp && module_sp->GetObjectFile() && - module_sp->GetObjectFile()->GetType() != - ObjectFile::Type::eTypeCoreFile) { - return error; - } - module_sp.reset(); } + module_sp.reset(); } } } + } - // Give the generic methods, including possibly calling into DebugSymbols - // framework on macOS systems, a chance. - error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp, - module_search_paths_ptr, - old_module_sp_ptr, did_create_ptr); - if (error.Success() && module_sp.get()) { - return error; - } + // Give the generic methods, including possibly calling into DebugSymbols + // framework on macOS systems, a chance. + error = PlatformDarwin::GetSharedModule(module_spec, process, module_sp, + module_search_paths_ptr, + old_module_sp_ptr, did_create_ptr); + if (error.Success() && module_sp.get()) { + return error; + } - // Next try all kernel binaries that don't have a dSYM - for (auto possible_kernel : m_kernel_binaries_without_dsyms) { - if (FileSystem::Instance().Exists(possible_kernel)) { - ModuleSpec kern_spec(possible_kernel); - kern_spec.GetUUID() = module_spec.GetUUID(); - ModuleSP module_sp(new Module(kern_spec)); - if (module_sp && module_sp->GetObjectFile() && - module_sp->MatchesModuleSpec(kern_spec)) { - // module_sp is an actual kernel binary we want to add. - if (process) { - process->GetTarget().GetImages().AppendIfNeeded(module_sp); - error.Clear(); + // Lastly, try all kernel binaries that don't have a dSYM + for (auto possible_kernel : m_kernel_binaries_without_dsyms) { + if (FileSystem::Instance().Exists(possible_kernel)) { + ModuleSpec kern_spec(possible_kernel); + kern_spec.GetUUID() = module_spec.GetUUID(); + ModuleSP module_sp(new Module(kern_spec)); + if (module_sp && module_sp->GetObjectFile() && + module_sp->MatchesModuleSpec(kern_spec)) { + // module_sp is an actual kernel binary we want to add. + if (process) { + process->GetTarget().GetImages().AppendIfNeeded(module_sp); + error.Clear(); + return error; + } else { + error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, NULL, + NULL); + if (module_sp && module_sp->GetObjectFile() && + module_sp->GetObjectFile()->GetType() != + ObjectFile::Type::eTypeCoreFile) { return error; - } else { - error = ModuleList::GetSharedModule(kern_spec, module_sp, NULL, - NULL, NULL); - if (module_sp && module_sp->GetObjectFile() && - module_sp->GetObjectFile()->GetType() != - ObjectFile::Type::eTypeCoreFile) { - return error; - } - module_sp.reset(); } + module_sp.reset(); } } } 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 @@ -517,12 +517,8 @@ Status error; PlatformSP platform_sp( Platform::Create(PlatformDarwinKernel::GetPluginNameStatic(), error)); - // Only select the darwin-kernel Platform if we've been asked to load kexts. - // It can take some time to scan over all of the kext info.plists and that - // shouldn't be done if kext loading is explicitly disabled. - if (platform_sp.get() && GetGlobalProperties()->GetLoadKexts()) { + if (platform_sp.get()) process->GetTarget().SetPlatform(platform_sp); - } } // Destructor
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits