- Fix KiDispatchException to unmask KI_EXCEPTION_INTERNAL when setting the exception...
[reactos.git] / reactos / ntoskrnl / ke / i386 / exp.c
index bf10539..500a1db 100644 (file)
@@ -90,7 +90,7 @@ KiUpdateDr7(IN ULONG Dr7)
     ULONG DebugMask = KeGetCurrentThread()->DispatcherHeader.DebugActive;
 
     /* Check if debugging is enabled */
-    if (DebugMask & DR_ACTIVE_MASK)
+    if (DebugMask & DR_MASK(DR7_OVERRIDE_V))
     {
         /* Sanity checks */
         ASSERT((DebugMask & DR_REG_MASK) != 0);
@@ -133,11 +133,11 @@ KiRecordDr7(OUT PULONG Dr7Ptr,
         Result = FALSE;
 
         /* Check the DR mask */
-        NewMask &= 0x7F;
+        NewMask &= ~(DR_MASK(7));
         if (NewMask & DR_REG_MASK)
         {
             /* Set the active mask */
-            NewMask |= DR_ACTIVE_MASK;
+            NewMask |= DR_MASK(DR7_OVERRIDE_V);
 
             /* Set DR7 override */
             *DrMask = DR7_OVERRIDE_MASK;
@@ -154,8 +154,8 @@ KiRecordDr7(OUT PULONG Dr7Ptr,
         Result = NewMask ? TRUE: FALSE;
 
         /* Update the mask to disable debugging */
-        NewMask &= ~DR_ACTIVE_MASK;
-        NewMask |= 0x80;
+        NewMask &= ~(DR_MASK(DR7_OVERRIDE_V));
+        NewMask |= DR_MASK(7);
     }
 
     /* Check if caller wants the new mask */
@@ -800,7 +800,7 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
     /* Set the context flags */
     Context.ContextFlags = CONTEXT_FULL | CONTEXT_DEBUG_REGISTERS;
 
-    /* Check if User Mode or if the debugger is enabled */
+    /* Check if User Mode or if the debugger isenabled */
     if ((PreviousMode == UserMode) || (KdDebuggerEnabled))
     {
         /* Add the FPU Flag */
@@ -846,6 +846,9 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
                 goto Handled;
             }
 
+            /* HACK: GDB Entry */
+            if (KdpCallGdb(TrapFrame, ExceptionRecord, &Context)) goto Handled;
+
             /* If the Debugger couldn't handle it, dispatch the exception */
             if (RtlDispatchException(ExceptionRecord, &Context)) goto Handled;
         }
@@ -891,6 +894,9 @@ KiDispatchException(IN PEXCEPTION_RECORD ExceptionRecord,
                 goto Handled;
             }
 
+            /* HACK: GDB Entry */
+            if (KdpCallGdb(TrapFrame, ExceptionRecord, &Context)) goto Handled;
+
             /* Forward exception to user mode debugger */
             if (DbgkForwardException(ExceptionRecord, TRUE, FALSE)) goto Exit;
 
@@ -1040,5 +1046,3 @@ KeRaiseUserException(IN NTSTATUS ExceptionCode)
     return (NTSTATUS)OldEip;
 }
 
-
-