Allow DynamicLoaderDarwinKernel to activate without binary
authorJason Molenda <jason@molenda.com>
Mon, 10 Oct 2022 17:15:43 +0000 (10:15 -0700)
committerJason Molenda <jason@molenda.com>
Mon, 10 Oct 2022 17:19:09 +0000 (10:19 -0700)
In https://reviews.llvm.org/D133534 I made a little cleanup
to DynamicLoaderDarwinKernel::CreateInstance and unintentionally
changed the logic.  Previously it would not create an instance
if there was a binary given to lldb and it was not a kernel.
With my change, the absence of any binary would also cause it
to not create.  So connecting to a kernel without any binaries
would fail.

rdar://100985097

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

index 533585a..b0617ce 100644 (file)
@@ -152,7 +152,8 @@ DynamicLoader *DynamicLoaderDarwinKernel::CreateInstance(Process *process,
   if (!force) {
     // If the user provided an executable binary and it is not a kernel, this
     // plugin should not create an instance.
-    if (!is_kernel(process->GetTarget().GetExecutableModulePointer()))
+    Module *exec = process->GetTarget().GetExecutableModulePointer();
+    if (exec && !is_kernel(exec))
       return nullptr;
 
     // If the target's architecture does not look like an Apple environment,