Don't load kexts/kernels without dSYMs present
authorJason Molenda <jason@molenda.com>
Sat, 13 Mar 2021 01:18:56 +0000 (17:18 -0800)
committerJason Molenda <jason@molenda.com>
Sat, 13 Mar 2021 01:20:44 +0000 (17:20 -0800)
One of the backup schemes I use for finding kexts and kernels
on the local filesystem is to load a solitary binary when I don't
find any with a dSYM.  This usually is a more confusing behavior
than helpful; people expect to get no binary loaded, or a binary
with debug information.  This change stops loading kexts and
kernels that do not have an associated dSYM.

rdar://74291888

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

index 76ce500..1c68f26 100644 (file)
@@ -791,21 +791,6 @@ Status PlatformDarwinKernel::GetSharedModuleKext(
     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;
 }
 
@@ -884,33 +869,6 @@ Status PlatformDarwinKernel::GetSharedModuleKernel(
     return error;
   }
 
-  // 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();
-      module_sp.reset(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, nullptr,
-                                              nullptr, nullptr);
-          if (module_sp && module_sp->GetObjectFile() &&
-              module_sp->GetObjectFile()->GetType() !=
-                  ObjectFile::Type::eTypeCoreFile) {
-            return error;
-          }
-          module_sp.reset();
-        }
-      }
-    }
-  }
-
   return error;
 }