From 503d018111155a7ac2a64fb84e2d9be6461b940f Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Sat, 2 Mar 2013 07:19:32 +0000 Subject: [PATCH] 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. llvm-svn: 176405 --- .../Darwin-Kernel/DynamicLoaderDarwinKernel.cpp | 20 +++++++++++++------- .../Darwin-Kernel/DynamicLoaderDarwinKernel.h | 3 +++ .../Plugins/Process/mach-core/ProcessMachCore.cpp | 8 ++++++++ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index afa81cb..2e865c1 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -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; } //---------------------------------------------------------------------- diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h index d3d3662..d65622c 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h @@ -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 (); diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 66f5081..0e19ebe 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -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; } -- 2.7.4