commit bd8aff3456bbd1651b1d202ee73934f477b3d5ff Author: Peter Oberndorfer Date: Wed May 9 20:23:46 2007 +0200 ntdll: fix up instruction pointer in context inside raise_exception diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index ec69387..2d74b69 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -64,15 +64,15 @@ static RTL_CRITICAL_SECTION_DEBUG critsect_debug = static RTL_CRITICAL_SECTION vectored_handlers_section = { &critsect_debug, -1, 0, 0, 0, 0 }; #ifdef __i386__ -# define GET_IP(context) ((LPVOID)(context)->Eip) +# define GET_IP(context) ((context)->Eip) #elif defined(__sparc__) -# define GET_IP(context) ((LPVOID)(context)->pc) +# define GET_IP(context) ((context)->pc) #elif defined(__powerpc__) -# define GET_IP(context) ((LPVOID)(context)->Iar) +# define GET_IP(context) ((context)->Iar) #elif defined(__ALPHA__) -# define GET_IP(context) ((LPVOID)(context)->Fir) +# define GET_IP(context) ((context)->Fir) #elif defined(__x86_64__) -# define GET_IP(context) ((LPVOID)(context)->Rip) +# define GET_IP(context) ((context)->Rip) #else # error You must define GET_IP for this CPU #endif @@ -364,6 +364,10 @@ static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL f if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED) return STATUS_SUCCESS; + /* fix up instruction pointer in context for EXCEPTION_BREAKPOINT */ + if (rec->ExceptionCode == EXCEPTION_BREAKPOINT) + GET_IP(context) = (DWORD_PTR)GET_IP(context) - 1; + if (call_vectored_handlers( rec, context ) == EXCEPTION_CONTINUE_EXECUTION) return STATUS_SUCCESS; @@ -450,7 +454,7 @@ void WINAPI __regs_RtlUnwind( EXCEPTION_REGISTRATION_RECORD* pEndFrame, PVOID un record.ExceptionCode = STATUS_UNWIND; record.ExceptionFlags = 0; record.ExceptionRecord = NULL; - record.ExceptionAddress = GET_IP(context); + record.ExceptionAddress = (LPVOID) GET_IP(context); record.NumberParameters = 0; pRecord = &record; } diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 9ebbda7..83613f7 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -215,10 +215,8 @@ LONG CALLBACK rtlraiseexception_vectored_handler(EXCEPTION_POINTERS *ExceptionIn */ if(rec->ExceptionCode == EXCEPTION_BREAKPOINT) { - todo_wine { ok(context->Eip == (DWORD)code_mem + 0xa, "Eip at %x instead of %x\n", context->Eip, (DWORD)code_mem + 0xa); - } } else { @@ -247,10 +245,8 @@ static DWORD rtlraiseexception_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTR */ if(rec->ExceptionCode == EXCEPTION_BREAKPOINT) { - todo_wine { ok(context->Eip == (DWORD)code_mem + 0xa, "Eip at %x instead of %x\n", context->Eip, (DWORD)code_mem + 0xa); - } } else { @@ -525,9 +521,7 @@ static DWORD int3_handler( EXCEPTION_RECORD *rec, EXCEPTION_REGISTRATION_RECORD { ok( rec->ExceptionAddress == code_mem, "exception address not at: %p, but at %p\n", code_mem, rec->ExceptionAddress); - todo_wine { - ok( context->Eip == (DWORD)code_mem, "eip not at: %p, but at %#x\n", code_mem, context->Eip); - } + ok( context->Eip == (DWORD)code_mem, "eip not at: %p, but at %#x\n", code_mem, context->Eip); if(context->Eip == (DWORD)code_mem) context->Eip++; /* skip breakpoint */ return ExceptionContinueExecution; @@ -692,10 +686,8 @@ static void test_debugger(void) /* ctx.Eip is the same value the exception handler got */ if (de.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_BREAKPOINT) { - todo_wine{ ok((char *)ctx.Eip == (char *)code_mem_address + 0xa, "Eip at 0x%x instead of %p\n", ctx.Eip, (char *)code_mem_address + 0xa); - } /* need to fixup Eip for debuggee */ if ((char *)ctx.Eip == (char *)code_mem_address + 0xa) ctx.Eip += 1;