[Lldb-commits] [lldb] r151827 - /lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp

Greg Clayton gclayton at apple.com
Thu Mar 1 11:35:09 PST 2012


Author: gclayton
Date: Thu Mar  1 13:35:09 2012
New Revision: 151827

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

Allow debugserver to be built on a newer kernel and still allow debugging on
older kernels.


Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp?rev=151827&r1=151826&r2=151827&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp Thu Mar  1 13:35:09 2012
@@ -465,16 +465,42 @@
     }
 }
 
+#define PREV_EXC_MASK_ALL (EXC_MASK_BAD_ACCESS      | \
+                           EXC_MASK_BAD_INSTRUCTION | \
+                           EXC_MASK_ARITHMETIC      | \
+                           EXC_MASK_EMULATION       | \
+                           EXC_MASK_SOFTWARE        | \
+                           EXC_MASK_BREAKPOINT      | \
+                           EXC_MASK_SYSCALL         | \
+                           EXC_MASK_MACH_SYSCALL    | \
+                           EXC_MASK_RPC_ALERT       | \
+                           EXC_MASK_MACHINE)
+
 
 kern_return_t
 MachException::PortInfo::Save (task_t task)
 {
-    count = (sizeof (ports) / sizeof (ports[0]));
     DNBLogThreadedIf(LOG_EXCEPTIONS | LOG_VERBOSE, "MachException::PortInfo::Save ( task = 0x%4.4x )", task);
+    // Be careful to be able to have debugserver built on a newer OS than what
+    // it is currently running on by being able to start with all exceptions
+    // and back off to just what is supported on the current system
     DNBError err;
-    err = ::task_get_exception_ports (task, EXC_MASK_ALL, masks, &count, ports, behaviors, flavors);
+
+    exception_mask_t exception_mask = EXC_MASK_ALL;
+
+    count = (sizeof (ports) / sizeof (ports[0]));
+    err = ::task_get_exception_ports (task, exception_mask, masks, &count, ports, behaviors, flavors);
     if (DNBLogCheckLogBit(LOG_EXCEPTIONS) || err.Fail())
-        err.LogThreaded("::task_get_exception_ports ( task = 0x%4.4x, mask = 0x%x, maskCnt => %u, ports, behaviors, flavors )", task, EXC_MASK_ALL, count);
+        err.LogThreaded("::task_get_exception_ports ( task = 0x%4.4x, mask = 0x%x, maskCnt => %u, ports, behaviors, flavors )", task, exception_mask, count);
+
+    if (err.Error() == KERN_INVALID_ARGUMENT && exception_mask != PREV_EXC_MASK_ALL)
+    {
+        exception_mask = PREV_EXC_MASK_ALL;
+        count = (sizeof (ports) / sizeof (ports[0]));
+        err = ::task_get_exception_ports (task, exception_mask, masks, &count, ports, behaviors, flavors);
+        if (DNBLogCheckLogBit(LOG_EXCEPTIONS) || err.Fail())
+            err.LogThreaded("::task_get_exception_ports ( task = 0x%4.4x, mask = 0x%x, maskCnt => %u, ports, behaviors, flavors )", task, exception_mask, count);
+    }
     if (err.Fail())
         count = 0;
     return err.Error();





More information about the lldb-commits mailing list