* 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
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;
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
} 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},
return(0);
}
+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)
{
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)
{
* 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
{
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)
{
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 */
/* 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);
{
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);
}
}
}