[Lldb-commits] [lldb] r182513 - <rdar://problem/13956179>

Greg Clayton gclayton at apple.com
Wed May 22 14:00:49 PDT 2013


Author: gclayton
Date: Wed May 22 16:00:49 2013
New Revision: 182513

URL: http://llvm.org/viewvc/llvm-project?rev=182513&view=rev
Log:
<rdar://problem/13956179>

Fixed ProcessMachCore to be able to locate the main executeable in the core file even if it doesn't start at a core file address range boundary. Prior to this we only checked the first bytes of each range in the core file for mach_kernel or dyld. Now we still do this, but if we don't find the mach_kernel or dyld anywhere, we go through all core file ranges and check every 0x1000 to see if we can find dyld or the mach_kernel.

Now that we can properly detect the mach_kernel at any address, we don't need to call "DynamicLoaderDarwinKernel::SearchForDarwinKernel(Process*)" anymore.


Modified:
    lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
    lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp

Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h?rev=182513&r1=182512&r2=182513&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h Wed May 22 16:00:49 2013
@@ -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

Modified: lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp?rev=182513&r1=182512&r2=182513&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp (original)
+++ lldb/trunk/source/Plugins/Process/mach-core/ProcessMachCore.cpp Wed May 22 16:00:49 2013
@@ -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;





More information about the lldb-commits mailing list