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
);
40 case TAG('R', 'o', 's', ' '): /* ROS-INTERNAL */
42 switch ((ULONG
)Context1
)
44 case DumpNonPagedPool
:
45 MiDebugDumpNonPagedPool(FALSE
);
49 KEBUGCHECK(MANUALLY_INITIATED_CRASH
);
52 case DumpNonPagedPoolStats
:
53 MiDebugDumpNonPagedPoolStats(FALSE
);
56 case DumpNewNonPagedPool
:
57 MiDebugDumpNonPagedPool(TRUE
);
60 case DumpNewNonPagedPoolStats
:
61 MiDebugDumpNonPagedPoolStats(TRUE
);
69 PspDumpThreads(FALSE
);
82 HalDisplayString ("Invalid debug service call!\n");
91 KdpEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord
,
92 KPROCESSOR_MODE PreviousMode
,
94 PKTRAP_FRAME TrapFrame
,
98 /* Get out of here if the Debugger isn't enabled */
99 if (!KdDebuggerEnabled
) return kdHandleException
;
102 * Right now, the GDB wrapper seems to handle exceptions differntly
103 * from KDGB and both are called at different times, while the GDB
104 * one is only called once and that's it. I don't really have the knowledge
105 * to fix the GDB stub, so until then, we'll be using this hack
109 /* Call the registered wrapper */
110 if (WrapperInitRoutine
) return WrapperTable
.
111 KdpExceptionRoutine(ExceptionRecord
,
116 /* Call KDBG if available */
117 return KdbEnterDebuggerException(ExceptionRecord
,
124 /* PUBLIC FUNCTIONS *********************************************************/
131 KdDisableDebugger(VOID
)
136 KeRaiseIrql(DISPATCH_LEVEL
, &OldIrql
);
138 /* TODO: Disable any breakpoints */
140 /* Disable the Debugger */
141 KdDebuggerEnabled
= FALSE
;
144 KeLowerIrql(OldIrql
);
152 KdEnableDebugger(VOID
)
157 KeRaiseIrql(DISPATCH_LEVEL
, &OldIrql
);
159 /* TODO: Re-enable any breakpoints */
161 /* Enable the Debugger */
162 KdDebuggerEnabled
= TRUE
;
165 KeLowerIrql(OldIrql
);
175 return KdpBreakPending
;
183 KeEnterKernelDebugger(VOID
)
185 HalDisplayString("\n\n *** Entered kernel debugger ***\n");
187 /* Set the Variable */
188 KdEnteredDebugger
= TRUE
;
191 for (;;) Ke386HaltProcessor();
199 KdPowerTransition(ULONG PowerState
)
202 return STATUS_NOT_IMPLEMENTED
;