mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
wrap stack walks in SEH - this doesn't fix page faults tho, so something else is going to have to be done :(
svn path=/trunk/; revision=12269
This commit is contained in:
parent
93af2278c0
commit
73df8e0872
7 changed files with 90 additions and 88 deletions
|
@ -361,6 +361,9 @@ KeResetEvent(IN PKEVENT Event);
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
KeRosDumpStackFrames ( PULONG Frame, ULONG FrameCount );
|
KeRosDumpStackFrames ( PULONG Frame, ULONG FrameCount );
|
||||||
|
|
||||||
|
ULONG STDCALL
|
||||||
|
KeRosGetStackFrames ( PULONG Frames, ULONG FrameCount );
|
||||||
|
|
||||||
BOOLEAN STDCALL
|
BOOLEAN STDCALL
|
||||||
KeRosPrintAddress(PVOID address);
|
KeRosPrintAddress(PVOID address);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ntoskrnl.h>
|
#include <ntoskrnl.h>
|
||||||
|
#include <pseh.h>
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
@ -630,16 +631,23 @@ VOID
|
||||||
KeDumpStackFrames(PULONG Frame)
|
KeDumpStackFrames(PULONG Frame)
|
||||||
{
|
{
|
||||||
DbgPrint("Frames: ");
|
DbgPrint("Frames: ");
|
||||||
while ( MmIsAddressValid(Frame) )
|
_SEH_TRY
|
||||||
{
|
{
|
||||||
ULONG Addr = Frame[1];
|
while ( MmIsAddressValid(Frame) )
|
||||||
if (!KeRosPrintAddress((PVOID)Addr))
|
{
|
||||||
DbgPrint("<%X>", Addr);
|
ULONG Addr = Frame[1];
|
||||||
if ( Addr == 0 || Addr == 0xDEADBEEF )
|
if (!KeRosPrintAddress((PVOID)Addr))
|
||||||
break;
|
DbgPrint("<%X>", Addr);
|
||||||
Frame = (PULONG)Frame[0];
|
if ( Addr == 0 || Addr == 0xDEADBEEF )
|
||||||
DbgPrint(" ");
|
break;
|
||||||
|
Frame = (PULONG)Frame[0];
|
||||||
|
DbgPrint(" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_SEH_HANDLE
|
||||||
|
{
|
||||||
|
}
|
||||||
|
_SEH_END;
|
||||||
DbgPrint("\n");
|
DbgPrint("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,29 +657,62 @@ KeRosDumpStackFrames ( PULONG Frame, ULONG FrameCount )
|
||||||
ULONG i=0;
|
ULONG i=0;
|
||||||
|
|
||||||
DbgPrint("Frames: ");
|
DbgPrint("Frames: ");
|
||||||
if ( !Frame )
|
_SEH_TRY
|
||||||
|
{
|
||||||
|
if ( !Frame )
|
||||||
|
{
|
||||||
|
#if defined __GNUC__
|
||||||
|
__asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
__asm mov [Frame], ebp
|
||||||
|
#endif
|
||||||
|
//Frame = (PULONG)Frame[0]; // step out of KeRosDumpStackFrames
|
||||||
|
}
|
||||||
|
while ( MmIsAddressValid(Frame) && i++ < FrameCount )
|
||||||
|
{
|
||||||
|
ULONG Addr = Frame[1];
|
||||||
|
if (!KeRosPrintAddress((PVOID)Addr))
|
||||||
|
DbgPrint("<%X>", Addr);
|
||||||
|
if ( Addr == 0 || Addr == 0xDEADBEEF )
|
||||||
|
break;
|
||||||
|
Frame = (PULONG)Frame[0];
|
||||||
|
DbgPrint(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_SEH_HANDLE
|
||||||
|
{
|
||||||
|
}
|
||||||
|
_SEH_END;
|
||||||
|
DbgPrint("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG STDCALL
|
||||||
|
KeRosGetStackFrames ( PULONG Frames, ULONG FrameCount )
|
||||||
|
{
|
||||||
|
ULONG Count = 0;
|
||||||
|
PULONG Frame;
|
||||||
|
_SEH_TRY
|
||||||
{
|
{
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
__asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
|
__asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
__asm mov [Frame], ebp
|
__asm mov [Frame], ebp
|
||||||
#endif
|
#endif
|
||||||
//Frame = (PULONG)Frame[0]; // step out of KeRosDumpStackFrames
|
while ( Count < FrameCount )
|
||||||
|
{
|
||||||
|
Frames[Count++] = Frame[1];
|
||||||
|
Frame = (PULONG)Frame[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while ( MmIsAddressValid(Frame) && i++ < FrameCount )
|
_SEH_HANDLE
|
||||||
{
|
{
|
||||||
ULONG Addr = Frame[1];
|
|
||||||
if (!KeRosPrintAddress((PVOID)Addr))
|
|
||||||
DbgPrint("<%X>", Addr);
|
|
||||||
if ( Addr == 0 || Addr == 0xDEADBEEF )
|
|
||||||
break;
|
|
||||||
Frame = (PULONG)Frame[0];
|
|
||||||
DbgPrint(" ");
|
|
||||||
}
|
}
|
||||||
DbgPrint("\n");
|
_SEH_END;
|
||||||
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_system_call_gate(unsigned int sel, unsigned int func)
|
static void
|
||||||
|
set_system_call_gate(unsigned int sel, unsigned int func)
|
||||||
{
|
{
|
||||||
DPRINT("sel %x %d\n",sel,sel);
|
DPRINT("sel %x %d\n",sel,sel);
|
||||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: RPoolMgr.h,v 1.2 2004/12/18 21:30:17 royce Exp $
|
/* $Id: RPoolMgr.h,v 1.3 2004/12/21 04:05:18 royce Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -249,65 +249,26 @@ RPoolRemoveFree ( PR_POOL pool, PR_FREE Item )
|
||||||
#endif//DBG || KDBG
|
#endif//DBG || KDBG
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function is used to walk up a stack trace... it returns
|
|
||||||
// the pointer to the next return address above the pointer to the
|
|
||||||
// return address pointed to by Frame...
|
|
||||||
static rulong*
|
|
||||||
RNextStackFrame ( rulong* Frame )
|
|
||||||
{
|
|
||||||
if ( !Frame || !*Frame || *Frame == 0xDEADBEAF )
|
|
||||||
return NULL;
|
|
||||||
return (rulong*)( Frame[-1] ) + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this function returns a pointer to the address the
|
|
||||||
// caller will return to. Use RNextStackFrame() above to walk
|
|
||||||
// further up the stack.
|
|
||||||
static rulong*
|
|
||||||
RStackFrame()
|
|
||||||
{
|
|
||||||
rulong* Frame;
|
|
||||||
#if defined __GNUC__
|
|
||||||
__asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
__asm mov [Frame], ebp
|
|
||||||
#endif
|
|
||||||
return RNextStackFrame ( Frame + 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RFreeFillStack ( PR_FREE free )
|
RFreeFillStack ( PR_FREE free )
|
||||||
{
|
{
|
||||||
rulong* Frame = RStackFrame();
|
|
||||||
int i;
|
int i;
|
||||||
memset ( free->LastOwnerStack, 0, sizeof(free->LastOwnerStack) );
|
ULONG stack[R_EXTRA_STACK_UP+3]; // need to skip 3 known levels of stack trace
|
||||||
Frame = RNextStackFrame ( Frame ); // step out of RFreeInit()
|
memset ( stack, 0xCD, sizeof(stack) );
|
||||||
Frame = RNextStackFrame ( Frame ); // step out of RFreeSplit()/RPoolReclaim()
|
R_GET_STACK_FRAMES ( stack, R_EXTRA_STACK_UP+3 );
|
||||||
Frame = RNextStackFrame ( Frame ); // step out of RPoolFree()
|
|
||||||
for ( i = 0; i < R_EXTRA_STACK_UP; i++ )
|
for ( i = 0; i < R_EXTRA_STACK_UP; i++ )
|
||||||
Frame = RNextStackFrame ( Frame );
|
free->LastOwnerStack[i] = stack[i+3];
|
||||||
for ( i = 0; i < R_STACK && Frame; i++ )
|
|
||||||
{
|
|
||||||
free->LastOwnerStack[i] = *Frame;
|
|
||||||
Frame = RNextStackFrame ( Frame );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RUsedFillStack ( PR_USED used )
|
RUsedFillStack ( PR_USED used )
|
||||||
{
|
{
|
||||||
rulong* Frame = RStackFrame();
|
|
||||||
int i;
|
int i;
|
||||||
memset ( used->LastOwnerStack, 0, sizeof(used->LastOwnerStack) );
|
ULONG stack[R_EXTRA_STACK_UP+2]; // need to skip 2 known levels of stack trace
|
||||||
Frame = RNextStackFrame ( Frame ); // step out of RUsedInit()
|
memset ( stack, 0xCD, sizeof(stack) );
|
||||||
Frame = RNextStackFrame ( Frame ); // step out of RPoolAlloc()
|
R_GET_STACK_FRAMES ( stack, R_EXTRA_STACK_UP+2 );
|
||||||
for ( i = 0; i < R_EXTRA_STACK_UP; i++ )
|
for ( i = 0; i < R_EXTRA_STACK_UP; i++ )
|
||||||
Frame = RNextStackFrame ( Frame );
|
used->LastOwnerStack[i] = stack[i+2];
|
||||||
for ( i = 0; i < R_STACK && Frame; i++ )
|
|
||||||
{
|
|
||||||
used->LastOwnerStack[i] = *Frame;
|
|
||||||
Frame = RNextStackFrame ( Frame );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PR_FREE
|
static PR_FREE
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: ppool.c,v 1.38 2004/12/18 21:27:27 royce Exp $
|
/* $Id: ppool.c,v 1.39 2004/12/21 04:05:18 royce Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -32,6 +32,7 @@
|
||||||
#define R_PANIC() KeBugCheck(0)
|
#define R_PANIC() KeBugCheck(0)
|
||||||
#define R_DEBUG DbgPrint
|
#define R_DEBUG DbgPrint
|
||||||
#define R_EXTRA_STACK_UP 2
|
#define R_EXTRA_STACK_UP 2
|
||||||
|
#define R_GET_STACK_FRAMES(ptr,cnt) KeRosGetStackFrames(ptr,cnt)
|
||||||
|
|
||||||
#include "RPoolMgr.h"
|
#include "RPoolMgr.h"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; $Id: ntoskrnl.def,v 1.204 2004/12/17 07:31:11 fireball Exp $
|
; $Id: ntoskrnl.def,v 1.205 2004/12/21 04:05:18 royce Exp $
|
||||||
;
|
;
|
||||||
; reactos/ntoskrnl/ntoskrnl.def
|
; reactos/ntoskrnl/ntoskrnl.def
|
||||||
;
|
;
|
||||||
|
@ -964,6 +964,7 @@ READ_REGISTER_BUFFER_ULONG@12
|
||||||
READ_REGISTER_BUFFER_USHORT@12
|
READ_REGISTER_BUFFER_USHORT@12
|
||||||
KeRosPrintAddress@4
|
KeRosPrintAddress@4
|
||||||
KeRosDumpStackFrames@8
|
KeRosDumpStackFrames@8
|
||||||
|
KeRosGetStackFrames@8
|
||||||
RtlAbsoluteToSelfRelativeSD@12
|
RtlAbsoluteToSelfRelativeSD@12
|
||||||
RtlAddAccessAllowedAce@16
|
RtlAddAccessAllowedAce@16
|
||||||
RtlAddAce@20
|
RtlAddAce@20
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.107 2004/12/12 01:40:37 weiden Exp $
|
# $Id: makefile,v 1.108 2004/12/21 04:05:18 royce Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ TARGET_PCH = w32k.h
|
||||||
|
|
||||||
TARGET_DDKLIBS = freetype.a
|
TARGET_DDKLIBS = freetype.a
|
||||||
|
|
||||||
|
TARGET_LIBS = \
|
||||||
|
$(SDK_PATH_LIB)/libpseh.a
|
||||||
|
|
||||||
TARGET_REGTESTS = yes
|
TARGET_REGTESTS = yes
|
||||||
|
|
||||||
FREETYPE_DIR = $(PATH_TO_TOP)/lib/freetype
|
FREETYPE_DIR = $(PATH_TO_TOP)/lib/freetype
|
||||||
|
|
|
@ -19,19 +19,25 @@
|
||||||
/*
|
/*
|
||||||
* GDIOBJ.C - GDI object manipulation routines
|
* GDIOBJ.C - GDI object manipulation routines
|
||||||
*
|
*
|
||||||
* $Id: gdiobj.c,v 1.82 2004/12/19 16:53:57 weiden Exp $
|
* $Id: gdiobj.c,v 1.83 2004/12/21 04:05:18 royce Exp $
|
||||||
*/
|
*/
|
||||||
#include <w32k.h>
|
#include <w32k.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
#include <pseh.h>
|
||||||
|
|
||||||
#ifdef __USE_W32API
|
#ifdef __USE_W32API
|
||||||
/* F*(&#$ header mess!!!! */
|
/* F*(&#$ header mess!!!! */
|
||||||
HANDLE
|
HANDLE
|
||||||
STDCALL PsGetProcessId(
|
STDCALL PsGetProcessId(
|
||||||
PEPROCESS Process
|
PEPROCESS Process
|
||||||
);
|
);
|
||||||
|
/* ditto */
|
||||||
|
ULONG STDCALL
|
||||||
|
KeRosGetStackFrames ( PULONG Frames, ULONG FrameCount );
|
||||||
#endif /* __USE_W32API */
|
#endif /* __USE_W32API */
|
||||||
|
|
||||||
|
|
||||||
|
@ -396,22 +402,8 @@ LockHandle:
|
||||||
InterlockedExchange(&Entry->ProcessId, CurrentProcessId);
|
InterlockedExchange(&Entry->ProcessId, CurrentProcessId);
|
||||||
|
|
||||||
#ifdef GDI_DEBUG
|
#ifdef GDI_DEBUG
|
||||||
{
|
memset ( GDIHandleAllocator[Index], 0xcd, GDI_STACK_LEVELS * sizeof(ULONG) );
|
||||||
PULONG Frame;
|
KeRosGetStackFrames ( GDIHandleAllocator[Index], GDI_STACK_LEVELS );
|
||||||
int which;
|
|
||||||
#if defined __GNUC__
|
|
||||||
__asm__("mov %%ebp, %%ebx" : "=b" (Frame) : );
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
__asm mov [Frame], ebp
|
|
||||||
#endif
|
|
||||||
for ( which = 0; which < GDI_STACK_LEVELS && Frame[1] != 0 && Frame[1] != 0xDEADBEEF; which++ )
|
|
||||||
{
|
|
||||||
GDIHandleAllocator[Index][which] = Frame[1];
|
|
||||||
Frame = ((PULONG)Frame[0]);
|
|
||||||
}
|
|
||||||
for ( ; which < GDI_STACK_LEVELS; which++ )
|
|
||||||
GDIHandleAllocator[Index][which] = 0xDEADBEEF;
|
|
||||||
}
|
|
||||||
#endif /* GDI_DEBUG */
|
#endif /* GDI_DEBUG */
|
||||||
|
|
||||||
if(W32Process != NULL)
|
if(W32Process != NULL)
|
||||||
|
|
Loading…
Reference in a new issue