diff --git a/reactos/ntoskrnl/include/internal/ke.h b/reactos/ntoskrnl/include/internal/ke.h index 2a3f062c18a..f45c6c9a3d0 100644 --- a/reactos/ntoskrnl/include/internal/ke.h +++ b/reactos/ntoskrnl/include/internal/ke.h @@ -1130,4 +1130,12 @@ NTAPI KiRosPcToUserFileHeader(IN PVOID Eip, OUT PLDR_DATA_TABLE_ENTRY *LdrEntry); +PCHAR +NTAPI +KeBugCheckUnicodeToAnsi( + IN PUNICODE_STRING Unicode, + OUT PCHAR Ansi, + IN ULONG Length +); + #include "ke_x.h" diff --git a/reactos/ntoskrnl/kdbg/kdb_symbols.c b/reactos/ntoskrnl/kdbg/kdb_symbols.c index f54f1cc14c1..2cb27c320c9 100644 --- a/reactos/ntoskrnl/kdbg/kdb_symbols.c +++ b/reactos/ntoskrnl/kdbg/kdb_symbols.c @@ -109,6 +109,30 @@ KdbpSymFindModule( pLdrEntry); } +PCHAR +NTAPI +KdbpSymUnicodeToAnsi(IN PUNICODE_STRING Unicode, + OUT PCHAR Ansi, + IN ULONG Length) +{ + PCHAR p; + PWCHAR pw; + ULONG i; + + /* Set length and normalize it */ + i = Unicode->Length / sizeof(WCHAR); + i = min(i, Length - 1); + + /* Set source and destination, and copy */ + pw = Unicode->Buffer; + p = Ansi; + while (i--) *p++ = (CHAR)*pw++; + + /* Null terminate and return */ + *p = ANSI_NULL; + return Ansi; +} + /*! \brief Print address... * * Tries to lookup line number, file name and function name for the given @@ -131,9 +155,14 @@ KdbSymPrintAddress( ULONG LineNumber; CHAR FileName[256]; CHAR FunctionName[256]; + CHAR ModuleNameAnsi[64]; if (!KdbpSymbolsInitialized || !KdbpSymFindModule(Address, NULL, -1, &LdrEntry)) return FALSE; + + KdbpSymUnicodeToAnsi(&LdrEntry->BaseDllName, + ModuleNameAnsi, + sizeof(ModuleNameAnsi)); RelativeAddress = (ULONG_PTR)Address - (ULONG_PTR)LdrEntry->DllBase; Status = KdbSymGetAddressInformation(LdrEntry->PatchInformation, @@ -143,12 +172,12 @@ KdbSymPrintAddress( FunctionName); if (NT_SUCCESS(Status)) { - DbgPrint("<%wZ:%x (%s:%d (%s))>", - &LdrEntry->BaseDllName, RelativeAddress, FileName, LineNumber, FunctionName); + DbgPrint("<%s:%x (%s:%d (%s))>", + ModuleNameAnsi, RelativeAddress, FileName, LineNumber, FunctionName); } else { - DbgPrint("<%wZ:%x>", &LdrEntry->BaseDllName, RelativeAddress); + DbgPrint("<%s:%x>", ModuleNameAnsi, RelativeAddress); } return TRUE; diff --git a/reactos/ntoskrnl/ke/bug.c b/reactos/ntoskrnl/ke/bug.c index 8d4470ec6ca..641c544dfa9 100644 --- a/reactos/ntoskrnl/ke/bug.c +++ b/reactos/ntoskrnl/ke/bug.c @@ -102,42 +102,6 @@ KiPcToFileHeader(IN PVOID Pc, return PcBase; } -BOOLEAN -NTAPI -KiRosPrintAddress(PVOID address) -{ - PLIST_ENTRY current_entry; - PLDR_DATA_TABLE_ENTRY current; - extern LIST_ENTRY PsLoadedModuleList; - ULONG_PTR RelativeAddress; - ULONG i = 0; - - do - { - current_entry = PsLoadedModuleList.Flink; - - while (current_entry != &PsLoadedModuleList) - { - current = CONTAINING_RECORD(current_entry, - LDR_DATA_TABLE_ENTRY, - InLoadOrderLinks); - - if (address >= (PVOID)current->DllBase && - address < (PVOID)((ULONG_PTR)current->DllBase + - current->SizeOfImage)) - { - RelativeAddress = (ULONG_PTR)address - - (ULONG_PTR)current->DllBase; - DbgPrint("<%wZ: %x>", ¤t->FullDllName, RelativeAddress); - return(TRUE); - } - current_entry = current_entry->Flink; - } - } while(++i <= 1); - - return(FALSE); -} - PVOID NTAPI KiRosPcToUserFileHeader(IN PVOID Pc, @@ -270,9 +234,14 @@ KeRosDumpStackFrameArray(IN PULONG_PTR Frames, if (!KdbSymPrintAddress((PVOID)Addr, NULL)) #endif { - /* Print out the module name */ + CHAR AnsiName[64]; + + /* Convert module name to ANSI and print it */ + KeBugCheckUnicodeToAnsi(&LdrEntry->BaseDllName, + AnsiName, + sizeof(AnsiName)); Addr -= (ULONG_PTR)LdrEntry->DllBase; - DbgPrint("<%wZ: %p>", &LdrEntry->FullDllName, (PVOID)Addr); + DbgPrint("<%s: %p>", AnsiName, (PVOID)Addr); } } else diff --git a/reactos/ntoskrnl/ke/i386/traphdlr.c b/reactos/ntoskrnl/ke/i386/traphdlr.c index c0066e288eb..9222079d0af 100644 --- a/reactos/ntoskrnl/ke/i386/traphdlr.c +++ b/reactos/ntoskrnl/ke/i386/traphdlr.c @@ -1190,6 +1190,7 @@ KiTrap0EHandler(IN PKTRAP_FRAME TrapFrame) /* Enable interupts */ _enable(); +#if 0 /* Check if we faulted with interrupts disabled */ if (!(TrapFrame->EFlags & EFLAGS_INTERRUPT_MASK)) { @@ -1201,6 +1202,14 @@ KiTrap0EHandler(IN PKTRAP_FRAME TrapFrame) TrapFrame->Eip, TrapFrame); } +#else + if (!(TrapFrame->EFlags & EFLAGS_INTERRUPT_MASK)) + { + /* Warn and dump stack */ + DPRINT1("Page fault with interrupts disabled!\n"); + KeRosDumpStackFrames(NULL, 0); + } +#endif /* Check for S-LIST fault in kernel mode */ if (TrapFrame->Eip == (ULONG_PTR)ExpInterlockedPopEntrySListFault)