mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 14:37:45 +00:00
[NTOS]
- It appears ros wasn't ready for properly handling page faults with interrupts disabled, disable bugcheck and warn and dump stack instead for now. - Make KeRosDumpStackFrameArray and KdbSymPrintAddress safe to use at elavated IRQL -- don't use Unicode formats for DbgPrint at possible elavated IRQL/interrupts disabled as this may generate a page fault. Safely convert to ANSI instead before printing out the address. svn path=/trunk/; revision=56235
This commit is contained in:
parent
0d198933fd
commit
4cde806076
|
@ -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"
|
||||
|
|
|
@ -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,10 +155,15 @@ 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,
|
||||
RelativeAddress,
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue