Commit 649be380 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntdll: Call send_debug_event from debug handler on x86_64.

parent 200490b3
......@@ -1357,7 +1357,7 @@ static void test_debugger(const char *argv0)
}
else win_skip("call_debug_service_code not supported on this architecture\n");
if (sizeof(loop_code) > 1 && broken(1) /* FIXME: broken in Wine */)
if (sizeof(loop_code) > 1 && (sizeof(void*) == 8 || broken(1) /* FIXME: broken in Wine */))
{
memset(buf, OP_BP, sizeof(buf));
memcpy(proc_code, &loop_code, sizeof(loop_code));
......
......@@ -2577,10 +2577,7 @@ static NTSTATUS call_stack_handlers( EXCEPTION_RECORD *rec, CONTEXT *orig_contex
}
/*******************************************************************
* NtRaiseException (NTDLL.@)
*/
NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
static NTSTATUS raise_exception( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
{
NTSTATUS status;
......@@ -2615,8 +2612,6 @@ NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL
TRACE(" r12=%016lx r13=%016lx r14=%016lx r15=%016lx\n",
context->R12, context->R13, context->R14, context->R15 );
}
status = send_debug_event( rec, TRUE, context );
if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED) goto done;
/* fix up instruction pointer in context for EXCEPTION_BREAKPOINT */
if (rec->ExceptionCode == EXCEPTION_BREAKPOINT) context->Rip--;
......@@ -2647,6 +2642,24 @@ done:
}
/*******************************************************************
* NtRaiseException (NTDLL.@)
*/
NTSTATUS WINAPI NtRaiseException( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_chance )
{
NTSTATUS status;
if (first_chance)
{
status = send_debug_event( rec, TRUE, context );
if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED)
return NtSetContextThread( GetCurrentThread(), context );
}
return raise_exception( rec, context, first_chance);
}
/**********************************************************************
* raise_generic_exception
*
......@@ -2763,6 +2776,7 @@ static void setup_raise_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec
{
struct stack_layout *stack = CONTAINING_RECORD( rec, struct stack_layout, rec );
ULONG64 *rsp_ptr;
NTSTATUS status;
if (rec->ExceptionCode == EXCEPTION_SINGLE_STEP)
{
......@@ -2782,12 +2796,19 @@ static void setup_raise_exception( ucontext_t *sigcontext, EXCEPTION_RECORD *rec
stack->context.EFlags &= ~0x100; /* clear single-step flag */
}
status = send_debug_event( rec, TRUE, &stack->context );
if (status == DBG_CONTINUE || status == DBG_EXCEPTION_HANDLED)
{
restore_context( &stack->context, sigcontext );
return;
}
/* store return address and %rbp without aligning, so that the offset is fixed */
rsp_ptr = (ULONG64 *)RSP_sig(sigcontext) - 16;
*(--rsp_ptr) = RIP_sig(sigcontext);
*(--rsp_ptr) = RBP_sig(sigcontext);
*(--rsp_ptr) = RDI_sig(sigcontext);
*(--rsp_ptr) = RSI_sig(sigcontext);
*(--rsp_ptr) = stack->context.Rip;
*(--rsp_ptr) = stack->context.Rbp;
*(--rsp_ptr) = stack->context.Rdi;
*(--rsp_ptr) = stack->context.Rsi;
/* now modify the sigcontext to return to the raise function */
RIP_sig(sigcontext) = (ULONG_PTR)raise_func_trampoline;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment