Author: ion
Date: Mon Mar 5 04:35:43 2007
New Revision: 25994
URL:
http://svn.reactos.org/svn/reactos?rev=25994&view=rev
Log:
- Stub NtSystemDebugControl.
- Fully support _WINKD_. Change this to 1, and get kdcom.dll from Windows 2003 or TinyKRNL
and you'll be able to connect to WinDBG if using the right debug settings. You can now
boot to desktop with WinDBG connected and see debug messages, but not much else is
supported.
- Fix bugs in KeGetBugMessageText.
- Implement KeEnterKernelDebugger.
Modified:
trunk/reactos/ntoskrnl/ex/dbgctrl.c
trunk/reactos/ntoskrnl/include/internal/kd.h
trunk/reactos/ntoskrnl/kd/kdmain.c
trunk/reactos/ntoskrnl/kd64/kdapi.c
trunk/reactos/ntoskrnl/ke/bug.c
trunk/reactos/ntoskrnl/ke/timerobj.c
trunk/reactos/ntoskrnl/ntoskrnl.rbuild
Modified: trunk/reactos/ntoskrnl/ex/dbgctrl.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/dbgctrl.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/dbgctrl.c (original)
+++ trunk/reactos/ntoskrnl/ex/dbgctrl.c Mon Mar 5 04:35:43 2007
@@ -60,23 +60,6 @@
ULONG OutputBufferLength,
PULONG ReturnLength)
{
- switch (ControlCode)
- {
- case SysDbgQueryTraceInformation:
- case SysDbgSetTracepoint:
- case SysDbgSetSpecialCall:
- case SysDbgClearSpecialCalls:
- case SysDbgQuerySpecialCalls:
- case SysDbgBreakPoint:
- break;
-
- case SysDbgQueryVersion:
- KDB_LOADUSERMODULE_HOOK((PLDR_DATA_TABLE_ENTRY) InputBuffer);
- break;
-
- default:
- break;
- }
-
+ /* FIXME: TODO */
return STATUS_SUCCESS;
}
Modified: trunk/reactos/ntoskrnl/include/internal/kd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/kd.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/kd.h Mon Mar 5 04:35:43 2007
@@ -16,6 +16,7 @@
extern BOOLEAN _KdDebuggerEnabled;
extern BOOLEAN _KdDebuggerNotPresent;
extern BOOLEAN KdBreakAfterSymbolLoad;
+extern BOOLEAN KdPitchDebugger;
BOOLEAN
NTAPI
Modified: trunk/reactos/ntoskrnl/kd/kdmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd/kdmain.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/kd/kdmain.c (original)
+++ trunk/reactos/ntoskrnl/kd/kdmain.c Mon Mar 5 04:35:43 2007
@@ -19,6 +19,7 @@
BOOLEAN KiEnableTimerWatchdog = FALSE;
BOOLEAN KdBreakAfterSymbolLoad = FALSE;
BOOLEAN KdpBreakPending;
+BOOLEAN KdPitchDebugger = TRUE;
VOID STDCALL PspDumpThreads(BOOLEAN SystemThreads);
typedef struct
@@ -232,22 +233,6 @@
KdPollBreakIn(VOID)
{
return KdpBreakPending;
-}
-
-/*
- * @implemented
- */
-VOID
-STDCALL
-KeEnterKernelDebugger(VOID)
-{
- HalDisplayString("\n\n *** Entered kernel debugger ***\n");
-
- /* Set the Variable */
- KdEnteredDebugger = TRUE;
-
- /* Halt the CPU */
- for (;;) Ke386HaltProcessor();
}
/*
Modified: trunk/reactos/ntoskrnl/kd64/kdapi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/kd64/kdapi.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/kd64/kdapi.c (original)
+++ trunk/reactos/ntoskrnl/kd64/kdapi.c Mon Mar 5 04:35:43 2007
@@ -1157,8 +1157,8 @@
}
/*
-* @unimplemented
-*/
+ * @unimplemented
+ */
NTSTATUS
NTAPI
KdSystemDebugControl(IN SYSDBG_COMMAND Command,
@@ -1173,20 +1173,60 @@
return STATUS_SUCCESS;
}
-NTSTATUS
-NTAPI
-NtQueryDebugFilterState(ULONG ComponentId,
- ULONG Level)
-{
- return STATUS_SUCCESS;
-}
-
-NTSTATUS
-NTAPI
-NtSetDebugFilterState(ULONG ComponentId,
- ULONG Level,
- BOOLEAN State)
-{
- return STATUS_SUCCESS;
-}
-
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+KdChangeOption(IN KD_OPTION Option,
+ IN ULONG InBufferBytes OPTIONAL,
+ IN PVOID InBuffer,
+ IN ULONG OutBufferBytes OPTIONAL,
+ OUT PVOID OutBuffer,
+ OUT PULONG OutBufferNeeded OPTIONAL)
+{
+ /* HACK */
+ return STATUS_SUCCESS;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+KdPowerTransition(IN DEVICE_POWER_STATE NewState)
+{
+ /* HACK */
+ return STATUS_SUCCESS;
+}
+
+/*
+ * @unimplemented
+ */
+NTSTATUS
+NTAPI
+KdDisableDebugger(VOID)
+{
+ /* HACK */
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+NtQueryDebugFilterState(ULONG ComponentId,
+ ULONG Level)
+{
+ /* HACK */
+ return STATUS_SUCCESS;
+}
+
+NTSTATUS
+NTAPI
+NtSetDebugFilterState(ULONG ComponentId,
+ ULONG Level,
+ BOOLEAN State)
+{
+ /* HACK */
+ return STATUS_SUCCESS;
+}
+
Modified: trunk/reactos/ntoskrnl/ke/bug.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/bug.c?rev=2599…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/bug.c (original)
+++ trunk/reactos/ntoskrnl/ke/bug.c Mon Mar 5 04:35:43 2007
@@ -99,7 +99,7 @@
}
/* Print it out */
- if (!KeRosPrintAddress((PVOID)Addr)) DbgPrint("<%X>", Addr);
+ KiRosPrintAddress((PVOID)Addr);
/* Go to the next frame */
DbgPrint("\n");
@@ -148,7 +148,7 @@
}
}
-VOID
+BOOLEAN
NTAPI
KeGetBugMessageText(IN ULONG BugCheckCode,
OUT PANSI_STRING OutputString OPTIONAL)
@@ -157,6 +157,10 @@
ULONG IdOffset;
ULONG_PTR MessageEntry;
PCHAR BugCode;
+ BOOLEAN Result = FALSE;
+
+ /* Make sure we're not bugchecking too early */
+ if (!KiBugCodeMessages) return Result;
/* Find the message. This code is based on RtlFindMesssage */
for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++)
@@ -164,7 +168,7 @@
/* Check if the ID Matches */
if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) &&
(BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId))
- {
+ {
/* Get Offset to Entry */
MessageEntry = KiBugCodeMessages->Blocks[i].OffsetToEntries +
(ULONG_PTR)KiBugCodeMessages;
@@ -182,22 +186,39 @@
BugCode = ((PRTL_MESSAGE_RESOURCE_ENTRY)MessageEntry)->Text;
i = strlen(BugCode);
- /* Return it in the OutputString */
+ /* Handle newlines */
+ while ((i > 0) && ((BugCode[i] == '\n') ||
+ (BugCode[i] == '\r') ||
+ (BugCode[i] == ANSI_NULL)))
+ {
+ /* Check if we have a string to return */
+ if (!OutputString) BugCode[i] = ANSI_NULL;
+ i--;
+ }
+
+ /* Check if caller wants an output string */
if (OutputString)
{
+ /* Return it in the OutputString */
OutputString->Buffer = BugCode;
- OutputString->Length = i + 1;
- OutputString->MaximumLength = i + 1;
+ OutputString->Length = (USHORT)i + 1;
+ OutputString->MaximumLength = (USHORT)i + 1;
}
else
{
/* Direct Output to Screen */
InbvDisplayString(BugCode);
InbvDisplayString("\r");
- break;
- }
- }
- }
+ }
+
+ /* We're done */
+ Result = TRUE;
+ break;
+ }
+ }
+
+ /* Return the result */
+ return Result;
}
VOID
@@ -489,7 +510,7 @@
/* Print message for technical information */
KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
- /* Show the techincal Data */
+ /* Show the technical Data */
sprintf(AnsiName,
"\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
KiBugCheckData[0],
@@ -819,6 +840,9 @@
}
/* Check if we need to save the context for KD */
+#ifdef _WINKD_
+ if (!KdPitchDebugger) KdDebuggerDataBlock.SavedContext = (ULONG)&Context;
+#endif
/* Check if a debugger is connected */
if ((BugCheckCode != MANUALLY_INITIATED_CRASH) && (KdDebuggerEnabled))
@@ -901,12 +925,14 @@
AnsiName);
/* Check if the debugger is disabled but we can enable it */
- //if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
+ if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
{
/* Enable it */
- //KdEnableDebuggerWithLock(FALSE);
- }
- //else
+#ifdef _WINKD_
+ KdEnableDebuggerWithLock(FALSE);
+#endif
+ }
+ else
{
/* Otherwise, print the last line */
InbvDisplayString("\r\n");
@@ -1116,4 +1142,30 @@
KeBugCheckWithTf(BugCheckCode, 0, 0, 0, 0, NULL);
}
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeEnterKernelDebugger(VOID)
+{
+ /* Disable interrupts */
+ KiHardwareTrigger = 1;
+ _disable();
+
+ /* Check the bugcheck count */
+ if (!InterlockedDecrement(&KeBugCheckCount))
+ {
+ /* There was only one, is the debugger disabled? */
+ if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
+ {
+ /* Enable the debugger */
+ KdInitSystem(0, NULL);
+ }
+ }
+
+ /* Bugcheck */
+ KiBugCheckDebugBreak(DBG_STATUS_FATAL);
+}
+
/* EOF */
Modified: trunk/reactos/ntoskrnl/ke/timerobj.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/timerobj.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/timerobj.c (original)
+++ trunk/reactos/ntoskrnl/ke/timerobj.c Mon Mar 5 04:35:43 2007
@@ -17,6 +17,7 @@
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE];
LARGE_INTEGER KiTimeIncrementReciprocal;
UCHAR KiTimeIncrementShiftCount;
+BOOLEAN KiEnableTimerWatchdog;
/* PRIVATE FUNCTIONS *********************************************************/
Modified: trunk/reactos/ntoskrnl/ntoskrnl.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ntoskrnl.rbuild?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ntoskrnl.rbuild (original)
+++ trunk/reactos/ntoskrnl/ntoskrnl.rbuild Mon Mar 5 04:35:43 2007
@@ -10,6 +10,9 @@
<define name="__USE_W32API" />
<define name="WIN9X_COMPAT_SPINLOCK" />
<define name="_IN_KERNEL_" />
+ <if property="_WINKD_" value="1">
+ <define name="_WINKD_" />
+ </if>
<include base="cmlib">.</include>
<include base="ntoskrnl">include</include>
<include base="ReactOS">include/reactos/drivers</include>