2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel
4 * FILE: ntoskrnl/kd/kdinit.c
5 * PURPOSE: Kernel Debugger Initializtion
7 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
12 #include <internal/debug.h>
14 /* VARIABLES ***************************************************************/
16 BOOLEAN EXPORTED KdDebuggerEnabled
= FALSE
;
17 BOOLEAN EXPORTED KdEnteredDebugger
= FALSE
;
18 BOOLEAN EXPORTED KdDebuggerNotPresent
= TRUE
;
19 BOOLEAN EXPORTED KiEnableTimerWatchdog
= FALSE
;
20 ULONG EXPORTED KiBugCheckData
;
21 BOOLEAN KdpBreakPending
;
22 VOID STDCALL
PspDumpThreads(BOOLEAN SystemThreads
);
24 /* PRIVATE FUNCTIONS *********************************************************/
28 KdpServiceDispatcher(ULONG Service
,
36 case 1: /* DbgPrint */
37 Result
= KdpPrintString ((PANSI_STRING
)Context1
);
41 case TAG('R', 'o', 's', ' '): /* ROS-INTERNAL */
43 switch ((ULONG
)Context1
)
45 case DumpNonPagedPool
:
46 MiDebugDumpNonPagedPool(FALSE
);
50 KEBUGCHECK(MANUALLY_INITIATED_CRASH
);
53 case DumpNonPagedPoolStats
:
54 MiDebugDumpNonPagedPoolStats(FALSE
);
57 case DumpNewNonPagedPool
:
58 MiDebugDumpNonPagedPool(TRUE
);
61 case DumpNewNonPagedPoolStats
:
62 MiDebugDumpNonPagedPoolStats(TRUE
);
70 PspDumpThreads(FALSE
);
83 HalDisplayString ("Invalid debug service call!\n");
92 KdpEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord
,
93 KPROCESSOR_MODE PreviousMode
,
95 PKTRAP_FRAME TrapFrame
,
99 /* Get out of here if the Debugger isn't enabled */
100 if (!KdDebuggerEnabled
) return kdHandleException
;
103 * Right now, the GDB wrapper seems to handle exceptions differntly
104 * from KDGB and both are called at different times, while the GDB
105 * one is only called once and that's it. I don't really have the knowledge
106 * to fix the GDB stub, so until then, we'll be using this hack
110 /* Call the registered wrapper */
111 if (WrapperInitRoutine
) return WrapperTable
.
112 KdpExceptionRoutine(ExceptionRecord
,
117 /* Call KDBG if available */
118 return KdbEnterDebuggerException(ExceptionRecord
,
125 /* PUBLIC FUNCTIONS *********************************************************/
132 KdDisableDebugger(VOID
)
137 KeRaiseIrql(DISPATCH_LEVEL
, &OldIrql
);
139 /* TODO: Disable any breakpoints */
141 /* Disable the Debugger */
142 KdDebuggerEnabled
= FALSE
;
145 KeLowerIrql(OldIrql
);
153 KdEnableDebugger(VOID
)
158 KeRaiseIrql(DISPATCH_LEVEL
, &OldIrql
);
160 /* TODO: Re-enable any breakpoints */
162 /* Enable the Debugger */
163 KdDebuggerEnabled
= TRUE
;
166 KeLowerIrql(OldIrql
);
176 return KdpBreakPending
;
184 KeEnterKernelDebugger(VOID
)
186 HalDisplayString("\n\n *** Entered kernel debugger ***\n");
188 /* Set the Variable */
189 KdEnteredDebugger
= TRUE
;
192 for (;;) Ke386HaltProcessor();
200 KdPowerTransition(ULONG PowerState
)
203 return STATUS_NOT_IMPLEMENTED
;