From 7d0dd5f3277f3408dde2c053fb7e5e2fd271ed76 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 7 Mar 2000 13:10:21 +0000 Subject: [PATCH] Added DbgBreakPoint. Fixed exception record contents on SIGTRAP. --- dlls/ntdll/exception.c | 22 +++++++++++----------- dlls/ntdll/ntdll.spec | 4 ++-- dlls/ntdll/signal_i386.c | 34 ++++++++++++++++++++++++---------- include/ntddk.h | 1 + 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index fe40166bcf6..f7b6893292f 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -289,18 +289,11 @@ void WINAPI RtlRaiseStatus( NTSTATUS status ) /*********************************************************************** - * EXC_DebugBreak / DebugBreak (KERNEL32.181) + * DebugBreak (KERNEL32.181) */ -DEFINE_REGS_ENTRYPOINT_0( DebugBreak, EXC_DebugBreak ) -void WINAPI EXC_DebugBreak( CONTEXT *context ) +void WINAPI DebugBreak(void) { - EXCEPTION_RECORD rec; - - rec.ExceptionCode = EXCEPTION_BREAKPOINT; - rec.ExceptionFlags = 0; - rec.ExceptionRecord = NULL; - rec.NumberParameters = 0; - EXC_RtlRaiseException( &rec, context ); + DbgBreakPoint(); } @@ -310,6 +303,13 @@ void WINAPI EXC_DebugBreak( CONTEXT *context ) void WINAPI DebugBreak16( CONTEXT86 *context ) { #ifdef __i386__ - EXC_DebugBreak( context ); + EXCEPTION_RECORD rec; + + rec.ExceptionCode = EXCEPTION_BREAKPOINT; + rec.ExceptionFlags = 0; + rec.ExceptionRecord = NULL; + rec.ExceptionAddress = GET_IP(context); + rec.NumberParameters = 0; + EXC_RtlRaiseException( &rec, context ); #endif /* defined(__i386__) */ } diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index f9e723820e7..d68ba588147 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -24,7 +24,7 @@ type win32 @ stub CsrProbeForWrite @ stub CsrSetPriorityClass @ stub CsrpProcessCallbackRequest -@ stub DbgBreakPoint +@ stdcall DbgBreakPoint() DbgBreakPoint @ varargs DbgPrint(str) DbgPrint @ stub DbgPrompt @ stub DbgSsHandleKmApiMsg @@ -32,7 +32,7 @@ type win32 @ stub DbgUiConnectToDbg @ stub DbgUiContinue @ stub DbgUiWaitStateChange -@ stub DbgUserBreakPoint +@ stdcall DbgUserBreakPoint() DbgUserBreakPoint @ stub KiUserApcDispatcher @ stub KiUserCallbackDispatcher @ stub KiUserExceptionDispatcher diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 5cceeba6f52..0974808d307 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -566,21 +566,25 @@ static HANDLER_DEF(trap_handler) handler_init( &context, HANDLER_CONTEXT ); - switch(get_trap_code(HANDLER_CONTEXT)) - { - case T_TRCTRAP: /* Single-step exception */ - rec.ExceptionCode = EXCEPTION_SINGLE_STEP; - break; - case T_BPTFLT: /* Breakpoint exception */ - default: - rec.ExceptionCode = EXCEPTION_BREAKPOINT; - break; - } save_context( &context, HANDLER_CONTEXT ); rec.ExceptionFlags = EXCEPTION_CONTINUABLE; rec.ExceptionRecord = NULL; rec.ExceptionAddress = (LPVOID)context.Eip; rec.NumberParameters = 0; + + switch(get_trap_code(HANDLER_CONTEXT)) + { + case T_TRCTRAP: /* Single-step exception */ + rec.ExceptionCode = EXCEPTION_SINGLE_STEP; + context.EFlags &= ~0x100; /* clear single-step flag */ + break; + case T_BPTFLT: /* Breakpoint exception */ + rec.ExceptionAddress--; /* back up over the int3 instruction */ + /* fall through */ + default: + rec.ExceptionCode = EXCEPTION_BREAKPOINT; + break; + } EXC_RtlRaiseException( &rec, &context ); restore_context( &context, HANDLER_CONTEXT ); } @@ -725,4 +729,14 @@ BOOL SIGNAL_Init(void) return FALSE; } +/********************************************************************** + * DbgBreakPoint (NTDLL) + */ +__ASM_GLOBAL_FUNC( DbgBreakPoint, "int3; ret"); + +/********************************************************************** + * DbgUserBreakPoint (NTDLL) + */ +__ASM_GLOBAL_FUNC( DbgUserBreakPoint, "int3; ret"); + #endif /* __i386__ */ diff --git a/include/ntddk.h b/include/ntddk.h index 9d223f1fc6b..7877549b155 100644 --- a/include/ntddk.h +++ b/include/ntddk.h @@ -961,6 +961,7 @@ NTSTATUS WINAPI NtClose( /* misc */ +void WINAPI DbgBreakPoint(void); void WINAPIV DbgPrint(LPCSTR fmt, ...); DWORD WINAPI RtlAdjustPrivilege(DWORD x1,DWORD x2,DWORD x3,DWORD x4);