[Lldb-commits] [lldb] r176405 - ProcessMachCore had (until 2013-01-29) some simple checks to find a kernel
Jason Molenda
jmolenda at apple.com
Fri Mar 1 23:19:32 PST 2013
Author: jmolenda
Date: Sat Mar 2 01:19:32 2013
New Revision: 176405
URL: http://llvm.org/viewvc/llvm-project?rev=176405&view=rev
Log:
ProcessMachCore had (until 2013-01-29) some simple checks to find a kernel
in a core file if it didn't start at the beginning of a memory segment.
I added more sophisticated kernel location code to DynamicLoaderDarwinKernel
and removed the simple one in ProcessMachCore. Unfortunately the kernel
DynamicLoader doesn't get a chance to search around in memory unless there's
a hint that this might be a kernel debug session. It was easy ot make the
kernel location code static in DynamicLoaderDarwinKernel and call it from
ProcessMachCore on the start of the session, so that's what I did.
<rdar://problem/13326647>
Modified:
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=176405&r1=176404&r2=176405&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Sat Mar 2 01:19:32 2013
@@ -177,6 +177,18 @@ DynamicLoaderDarwinKernel::CreateInstanc
// At this point if there is an ExecutableModule, it is a kernel and the Target is some variant of an Apple system.
// If the Process hasn't provided the kernel load address, we need to look around in memory to find it.
+ addr_t kernel_load_address = SearchForDarwinKernel (process);
+ if (kernel_load_address != LLDB_INVALID_ADDRESS)
+ {
+ process->SetCanJIT(false);
+ return new DynamicLoaderDarwinKernel (process, kernel_load_address);
+ }
+ return NULL;
+}
+
+lldb::addr_t
+DynamicLoaderDarwinKernel::SearchForDarwinKernel (Process *process)
+{
addr_t kernel_load_address = process->GetImageInfoAddress();
if (kernel_load_address == LLDB_INVALID_ADDRESS)
{
@@ -194,13 +206,7 @@ DynamicLoaderDarwinKernel::CreateInstanc
}
}
}
-
- if (kernel_load_address != LLDB_INVALID_ADDRESS)
- {
- process->SetCanJIT(false);
- return new DynamicLoaderDarwinKernel (process, kernel_load_address);
- }
- return NULL;
+ return kernel_load_address;
}
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h?rev=176405&r1=176404&r2=176405&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h Sat Mar 2 01:19:32 2013
@@ -52,6 +52,9 @@ public:
DynamicLoaderDarwinKernel (lldb_private::Process *process, lldb::addr_t kernel_addr);
+ static lldb::addr_t
+ SearchForDarwinKernel (lldb_private::Process *process);
+
virtual
~DynamicLoaderDarwinKernel ();
Modified: lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp?rev=176405&r1=176404&r2=176405&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp Sat Mar 2 01:19:32 2013
@@ -299,6 +299,14 @@ ProcessMachCore::DoLoadCore ()
if (arch.IsValid())
m_target.SetArchitecture(arch);
+ if (m_dyld_addr == LLDB_INVALID_ADDRESS)
+ {
+ addr_t kernel_load_address = DynamicLoaderDarwinKernel::SearchForDarwinKernel (this);
+ if (kernel_load_address != LLDB_INVALID_ADDRESS)
+ {
+ GetDynamicLoaderAddress (kernel_load_address);
+ }
+ }
return error;
}
More information about the lldb-commits
mailing list