[Lldb-commits] [lldb] r176160 - When starting a kernel debug session, if the user specified an executable

Jason Molenda jmolenda at apple.com
Tue Feb 26 19:07:49 PST 2013


Author: jmolenda
Date: Tue Feb 26 21:07:49 2013
New Revision: 176160

URL: http://llvm.org/viewvc/llvm-project?rev=176160&view=rev
Log:
When starting a kernel debug session, if the user specified an executable
binary to lldb already check that the UUID of that binary and the UUID of
the kernel binary in memory match.  Warn if they don't.
<rdar://problem/13184784> 

Modified:
    lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Modified: lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=176160&r1=176159&r2=176160&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp Tue Feb 26 21:07:49 2013
@@ -668,9 +668,9 @@ DynamicLoaderDarwinKernel::KextImageInfo
         }
     }
 
-    // If the kernel specified what UUID we should find at this load address,
-    // require that the memory module have a matching UUID or something has gone
-    // wrong and we should discard it.
+    // If this is a kext, and the kernel specified what UUID we should find at this 
+    // load address, require that the memory module have a matching UUID or something 
+    // has gone wrong and we should discard it.
     if (m_uuid.IsValid())
     {
         if (m_uuid != memory_module_sp->GetUUID())
@@ -689,10 +689,30 @@ DynamicLoaderDarwinKernel::KextImageInfo
     m_kernel_image = is_kernel;
     if (is_kernel)
     {
-       if (memory_module_sp->GetArchitecture().IsValid())
+        if (memory_module_sp->GetArchitecture().IsValid())
         {
             process->GetTarget().SetArchitecture(memory_module_sp->GetArchitecture());
         }
+        if (m_uuid.IsValid())
+        {
+            Module* exe_module = process->GetTarget().GetExecutableModulePointer();
+            if (exe_module && exe_module->GetUUID().IsValid())
+            {
+                if (m_uuid != exe_module->GetUUID())
+                {
+                    Stream *s = &process->GetTarget().GetDebugger().GetOutputStream();
+                    if (s)
+                    {
+                        char memory_module_uuidbuf[64];
+                        char exe_module_uuidbuf[64];
+                        s->Printf ("warning: Host-side kernel file has Mach-O UUID of %s but remote kernel has a UUID of %s -- a mismatched kernel file will result in a poor debugger experience.\n", 
+                                   exe_module->GetUUID().GetAsCString(exe_module_uuidbuf, sizeof (exe_module_uuidbuf)),
+                                   m_uuid.GetAsCString(memory_module_uuidbuf, sizeof (memory_module_uuidbuf)));
+                        s->Flush ();
+                    }
+                }
+            }
+        }
     }
 
     return true;





More information about the lldb-commits mailing list