diff options
| author | Jason Molenda <jmolenda@apple.com> | 2016-02-06 04:55:26 +0000 |
|---|---|---|
| committer | Jason Molenda <jmolenda@apple.com> | 2016-02-06 04:55:26 +0000 |
| commit | 880988af09bbe6d634959d3b5bb94cf8bd6973cd (patch) | |
| tree | c59eec1929684696cdf12cd5383931751be5da77 /lldb/source/Plugins/Process | |
| parent | bafa729e26923f11c199fb1e2b8d38fbf6f471c2 (diff) | |
| download | bcm5719-llvm-880988af09bbe6d634959d3b5bb94cf8bd6973cd.tar.gz bcm5719-llvm-880988af09bbe6d634959d3b5bb94cf8bd6973cd.zip | |
ProcessMachCore scans through the core file pages looking for a
user process dyld binary and/or a mach kernel binary image. By
default, it prefers the kernel if it finds both.
But if it finds two kernel binary images (which can happen when
random things are mapped into memory), it may pick the wrong
kernel image.
DynamicLoaderDarwinKernel has heuristics to find a kernel in memory;
once we've established that there is a kernel binary in memory,
call over to that class to see if it can find a kernel address via
its search methods. If it does, use that.
Some minor cleanups to DynamicLoaderDarwinKernel while I was at it.
<rdar://problem/24446112>
llvm-svn: 259983
Diffstat (limited to 'lldb/source/Plugins/Process')
| -rw-r--r-- | lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 713b262c650..f11aeb22874 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -335,6 +335,38 @@ ProcessMachCore::DoLoadCore () } } + + if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) + { + // In the case of multiple kernel images found in the core file via exhaustive + // search, we may not pick the correct one. See if the DynamicLoaderDarwinKernel's + // 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()); + } + + addr_t saved_mach_kernel_addr = m_mach_kernel_addr; + m_mach_kernel_addr = LLDB_INVALID_ADDRESS; + addr_t better_kernel_address = DynamicLoaderDarwinKernel::SearchForDarwinKernel (this); + m_mach_kernel_addr = saved_mach_kernel_addr; + if (better_kernel_address != LLDB_INVALID_ADDRESS) + { + if (log) + log->Printf ("ProcessMachCore::DoLoadCore: Using the kernel address from DynamicLoaderDarwinKernel"); + m_mach_kernel_addr = better_kernel_address; + } + } + + // If we found both a user-process dyld and a kernel binary, we need to decide // which to prefer. if (GetCorefilePreference() == eKernelCorefile) |

