Commit in reactos/ntoskrnl on MAIN
ke/catch.c+23-171.53 -> 1.54
dbg/kdb.c+40-21.34 -> 1.35
+63-19
2 modified files
Changed kdbg a bit by adding some new flags (and a new command):
condition [all|umode|kmode]

condition all -> Handle all exceptions.  This is like the current kdbg
condition umode -> Handle unhandled usermode exceptions and all kmode 
	exceptions.
condition kmode -> Handle only unhandled kernelmode exceptions (default)

reactos/ntoskrnl/ke
catch.c 1.53 -> 1.54
diff -u -r1.53 -r1.54
--- catch.c	14 Nov 2004 16:00:02 -0000	1.53
+++ catch.c	18 Nov 2004 02:10:28 -0000	1.54
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: catch.c,v 1.53 2004/11/14 16:00:02 blight Exp $
+/* $Id: catch.c,v 1.54 2004/11/18 02:10:28 arty Exp $
  *
  * PROJECT:              ReactOS kernel
  * FILE:                 ntoskrnl/ke/catch.c
@@ -76,17 +76,8 @@
     {
       Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
     }
-#ifdef KDBG
-  else if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_KDB)
-    {
-      Action = KdbEnterDebuggerException (ExceptionRecord, Context, Tf);
-    }
-#endif /* KDBG */
-  if (Action == kdContinue)
-    {
-      return;
-    }
-  else if (Action != kdDoNotHandleException)
+
+  if (Action != kdDoNotHandleException)
     {
       if (PreviousMode == UserMode)
 	{
@@ -98,6 +89,11 @@
 	      PULONG pNewUserStack = (PULONG)(Tf->Esp - (12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT)));
 	      NTSTATUS StatusOfCopy;
 
+#ifdef KDBG
+	      KdbEnterDebuggerException (ExceptionRecord, PreviousMode, 
+					 Context, Tf, FALSE);
+#endif
+
 	      /* FIXME: Forward exception to user mode debugger */
 
 	      /* FIXME: Check user mode stack for enough space */
@@ -139,17 +135,23 @@
 
 	  /* FIXME: Forward the exception to the process exception port */
 
+#ifdef KDBG
+	  KdbEnterDebuggerException (ExceptionRecord, PreviousMode, 
+				     Context, Tf, TRUE);
+#endif
+
 	  /* Terminate the offending thread */
 	  DPRINT1("Unhandled UserMode exception, terminating thread\n");
 	  ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode);
-
-	  /* If that fails then bugcheck */
-	  DPRINT1("Could not terminate thread\n");
-	  KEBUGCHECK(KMODE_EXCEPTION_NOT_HANDLED);
 	}
       else
 	{
 	  /* PreviousMode == KernelMode */
+#ifdef KDBG
+	  KdbEnterDebuggerException (ExceptionRecord, PreviousMode, 
+				     Context, Tf, FALSE);
+#endif
+
 	  Value = RtlpDispatchException (ExceptionRecord, Context);
 	  
 	  DPRINT("RtlpDispatchException() returned with 0x%X\n", Value);
@@ -162,7 +164,11 @@
 	    {
 	      DPRINT("ExceptionRecord->ExceptionAddress = 0x%x\n",
 		     ExceptionRecord->ExceptionAddress );
-              KEBUGCHECKWITHTF(KMODE_EXCEPTION_NOT_HANDLED, 0, 0, 0, 0, Tf);
+#ifdef KDBG
+	      KdbEnterDebuggerException (ExceptionRecord, PreviousMode, 
+					 Context, Tf, TRUE); 
+#endif
+	      KEBUGCHECKWITHTF(KMODE_EXCEPTION_NOT_HANDLED, 0, 0, 0, 0, Tf);
 	    }
 	}
     }

reactos/ntoskrnl/dbg
kdb.c 1.34 -> 1.35
diff -u -r1.34 -r1.35
--- kdb.c	10 Nov 2004 23:16:16 -0000	1.34
+++ kdb.c	18 Nov 2004 02:10:28 -0000	1.35
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: kdb.c,v 1.34 2004/11/10 23:16:16 blight Exp $
+/* $Id: kdb.c,v 1.35 2004/11/18 02:10:28 arty Exp $
  *
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/dbg/kdb.c
@@ -58,6 +58,8 @@
 static KDB_ACTIVE_BREAKPOINT 
  KdbActiveBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT];
 
+static BOOLEAN KdbHandleUmode = FALSE;
+static BOOLEAN KdbHandleHandled = FALSE;
 static BOOLEAN KdbIgnoreNextSingleStep = FALSE;
 
 static ULONG KdbLastSingleStepFrom = 0xFFFFFFFF;
@@ -70,6 +72,8 @@
 PsDumpThreads(BOOLEAN System);
 ULONG 
 DbgContCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
+ULONG 
+DbgStopCondition(ULONG Aargc, PCH Argv[], PKTRAP_FRAME Tf);
 ULONG
 DbgEchoToggle(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
 ULONG 
@@ -124,6 +128,8 @@
 } DebuggerCommands[] = {
   {"cont", "cont", "Exit the debugger", DbgContCommand},
   {"echo", "echo", "Toggle serial echo", DbgEchoToggle},
+  {"condition", "condition [all|umode|kmode]", "Kdbg enter condition", DbgStopCondition},
+   
   {"regs", "regs", "Display general purpose registers", DbgRegsCommand},
   {"dregs", "dregs", "Display debug registers", DbgDRegsCommand},
   {"cregs", "cregs", "Display control registers", DbgCRegsCommand},
@@ -1329,6 +1335,24 @@
 }
 
 ULONG
+DbgStopCondition(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
+{
+    if( Argc == 1 ) {
+	if( KdbHandleHandled ) DbgPrint("all\n");
+	else if( KdbHandleUmode ) DbgPrint("umode\n");
+	else DbgPrint("kmode\n");
+    } 
+    else if( !strcmp(Argv[1],"all") ) 
+    { KdbHandleHandled = TRUE; KdbHandleUmode = TRUE; }
+    else if( !strcmp(Argv[1],"umode") )
+    { KdbHandleHandled = FALSE; KdbHandleUmode = TRUE; }
+    else if( !strcmp(Argv[1],"kmode") )
+    { KdbHandleHandled = FALSE; KdbHandleUmode = FALSE; }
+
+    return(TRUE);
+}
+
+ULONG
 DbgEchoToggle(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
 {
   KbdEchoOn = !KbdEchoOn;
@@ -1624,12 +1648,26 @@
 
 KD_CONTINUE_TYPE
 KdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
+			  KPROCESSOR_MODE PreviousMode,
 			  PCONTEXT Context,
-			  PKTRAP_FRAME TrapFrame)
+			  PKTRAP_FRAME TrapFrame,
+			  BOOLEAN AlwaysHandle)
 {
   LONG BreakPointNr;
   ULONG ExpNr = (ULONG)TrapFrame->DebugArgMark;
 
+  DbgPrint( ":KDBG:Entered:%s:%s\n", 
+	    PreviousMode==KernelMode ? "kmode" : "umode",
+	    AlwaysHandle ? "always" : "if-unhandled" );
+  
+  /* If we aren't handling umode exceptions then return */
+  if( PreviousMode == UserMode && !KdbHandleUmode && !AlwaysHandle )
+      return kdContinue;
+
+  /* If the exception would be unhandled (and we care) then handle it */
+  if( PreviousMode == KernelMode && !KdbHandleHandled && !AlwaysHandle )
+      return kdContinue;
+
   /* Exception inside the debugger? Game over. */
   if (KdbEntryCount > 0)
     {
CVSspam 0.2.8