From a993df861c30e7509f19ca47b58069f7fc12c0bf Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 24 Mar 2003 19:31:10 +0000 Subject: [PATCH] Make sure changes to the debug registers while inside a SIGTRAP exception are taken into account (based on a patch by Alex Pasadyn). --- dlls/ntdll/signal_i386.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c index 5ad70a60237..cc08a360d0f 100644 --- a/dlls/ntdll/signal_i386.c +++ b/dlls/ntdll/signal_i386.c @@ -836,6 +836,7 @@ static void do_segv( CONTEXT *context, int trap_code, void *cr2, int err_code ) static void do_trap( CONTEXT *context, int trap_code ) { EXCEPTION_RECORD rec; + DWORD dr0, dr1, dr2, dr3, dr6, dr7; rec.ExceptionFlags = EXCEPTION_CONTINUABLE; rec.ExceptionRecord = NULL; @@ -845,18 +846,15 @@ static void do_trap( CONTEXT *context, int trap_code ) switch(trap_code) { case T_TRCTRAP: /* Single-step exception */ + rec.ExceptionCode = EXCEPTION_SINGLE_STEP; if (context->EFlags & 0x100) { - rec.ExceptionCode = EXCEPTION_SINGLE_STEP; context->EFlags &= ~0x100; /* clear single-step flag */ } - else + else /* hardware breakpoint, fetch the debug registers */ { - /* likely we get this because of a kill(SIGTRAP) on ourself, - * so send a bp exception instead of a single step exception - */ - TRACE("Spurious single step trap => breakpoint simulation\n"); - rec.ExceptionCode = EXCEPTION_BREAKPOINT; + context->ContextFlags = CONTEXT_DEBUG_REGISTERS; + GetThreadContext(GetCurrentThread(), context); } break; case T_BPTFLT: /* Breakpoint exception */ @@ -866,7 +864,22 @@ static void do_trap( CONTEXT *context, int trap_code ) rec.ExceptionCode = EXCEPTION_BREAKPOINT; break; } + dr0 = context->Dr0; + dr1 = context->Dr1; + dr2 = context->Dr2; + dr3 = context->Dr3; + dr6 = context->Dr6; + dr7 = context->Dr7; + EXC_RtlRaiseException( &rec, context ); + + if (dr0 != context->Dr0 || dr1 != context->Dr1 || dr2 != context->Dr2 || + dr3 != context->Dr3 || dr6 != context->Dr6 || dr7 != context->Dr7) + { + /* the debug registers have changed, set the new values */ + context->ContextFlags = CONTEXT_DEBUG_REGISTERS; + SetThreadContext(GetCurrentThread(), context); + } }