Suppress debug exceptions when running under native (lldb/gdb) debugger.
authorMike McLaughlin <mikem@microsoft.com>
Tue, 6 Oct 2015 23:44:07 +0000 (16:44 -0700)
committerMike McLaughlin <mikem@microsoft.com>
Tue, 6 Oct 2015 23:51:57 +0000 (16:51 -0700)
src/pal/src/exception/machexception.cpp

index d51c692..6296ebd 100644 (file)
@@ -133,9 +133,20 @@ static exception_mask_t GetExceptionMask()
 
     if (exMode == MachException_Uninitialized)
     {
+        exMode = MachException_Default;
+
         const char * exceptionSettings = getenv(PAL_MACH_EXCEPTION_MODE);
-        exMode = exceptionSettings
-            ? (MachExceptionMode)atoi(exceptionSettings) : MachException_Default;
+        if (exceptionSettings)
+        {
+            exMode = (MachExceptionMode)atoi(exceptionSettings);
+        }
+        else
+        {
+            if (PAL_IsDebuggerPresent())
+            {
+                exMode = MachException_SuppressDebugging;
+            }
+        }
     }
 
     exception_mask_t machExceptionMask = 0;