diff --git a/reactos/ntoskrnl/include/internal/kd.h b/reactos/ntoskrnl/include/internal/kd.h index dd0112f35a3..f523d07504a 100644 --- a/reactos/ntoskrnl/include/internal/kd.h +++ b/reactos/ntoskrnl/include/internal/kd.h @@ -1,4 +1,4 @@ -/* $Id: kd.h,v 1.23 2004/02/24 21:25:41 weiden Exp $ +/* $Id: kd.h,v 1.24 2004/03/11 21:50:23 dwelch Exp $ * * kernel debugger prototypes */ @@ -120,5 +120,7 @@ KD_CONTINUE_TYPE KdbEnterDebuggerException(PEXCEPTION_RECORD ExceptionRecord, PCONTEXT Context, PKTRAP_FRAME TrapFrame); +VOID +DebugLogDumpMessages(VOID); #endif /* __INCLUDE_INTERNAL_KERNEL_DEBUGGER_H */ diff --git a/reactos/ntoskrnl/kd/dlog.c b/reactos/ntoskrnl/kd/dlog.c index b4bab1637ac..d0d31dc4daf 100644 --- a/reactos/ntoskrnl/kd/dlog.c +++ b/reactos/ntoskrnl/kd/dlog.c @@ -1,4 +1,4 @@ -/* $Id: dlog.c,v 1.12 2004/03/07 04:38:41 dwelch Exp $ +/* $Id: dlog.c,v 1.13 2004/03/11 21:50:23 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -35,6 +35,38 @@ static KEVENT DebugLogEvent; /* FUNCTIONS *****************************************************************/ +VOID +DebugLogDumpMessages(VOID) +{ + static CHAR Buffer[256]; + ULONG Offset; + ULONG Length; + + if (!(KdDebugState & KD_DEBUG_FILELOG)) + { + return; + } + KdDebugState &= ~KD_DEBUG_FILELOG; + + Offset = (DebugLogEnd + 1) % DEBUGLOG_SIZE; + do + { + if (Offset <= DebugLogEnd) + { + Length = min(255, DebugLogEnd - Offset); + } + else + { + Length = min(255, DEBUGLOG_SIZE - Offset); + } + memcpy(Buffer, DebugLog + Offset, Length); + Buffer[Length] = 0; + DbgPrint(Buffer); + Offset = (Offset + Length) % DEBUGLOG_SIZE; + } + while (Length > 0); +} + VOID INIT_FUNCTION DebugLogInit(VOID) { diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index c9ff4a6f550..7f51fe575e3 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: bug.c,v 1.43 2004/03/09 21:49:53 dwelch Exp $ +/* $Id: bug.c,v 1.44 2004/03/11 21:50:24 dwelch Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/ke/bug.c @@ -104,6 +104,7 @@ KeBugCheckWithTf(ULONG BugCheckCode, } Ke386DisableInterrupts(); + DebugLogDumpMessages(); if (KeGetCurrentIrql() < DISPATCH_LEVEL) { @@ -138,8 +139,23 @@ KeBugCheckWithTf(ULONG BugCheckCode, DbgPrint("Recursive bug check halting now\n"); Ke386HaltProcessor(); } - InBugCheck = 1; - KiDumpTrapFrame(Tf, BugCheckParameter1, BugCheckParameter2); + InBugCheck = 1; + if (Tf != NULL) + { + KiDumpTrapFrame(Tf, BugCheckParameter1, BugCheckParameter2); + } + else + { +#if defined(__GNUC__) + KeDumpStackFrames((PULONG)__builtin_frame_address(0)); +#elif defined(_MSC_VER) + __asm push ebp + __asm call KeDumpStackFrames + __asm add esp, 4 +#else +#error Unknown compiler for inline assembler +#endif + } MmDumpToPagingFile(BugCheckCode, BugCheckParameter1, BugCheckParameter2, BugCheckParameter3, BugCheckParameter4, Tf); @@ -175,88 +191,8 @@ KeBugCheckEx(ULONG BugCheckCode, * RETURNS: Doesn't */ { - PRTL_MESSAGE_RESOURCE_ENTRY Message; - NTSTATUS Status; - KIRQL OldIrql; - - /* Make sure we're switching back to the blue screen and print messages on it */ - HalReleaseDisplayOwnership(); - if (0 == (KdDebugState & KD_DEBUG_GDB)) - { - KdDebugState |= KD_DEBUG_SCREEN; - } - - Ke386DisableInterrupts(); - - if (KeGetCurrentIrql() < DISPATCH_LEVEL) - { - KeRaiseIrql(DISPATCH_LEVEL, &OldIrql); - } - DbgPrint("Bug detected (code %x param %x %x %x %x)\n", - BugCheckCode, - BugCheckParameter1, - BugCheckParameter2, - BugCheckParameter3, - BugCheckParameter4); - - Status = RtlFindMessage((PVOID)KERNEL_BASE, //0xC0000000, - 11, //RT_MESSAGETABLE, - 0x09, //0x409, - BugCheckCode, - &Message); - if (NT_SUCCESS(Status)) - { - if (Message->Flags == 0) - DbgPrint(" %s\n", Message->Text); - else - DbgPrint(" %S\n", (PWSTR)Message->Text); - } - else - { - DbgPrint(" No message text found!\n\n"); - } - - if (InBugCheck == 1) - { - DbgPrint("Recursive bug check halting now\n"); - Ke386HaltProcessor(); - } - InBugCheck = 1; - if (PsGetCurrentProcess() != NULL) - { - DbgPrint("Pid: %x <", PsGetCurrentProcess()->UniqueProcessId); - DbgPrint("%.8s> ", PsGetCurrentProcess()->ImageFileName); - } - if (PsGetCurrentThread() != NULL) - { - DbgPrint("Thrd: %x Tid: %x\n", - PsGetCurrentThread(), - PsGetCurrentThread()->Cid.UniqueThread); - } -#if defined(__GNUC__) - KeDumpStackFrames((PULONG)__builtin_frame_address(0)); -#elif defined(_MSC_VER) - __asm push ebp - __asm call KeDumpStackFrames - __asm add esp, 4 -#else -#error Unknown compiler for inline assembler -#endif - MmDumpToPagingFile(BugCheckCode, BugCheckParameter1, - BugCheckParameter2, BugCheckParameter3, - BugCheckParameter4, NULL); - - if (KdDebuggerEnabled) - { - Ke386EnableInterrupts(); - DbgBreakPointNoBugCheck(); - Ke386DisableInterrupts(); - } - - for (;;) - { - Ke386HaltProcessor(); - } + KeBugCheckWithTf(BugCheckCode, BugCheckParameter1, BugCheckParameter2, + BugCheckParameter3, BugCheckParameter4, NULL); } /*