-/* $Id: kdebug.c,v 1.39 2002/09/07 15:12:53 chorns Exp $
+/* $Id: kdebug.c,v 1.46 2003/08/11 18:50:12 chorns Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* 21/10/99: Created
*/
-#include <ntoskrnl.h>
+#include <ddk/ntddk.h>
+#include <internal/ntoskrnl.h>
+#include <internal/kd.h>
+#include <internal/mm.h>
+#include <roscfg.h>
#include "../dbg/kdb.h"
-#define NDEBUG
-#include <internal/debug.h>
-
-
/* serial debug connection */
#define DEFAULT_DEBUG_PORT 2 /* COM2 */
#define DEFAULT_DEBUG_COM1_IRQ 4 /* COM1 IRQ */
/* VARIABLES ***************************************************************/
BOOLEAN
-KdpDebuggerEnabled = FALSE;
-
-PBOOLEAN
__declspec(dllexport)
-KdDebuggerEnabled = &KdpDebuggerEnabled;
+KdDebuggerEnabled = FALSE; /* EXPORTED */
BOOLEAN
-KdpDebuggerNotPresent = TRUE;
-
-PBOOLEAN
__declspec(dllexport)
-KdDebuggerNotPresent = &KdpDebuggerNotPresent;
+KdDebuggerNotPresent = TRUE; /* EXPORTED */
static BOOLEAN KdpBreakPending = FALSE;
#ifdef KDBG
/* Initialize the local kernel debugger. */
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_KDB;
#endif
if (!_strnicmp(p2, "SCREEN", 6))
{
p2 += 6;
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_SCREEN;
}
else if (!_strnicmp(p2, "BOCHS", 5))
{
p2 += 5;
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_BOCHS;
}
else if (!_strnicmp(p2, "GDB", 3))
{
p2 += 3;
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_GDB;
/* Reset port information to defaults */
else if (!_strnicmp(p2, "PICE", 4))
{
p2 += 4;
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_PICE;
}
else if (!_strnicmp(p2, "COM", 3))
Value = (ULONG)atol(p2);
if (Value > 0 && Value < 5)
{
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_SERIAL;
LogPortInfo.ComPort = Value;
}
else if (!_strnicmp(p2, "FILE", 4))
{
p2 += 4;
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_FILELOG;
}
else if (!_strnicmp(p2, "MDA", 3))
{
p2 += 3;
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_MDA;
}
}
else if (!_strnicmp(p2, "DEBUG", 5))
{
p2 += 5;
- KdpDebuggerEnabled = TRUE;
+ KdDebuggerEnabled = TRUE;
KdDebugState |= KD_DEBUG_SERIAL;
}
else if (!_strnicmp(p2, "NODEBUG", 7))
{
p2 += 7;
- KdpDebuggerEnabled = FALSE;
+ KdDebuggerEnabled = FALSE;
KdDebugState = KD_DEBUG_DISABLED;
}
else if (!_strnicmp(p2, "CRASHDEBUG", 10))
{
p2 += 10;
- KdpDebuggerEnabled = FALSE;
+ KdDebuggerEnabled = FALSE;
KdDebugState = KD_DEBUG_DISABLED;
}
else if (!_strnicmp(p2, "BREAK", 5))
p2 += 5;
KdpBreakPending = TRUE;
}
- else if (!_strnicmp(p2, "COM", 3))
+ else if (!_strnicmp(p2, "COM", 3))
+ {
+ p2 += 3;
+ if ('=' == *p2)
{
- p2 += 3;
- if (*p2 != '=')
+ p2++;
+ Value = (ULONG)atol(p2);
+ if (0 < Value && Value < 5)
{
- p2++;
- Value = (ULONG)atol(p2);
- if (Value > 0 && Value < 5)
- {
- PortInfo.ComPort = Value;
- }
+ PortInfo.ComPort = Value;
}
+ }
}
else if (!_strnicmp(p2, "BAUDRATE", 8))
{
p2 += 8;
- if (*p2 != '=')
+ if ('=' == *p2)
{
p2++;
Value = (ULONG)atol(p2);
- if (Value > 0)
- {
- PortInfo.BaudRate = Value;
- }
+ if (0 < Value)
+ {
+ PortInfo.BaudRate = Value;
+ }
}
- else if (!_strnicmp(p2, "IRQ", 3))
+ }
+ else if (!_strnicmp(p2, "IRQ", 3))
+ {
+ p2 += 3;
+ if ('=' == *p2)
{
- p2 += 3;
- if (*p2 != '=')
+ p2++;
+ Value = (ULONG)atol(p2);
+ if (0 < Value)
{
- p2++;
- Value = (ULONG)atol(p2);
- if (Value > 0)
- {
- KdpPortIrq = Value;
- }
+ KdpPortIrq = Value;
}
}
}
+#ifdef KDBG
+ else if (!_strnicmp(p2, "PROFILE", 7))
+ {
+ KdbInitProfiling();
+ }
+#endif /* KDBG */
p1 = p2;
}
- /* Print some information */
- if (KdpDebuggerEnabled == TRUE)
- {
- if (KdDebugState & KD_DEBUG_GDB)
- PrintString("\n GDB debugging enabled. COM%ld %ld Baud\n\n",
- GdbPortInfo.ComPort, GdbPortInfo.BaudRate);
-
- if (KdDebugState & KD_DEBUG_PICE)
- PrintString("\n Private ICE debugger enabled\n\n");
-
- if (KdDebugState & KD_DEBUG_SCREEN)
- PrintString("\n Screen debugging enabled\n\n");
-
- if (KdDebugState & KD_DEBUG_BOCHS)
- PrintString("\n Bochs debugging enabled\n\n");
-
- if (KdDebugState & KD_DEBUG_SERIAL)
- PrintString("\n Serial debugging enabled. COM%ld %ld Baud\n\n",
- LogPortInfo.ComPort, LogPortInfo.BaudRate);
-
- if (KdDebugState & KD_DEBUG_FILELOG)
- PrintString("\n File log debugging enabled\n\n");
-
- if (KdDebugState & KD_DEBUG_MDA)
- PrintString("\n MDA debugging enabled\n\n");
- }
-
/* Perform any initialization nescessary */
- if (KdpDebuggerEnabled == TRUE)
+ if (KdDebuggerEnabled == TRUE)
{
if (KdDebugState & KD_DEBUG_GDB)
KdPortInitializeEx(&GdbPortInfo, 0, 0);
KdInit1(VOID)
{
/* Initialize kernel debugger (phase 0) */
- if ((KdpDebuggerEnabled == TRUE) &&
+ if ((KdDebuggerEnabled == TRUE) &&
(KdDebugState & KD_DEBUG_GDB))
{
KdGdbStubInit(0);
VOID KdInit2(VOID)
{
/* Initialize kernel debugger (phase 1) */
- if ((KdpDebuggerEnabled == TRUE) &&
+ if ((KdDebuggerEnabled == TRUE) &&
(KdDebugState & KD_DEBUG_GDB))
{
KdGdbStubInit(1);
}
}
+
+VOID
+KdInit3(VOID)
+{
+ /* Print some information */
+ if (KdDebuggerEnabled == TRUE)
+ {
+ if (KdDebugState & KD_DEBUG_GDB)
+ PrintString("\n GDB debugging enabled. COM%ld %ld Baud\n\n",
+ GdbPortInfo.ComPort, GdbPortInfo.BaudRate);
+
+ if (KdDebugState & KD_DEBUG_PICE)
+ PrintString("\n Private ICE debugger enabled\n\n");
+
+ if (KdDebugState & KD_DEBUG_SCREEN)
+ PrintString("\n Screen debugging enabled\n\n");
+
+ if (KdDebugState & KD_DEBUG_BOCHS)
+ PrintString("\n Bochs debugging enabled\n\n");
+
+ if (KdDebugState & KD_DEBUG_SERIAL)
+ PrintString("\n Serial debugging enabled. COM%ld %ld Baud\n\n",
+ LogPortInfo.ComPort, LogPortInfo.BaudRate);
+
+ if (KdDebugState & KD_DEBUG_FILELOG)
+ PrintString("\n File log debugging enabled\n\n");
+ if (KdDebugState & KD_DEBUG_MDA)
+ PrintString("\n MDA debugging enabled\n\n");
+ }
+}
+
+
VOID
KdSerialDebugPrint (LPSTR Message)
{
/* NTOSKRNL.KdPollBreakIn */
+/*
+ * @implemented
+ */
BOOLEAN STDCALL
KdPollBreakIn(VOID)
{
- if ((!KdpDebuggerEnabled) || (!(KdDebugState & KD_DEBUG_SERIAL)))
+ if ((!KdDebuggerEnabled) || (!(KdDebugState & KD_DEBUG_SERIAL)))
return FALSE;
return KdpBreakPending;
}
+/*
+ * @implemented
+ */
VOID STDCALL
KeEnterKernelDebugger(VOID)
{
/* B - Bug check the system. */
else if (Code == 1)
{
- KeBugCheck(0);
+ KEBUGCHECK(0);
}
/*
* C - Dump statistics about the distribution of tagged blocks in