Additional fix to my change in r259983 to handle the

case where a core file has a kernel binary and a user
process dyld in the same one.  Without this, we were
always picking the dyld and trying to process it as a
kernel.

<rdar://problem/24446112> 

llvm-svn: 260803
This commit is contained in:
Jason Molenda 2016-02-13 04:15:02 +00:00
parent 93e0200e23
commit 5f826bbc51
1 changed files with 11 additions and 5 deletions

View File

@ -343,21 +343,27 @@ ProcessMachCore::DoLoadCore ()
// search heuristics might identify the correct one.
// Most of the time, I expect the address from SearchForDarwinKernel() will be the
// same as the address we found via exhaustive search.
//
// NB SearchForDarwinKernel will end up calling back into this this class in the GetImageInfoAddress
// method which will give it the m_mach_kernel_addr address it already has. Save that aside
// and set m_mach_kernel_addr to an invalid address temporarily so DynamicLoaderDarwinKernel does
// a real search for the kernel using its own heuristics.
if (GetTarget().GetArchitecture().IsValid() == false && m_core_module_sp.get())
{
GetTarget().SetArchitecture (m_core_module_sp->GetArchitecture());
}
// SearchForDarwinKernel will end up calling back into this this class in the GetImageInfoAddress
// method which will give it the m_mach_kernel_addr/m_dyld_addr it already has. Save that aside
// and set m_mach_kernel_addr/m_dyld_addr to an invalid address temporarily so
// DynamicLoaderDarwinKernel does a real search for the kernel using its own heuristics.
addr_t saved_mach_kernel_addr = m_mach_kernel_addr;
addr_t saved_user_dyld_addr = m_dyld_addr;
m_mach_kernel_addr = LLDB_INVALID_ADDRESS;
m_dyld_addr = LLDB_INVALID_ADDRESS;
addr_t better_kernel_address = DynamicLoaderDarwinKernel::SearchForDarwinKernel (this);
m_mach_kernel_addr = saved_mach_kernel_addr;
m_dyld_addr = saved_user_dyld_addr;
if (better_kernel_address != LLDB_INVALID_ADDRESS)
{
if (log)