mirror of
https://github.com/reactos/reactos.git
synced 2025-07-25 04:03:56 +00:00
- 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. svn path=/trunk/; revision=25994
This commit is contained in:
parent
aafc3a967a
commit
05f82784bd
7 changed files with 127 additions and 62 deletions
|
@ -60,23 +60,6 @@ NtSystemDebugControl(SYSDBG_COMMAND ControlCode,
|
||||||
ULONG OutputBufferLength,
|
ULONG OutputBufferLength,
|
||||||
PULONG ReturnLength)
|
PULONG ReturnLength)
|
||||||
{
|
{
|
||||||
switch (ControlCode)
|
/* FIXME: TODO */
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ extern KD_PORT_INFORMATION GdbPortInfo;
|
||||||
extern BOOLEAN _KdDebuggerEnabled;
|
extern BOOLEAN _KdDebuggerEnabled;
|
||||||
extern BOOLEAN _KdDebuggerNotPresent;
|
extern BOOLEAN _KdDebuggerNotPresent;
|
||||||
extern BOOLEAN KdBreakAfterSymbolLoad;
|
extern BOOLEAN KdBreakAfterSymbolLoad;
|
||||||
|
extern BOOLEAN KdPitchDebugger;
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
|
|
|
@ -19,6 +19,7 @@ BOOLEAN KdDebuggerNotPresent = TRUE;
|
||||||
BOOLEAN KiEnableTimerWatchdog = FALSE;
|
BOOLEAN KiEnableTimerWatchdog = FALSE;
|
||||||
BOOLEAN KdBreakAfterSymbolLoad = FALSE;
|
BOOLEAN KdBreakAfterSymbolLoad = FALSE;
|
||||||
BOOLEAN KdpBreakPending;
|
BOOLEAN KdpBreakPending;
|
||||||
|
BOOLEAN KdPitchDebugger = TRUE;
|
||||||
VOID STDCALL PspDumpThreads(BOOLEAN SystemThreads);
|
VOID STDCALL PspDumpThreads(BOOLEAN SystemThreads);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -234,22 +235,6 @@ KdPollBreakIn(VOID)
|
||||||
return KdpBreakPending;
|
return KdpBreakPending;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
VOID
|
|
||||||
STDCALL
|
|
||||||
KeEnterKernelDebugger(VOID)
|
|
||||||
{
|
|
||||||
HalDisplayString("\n\n *** Entered kernel debugger ***\n");
|
|
||||||
|
|
||||||
/* Set the Variable */
|
|
||||||
KdEnteredDebugger = TRUE;
|
|
||||||
|
|
||||||
/* Halt the CPU */
|
|
||||||
for (;;) Ke386HaltProcessor();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1157,8 +1157,8 @@ KdEnableDebugger(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
KdSystemDebugControl(IN SYSDBG_COMMAND Command,
|
KdSystemDebugControl(IN SYSDBG_COMMAND Command,
|
||||||
|
@ -1173,20 +1173,60 @@ KdSystemDebugControl(IN SYSDBG_COMMAND Command,
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
/*
|
||||||
NTAPI
|
* @unimplemented
|
||||||
NtQueryDebugFilterState(ULONG ComponentId,
|
*/
|
||||||
ULONG Level)
|
NTSTATUS
|
||||||
{
|
NTAPI
|
||||||
return STATUS_SUCCESS;
|
KdChangeOption(IN KD_OPTION Option,
|
||||||
}
|
IN ULONG InBufferBytes OPTIONAL,
|
||||||
|
IN PVOID InBuffer,
|
||||||
NTSTATUS
|
IN ULONG OutBufferBytes OPTIONAL,
|
||||||
NTAPI
|
OUT PVOID OutBuffer,
|
||||||
NtSetDebugFilterState(ULONG ComponentId,
|
OUT PULONG OutBufferNeeded OPTIONAL)
|
||||||
ULONG Level,
|
{
|
||||||
BOOLEAN State)
|
/* HACK */
|
||||||
{
|
return STATUS_SUCCESS;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ KeRosDumpStackFrames(IN PULONG Frame OPTIONAL,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Print it out */
|
/* Print it out */
|
||||||
if (!KeRosPrintAddress((PVOID)Addr)) DbgPrint("<%X>", Addr);
|
KiRosPrintAddress((PVOID)Addr);
|
||||||
|
|
||||||
/* Go to the next frame */
|
/* Go to the next frame */
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
|
@ -148,7 +148,7 @@ KiInitializeBugCheck(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
BOOLEAN
|
||||||
NTAPI
|
NTAPI
|
||||||
KeGetBugMessageText(IN ULONG BugCheckCode,
|
KeGetBugMessageText(IN ULONG BugCheckCode,
|
||||||
OUT PANSI_STRING OutputString OPTIONAL)
|
OUT PANSI_STRING OutputString OPTIONAL)
|
||||||
|
@ -157,6 +157,10 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
|
||||||
ULONG IdOffset;
|
ULONG IdOffset;
|
||||||
ULONG_PTR MessageEntry;
|
ULONG_PTR MessageEntry;
|
||||||
PCHAR BugCode;
|
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 */
|
/* Find the message. This code is based on RtlFindMesssage */
|
||||||
for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++)
|
for (i = 0; i < KiBugCodeMessages->NumberOfBlocks; i++)
|
||||||
|
@ -164,7 +168,7 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
|
||||||
/* Check if the ID Matches */
|
/* Check if the ID Matches */
|
||||||
if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) &&
|
if ((BugCheckCode >= KiBugCodeMessages->Blocks[i].LowId) &&
|
||||||
(BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId))
|
(BugCheckCode <= KiBugCodeMessages->Blocks[i].HighId))
|
||||||
{
|
{
|
||||||
/* Get Offset to Entry */
|
/* Get Offset to Entry */
|
||||||
MessageEntry = KiBugCodeMessages->Blocks[i].OffsetToEntries +
|
MessageEntry = KiBugCodeMessages->Blocks[i].OffsetToEntries +
|
||||||
(ULONG_PTR)KiBugCodeMessages;
|
(ULONG_PTR)KiBugCodeMessages;
|
||||||
|
@ -182,22 +186,39 @@ KeGetBugMessageText(IN ULONG BugCheckCode,
|
||||||
BugCode = ((PRTL_MESSAGE_RESOURCE_ENTRY)MessageEntry)->Text;
|
BugCode = ((PRTL_MESSAGE_RESOURCE_ENTRY)MessageEntry)->Text;
|
||||||
i = strlen(BugCode);
|
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)
|
if (OutputString)
|
||||||
{
|
{
|
||||||
|
/* Return it in the OutputString */
|
||||||
OutputString->Buffer = BugCode;
|
OutputString->Buffer = BugCode;
|
||||||
OutputString->Length = i + 1;
|
OutputString->Length = (USHORT)i + 1;
|
||||||
OutputString->MaximumLength = i + 1;
|
OutputString->MaximumLength = (USHORT)i + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Direct Output to Screen */
|
/* Direct Output to Screen */
|
||||||
InbvDisplayString(BugCode);
|
InbvDisplayString(BugCode);
|
||||||
InbvDisplayString("\r");
|
InbvDisplayString("\r");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We're done */
|
||||||
|
Result = TRUE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Return the result */
|
||||||
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -489,7 +510,7 @@ KiDisplayBlueScreen(IN ULONG MessageId,
|
||||||
/* Print message for technical information */
|
/* Print message for technical information */
|
||||||
KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
|
KeGetBugMessageText(BUGCHECK_TECH_INFO, NULL);
|
||||||
|
|
||||||
/* Show the techincal Data */
|
/* Show the technical Data */
|
||||||
sprintf(AnsiName,
|
sprintf(AnsiName,
|
||||||
"\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
|
"\r\n\r\n*** STOP: 0x%08lX (0x%p,0x%p,0x%p,0x%p)\r\n\r\n",
|
||||||
KiBugCheckData[0],
|
KiBugCheckData[0],
|
||||||
|
@ -819,6 +840,9 @@ KeBugCheckWithTf(IN ULONG BugCheckCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we need to save the context for KD */
|
/* 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 */
|
/* Check if a debugger is connected */
|
||||||
if ((BugCheckCode != MANUALLY_INITIATED_CRASH) && (KdDebuggerEnabled))
|
if ((BugCheckCode != MANUALLY_INITIATED_CRASH) && (KdDebuggerEnabled))
|
||||||
|
@ -901,12 +925,14 @@ KeBugCheckWithTf(IN ULONG BugCheckCode,
|
||||||
AnsiName);
|
AnsiName);
|
||||||
|
|
||||||
/* Check if the debugger is disabled but we can enable it */
|
/* Check if the debugger is disabled but we can enable it */
|
||||||
//if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
|
if (!(KdDebuggerEnabled) && !(KdPitchDebugger))
|
||||||
{
|
{
|
||||||
/* Enable it */
|
/* Enable it */
|
||||||
//KdEnableDebuggerWithLock(FALSE);
|
#ifdef _WINKD_
|
||||||
|
KdEnableDebuggerWithLock(FALSE);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
//else
|
else
|
||||||
{
|
{
|
||||||
/* Otherwise, print the last line */
|
/* Otherwise, print the last line */
|
||||||
InbvDisplayString("\r\n");
|
InbvDisplayString("\r\n");
|
||||||
|
@ -1116,4 +1142,30 @@ KeBugCheck(ULONG BugCheckCode)
|
||||||
KeBugCheckWithTf(BugCheckCode, 0, 0, 0, 0, NULL);
|
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 */
|
/* EOF */
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE];
|
KTIMER_TABLE_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE];
|
||||||
LARGE_INTEGER KiTimeIncrementReciprocal;
|
LARGE_INTEGER KiTimeIncrementReciprocal;
|
||||||
UCHAR KiTimeIncrementShiftCount;
|
UCHAR KiTimeIncrementShiftCount;
|
||||||
|
BOOLEAN KiEnableTimerWatchdog;
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS *********************************************************/
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
<define name="__USE_W32API" />
|
<define name="__USE_W32API" />
|
||||||
<define name="WIN9X_COMPAT_SPINLOCK" />
|
<define name="WIN9X_COMPAT_SPINLOCK" />
|
||||||
<define name="_IN_KERNEL_" />
|
<define name="_IN_KERNEL_" />
|
||||||
|
<if property="_WINKD_" value="1">
|
||||||
|
<define name="_WINKD_" />
|
||||||
|
</if>
|
||||||
<include base="cmlib">.</include>
|
<include base="cmlib">.</include>
|
||||||
<include base="ntoskrnl">include</include>
|
<include base="ntoskrnl">include</include>
|
||||||
<include base="ReactOS">include/reactos/drivers</include>
|
<include base="ReactOS">include/reactos/drivers</include>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue