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> 

llvm-svn: 176405
This commit is contained in:
Jason Molenda 2013-03-02 07:19:32 +00:00
parent fe7a348614
commit 503d018111
3 changed files with 24 additions and 7 deletions

View File

@ -177,6 +177,18 @@ DynamicLoaderDarwinKernel::CreateInstance (Process* process, bool force)
// 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::CreateInstance (Process* process, bool force)
}
}
}
if (kernel_load_address != LLDB_INVALID_ADDRESS)
{
process->SetCanJIT(false);
return new DynamicLoaderDarwinKernel (process, kernel_load_address);
}
return NULL;
return kernel_load_address;
}
//----------------------------------------------------------------------

View File

@ -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 ();

View File

@ -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;
}