diff options
-rw-r--r-- | lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h | 6 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp | 23 |
2 files changed, 23 insertions, 6 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h index c34ac6562ab..8091710fb2d 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h @@ -52,9 +52,6 @@ public: DynamicLoaderDarwinKernel (lldb_private::Process *process, lldb::addr_t kernel_addr); - static lldb::addr_t - SearchForDarwinKernel (lldb_private::Process *process); - virtual ~DynamicLoaderDarwinKernel (); @@ -344,6 +341,9 @@ protected: KextImageInfo::collection &image_infos); static lldb::addr_t + SearchForDarwinKernel (lldb_private::Process *process); + + static lldb::addr_t SearchForKernelAtSameLoadAddr (lldb_private::Process *process); static lldb::addr_t diff --git a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp index 8fc87296d75..7ede3fcfe76 100644 --- a/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp +++ b/lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp @@ -32,6 +32,7 @@ #include "ThreadMachCore.h" #include "StopInfoMachException.h" +// Needed for the plug-in names for the dynamic loaders. #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" @@ -296,10 +297,26 @@ ProcessMachCore::DoLoadCore () if (m_dyld_addr == LLDB_INVALID_ADDRESS) { - addr_t kernel_load_address = DynamicLoaderDarwinKernel::SearchForDarwinKernel (this); - if (kernel_load_address != LLDB_INVALID_ADDRESS) + // We need to locate the main executable in the memory ranges + // we have in the core file. We already checked the first address + // in each memory zone above, so we just need to check each page + // except the first page in each range and stop once we have found + // our main executable + const size_t num_core_aranges = m_core_aranges.GetSize(); + for (size_t i=0; i<num_core_aranges && m_dyld_addr == LLDB_INVALID_ADDRESS; ++i) { - GetDynamicLoaderAddress (kernel_load_address); + const VMRangeToFileOffset::Entry *entry = m_core_aranges.GetEntryAtIndex(i); + lldb::addr_t section_vm_addr_start = entry->GetRangeBase(); + lldb::addr_t section_vm_addr_end = entry->GetRangeEnd(); + for (lldb::addr_t section_vm_addr = section_vm_addr_start + 0x1000; + section_vm_addr < section_vm_addr_end; + section_vm_addr += 0x1000) + { + if (GetDynamicLoaderAddress (section_vm_addr)) + { + break; + } + } } } return error; |