mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
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) svn path=/trunk/; revision=11692
This commit is contained in:
parent
4af944d53d
commit
a2f6011b3d
2 changed files with 63 additions and 19 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* 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
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/dbg/kdb.c
|
* FILE: ntoskrnl/dbg/kdb.c
|
||||||
|
@ -58,6 +58,8 @@ static ULONG KdbBreakPointCount = 0;
|
||||||
static KDB_ACTIVE_BREAKPOINT
|
static KDB_ACTIVE_BREAKPOINT
|
||||||
KdbActiveBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT];
|
KdbActiveBreakPoints[KDB_MAXIMUM_BREAKPOINT_COUNT];
|
||||||
|
|
||||||
|
static BOOLEAN KdbHandleUmode = FALSE;
|
||||||
|
static BOOLEAN KdbHandleHandled = FALSE;
|
||||||
static BOOLEAN KdbIgnoreNextSingleStep = FALSE;
|
static BOOLEAN KdbIgnoreNextSingleStep = FALSE;
|
||||||
|
|
||||||
static ULONG KdbLastSingleStepFrom = 0xFFFFFFFF;
|
static ULONG KdbLastSingleStepFrom = 0xFFFFFFFF;
|
||||||
|
@ -70,6 +72,8 @@ VOID
|
||||||
PsDumpThreads(BOOLEAN System);
|
PsDumpThreads(BOOLEAN System);
|
||||||
ULONG
|
ULONG
|
||||||
DbgContCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
|
DbgContCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
|
||||||
|
ULONG
|
||||||
|
DbgStopCondition(ULONG Aargc, PCH Argv[], PKTRAP_FRAME Tf);
|
||||||
ULONG
|
ULONG
|
||||||
DbgEchoToggle(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
|
DbgEchoToggle(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf);
|
||||||
ULONG
|
ULONG
|
||||||
|
@ -124,6 +128,8 @@ struct
|
||||||
} DebuggerCommands[] = {
|
} DebuggerCommands[] = {
|
||||||
{"cont", "cont", "Exit the debugger", DbgContCommand},
|
{"cont", "cont", "Exit the debugger", DbgContCommand},
|
||||||
{"echo", "echo", "Toggle serial echo", DbgEchoToggle},
|
{"echo", "echo", "Toggle serial echo", DbgEchoToggle},
|
||||||
|
{"condition", "condition [all|umode|kmode]", "Kdbg enter condition", DbgStopCondition},
|
||||||
|
|
||||||
{"regs", "regs", "Display general purpose registers", DbgRegsCommand},
|
{"regs", "regs", "Display general purpose registers", DbgRegsCommand},
|
||||||
{"dregs", "dregs", "Display debug registers", DbgDRegsCommand},
|
{"dregs", "dregs", "Display debug registers", DbgDRegsCommand},
|
||||||
{"cregs", "cregs", "Display control registers", DbgCRegsCommand},
|
{"cregs", "cregs", "Display control registers", DbgCRegsCommand},
|
||||||
|
@ -1328,6 +1334,24 @@ DbgContCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
|
||||||
return(0);
|
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
|
ULONG
|
||||||
DbgEchoToggle(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
|
DbgEchoToggle(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf)
|
||||||
{
|
{
|
||||||
|
@ -1624,12 +1648,26 @@ KdbInternalEnter(PKTRAP_FRAME Tf)
|
||||||
|
|
||||||
KD_CONTINUE_TYPE
|
KD_CONTINUE_TYPE
|
||||||
KdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
|
KdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
|
KPROCESSOR_MODE PreviousMode,
|
||||||
PCONTEXT Context,
|
PCONTEXT Context,
|
||||||
PKTRAP_FRAME TrapFrame)
|
PKTRAP_FRAME TrapFrame,
|
||||||
|
BOOLEAN AlwaysHandle)
|
||||||
{
|
{
|
||||||
LONG BreakPointNr;
|
LONG BreakPointNr;
|
||||||
ULONG ExpNr = (ULONG)TrapFrame->DebugArgMark;
|
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. */
|
/* Exception inside the debugger? Game over. */
|
||||||
if (KdbEntryCount > 0)
|
if (KdbEntryCount > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* 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
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/catch.c
|
* FILE: ntoskrnl/ke/catch.c
|
||||||
|
@ -76,17 +76,8 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
{
|
{
|
||||||
Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
|
Action = KdEnterDebuggerException (ExceptionRecord, Context, Tf);
|
||||||
}
|
}
|
||||||
#ifdef KDBG
|
|
||||||
else if (KdDebuggerEnabled && KdDebugState & KD_DEBUG_KDB)
|
if (Action != kdDoNotHandleException)
|
||||||
{
|
|
||||||
Action = KdbEnterDebuggerException (ExceptionRecord, Context, Tf);
|
|
||||||
}
|
|
||||||
#endif /* KDBG */
|
|
||||||
if (Action == kdContinue)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (Action != kdDoNotHandleException)
|
|
||||||
{
|
{
|
||||||
if (PreviousMode == UserMode)
|
if (PreviousMode == UserMode)
|
||||||
{
|
{
|
||||||
|
@ -98,6 +89,11 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
PULONG pNewUserStack = (PULONG)(Tf->Esp - (12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT)));
|
PULONG pNewUserStack = (PULONG)(Tf->Esp - (12 + sizeof(EXCEPTION_RECORD) + sizeof(CONTEXT)));
|
||||||
NTSTATUS StatusOfCopy;
|
NTSTATUS StatusOfCopy;
|
||||||
|
|
||||||
|
#ifdef KDBG
|
||||||
|
KdbEnterDebuggerException (ExceptionRecord, PreviousMode,
|
||||||
|
Context, Tf, FALSE);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* FIXME: Forward exception to user mode debugger */
|
/* FIXME: Forward exception to user mode debugger */
|
||||||
|
|
||||||
/* FIXME: Check user mode stack for enough space */
|
/* FIXME: Check user mode stack for enough space */
|
||||||
|
@ -139,17 +135,23 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
|
|
||||||
/* FIXME: Forward the exception to the process exception port */
|
/* FIXME: Forward the exception to the process exception port */
|
||||||
|
|
||||||
|
#ifdef KDBG
|
||||||
|
KdbEnterDebuggerException (ExceptionRecord, PreviousMode,
|
||||||
|
Context, Tf, TRUE);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Terminate the offending thread */
|
/* Terminate the offending thread */
|
||||||
DPRINT1("Unhandled UserMode exception, terminating thread\n");
|
DPRINT1("Unhandled UserMode exception, terminating thread\n");
|
||||||
ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode);
|
ZwTerminateThread(NtCurrentThread(), ExceptionRecord->ExceptionCode);
|
||||||
|
|
||||||
/* If that fails then bugcheck */
|
|
||||||
DPRINT1("Could not terminate thread\n");
|
|
||||||
KEBUGCHECK(KMODE_EXCEPTION_NOT_HANDLED);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* PreviousMode == KernelMode */
|
/* PreviousMode == KernelMode */
|
||||||
|
#ifdef KDBG
|
||||||
|
KdbEnterDebuggerException (ExceptionRecord, PreviousMode,
|
||||||
|
Context, Tf, FALSE);
|
||||||
|
#endif
|
||||||
|
|
||||||
Value = RtlpDispatchException (ExceptionRecord, Context);
|
Value = RtlpDispatchException (ExceptionRecord, Context);
|
||||||
|
|
||||||
DPRINT("RtlpDispatchException() returned with 0x%X\n", Value);
|
DPRINT("RtlpDispatchException() returned with 0x%X\n", Value);
|
||||||
|
@ -162,7 +164,11 @@ KiDispatchException(PEXCEPTION_RECORD ExceptionRecord,
|
||||||
{
|
{
|
||||||
DPRINT("ExceptionRecord->ExceptionAddress = 0x%x\n",
|
DPRINT("ExceptionRecord->ExceptionAddress = 0x%x\n",
|
||||||
ExceptionRecord->ExceptionAddress );
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue