[Lldb-commits] [lldb] r152077 - in /lldb/trunk/tools/debugserver/source/MacOSX: MachException.cpp MachException.h MachTask.cpp

Greg Clayton gclayton at apple.com
Mon Mar 5 16:24:17 PST 2012


Author: gclayton
Date: Mon Mar  5 18:24:17 2012
New Revision: 152077

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

Safeguard against building on next OS and run on current OS.


Modified:
    lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp
    lldb/trunk/tools/debugserver/source/MacOSX/MachException.h
    lldb/trunk/tools/debugserver/source/MacOSX/MachTask.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=152077&r1=152076&r2=152077&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachException.cpp Mon Mar  5 18:24:17 2012
@@ -486,23 +486,26 @@
     // and back off to just what is supported on the current system
     DNBError err;
 
-    exception_mask_t exception_mask = EXC_MASK_ALL;
+    mask = EXC_MASK_ALL;
 
     count = (sizeof (ports) / sizeof (ports[0]));
-    err = ::task_get_exception_ports (task, exception_mask, masks, &count, ports, behaviors, flavors);
+    err = ::task_get_exception_ports (task, 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);
+        err.LogThreaded("::task_get_exception_ports ( task = 0x%4.4x, mask = 0x%x, maskCnt => %u, ports, behaviors, flavors )", task, mask, count);
 
-    if (err.Error() == KERN_INVALID_ARGUMENT && exception_mask != PREV_EXC_MASK_ALL)
+    if (err.Error() == KERN_INVALID_ARGUMENT && mask != PREV_EXC_MASK_ALL)
     {
-        exception_mask = PREV_EXC_MASK_ALL;
+        mask = PREV_EXC_MASK_ALL;
         count = (sizeof (ports) / sizeof (ports[0]));
-        err = ::task_get_exception_ports (task, exception_mask, masks, &count, ports, behaviors, flavors);
+        err = ::task_get_exception_ports (task, 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);
+            err.LogThreaded("::task_get_exception_ports ( task = 0x%4.4x, mask = 0x%x, maskCnt => %u, ports, behaviors, flavors )", task, mask, count);
     }
     if (err.Fail())
+    {
+        mask = 0;
         count = 0;
+    }
     return err.Error();
 }
 

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachException.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachException.h?rev=152077&r1=152076&r2=152077&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachException.h (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachException.h Mon Mar  5 18:24:17 2012
@@ -35,6 +35,7 @@
 
     struct PortInfo
     {
+        exception_mask_t        mask; // the exception mask for this device which may be a subset of EXC_MASK_ALL...
         exception_mask_t        masks[EXC_TYPES_COUNT];
         mach_port_t             ports[EXC_TYPES_COUNT];
         exception_behavior_t    behaviors[EXC_TYPES_COUNT];

Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp?rev=152077&r1=152076&r2=152077&view=diff
==============================================================================
--- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp (original)
+++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp Mon Mar  5 18:24:17 2012
@@ -367,8 +367,25 @@
         // Save the original state of the exception ports for our child process
         SaveExceptionPortInfo();
 
+        // We weren't able to save the info for our exception ports, we must stop...
+        if (m_exc_port_info.mask == 0)
+        {
+            err.SetErrorString("failed to get exception port info");
+            return false;
+        }
+
         // Set the ability to get all exceptions on this port
-        err = ::task_set_exception_ports (task, EXC_MASK_ALL, m_exception_port, EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES, THREAD_STATE_NONE);
+        err = ::task_set_exception_ports (task, m_exc_port_info.mask, m_exception_port, EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES, THREAD_STATE_NONE);
+        if (DNBLogCheckLogBit(LOG_EXCEPTIONS) || err.Fail())
+        {
+            err.LogThreaded("::task_set_exception_ports ( task = 0x%4.4x, exception_mask = 0x%8.8x, new_port = 0x%4.4x, behavior = 0x%8.8x, new_flavor = 0x%8.8x )",
+                            task,
+                            m_exc_port_info.mask,
+                            m_exception_port,
+                            (EXCEPTION_DEFAULT | MACH_EXCEPTION_CODES),
+                            THREAD_STATE_NONE);
+        }
+
         if (err.Fail())
             return false;
 





More information about the lldb-commits mailing list