server: Don't change cached thread context in set_thread_context.

Let the caller take care of that.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Jacek Caban 2020-04-22 14:31:18 +02:00 committed by Alexandre Julliard
parent 89b4bdd6cd
commit 80ceafc2a1
3 changed files with 2 additions and 27 deletions

View File

@ -283,18 +283,7 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
state.uds.ds32.dr7 = dr7;
#endif
}
if (!thread_set_state( port, x86_DEBUG_STATE, (thread_state_t)&state, count ))
{
if (thread->context) /* update the cached values */
{
#ifdef __x86_64__
if (thread->process->cpu == CPU_x86_64)
thread->context->debug.x86_64_regs = context->debug.x86_64_regs;
else
#endif
thread->context->debug.i386_regs = context->debug.i386_regs;
}
}
thread_set_state( port, x86_DEBUG_STATE, (thread_state_t)&state, count );
mach_port_deallocate( mach_task_self(), port );
#endif
}

View File

@ -637,36 +637,24 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
/* Linux 2.6.33+ does DR0-DR3 alignment validation, so it has to know LEN bits first */
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(7), context->debug.i386_regs.dr7 & 0xffff0000 ) == -1) goto error;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(0), context->debug.i386_regs.dr0 ) == -1) goto error;
if (thread->context) thread->context->debug.i386_regs.dr0 = context->debug.i386_regs.dr0;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(1), context->debug.i386_regs.dr1 ) == -1) goto error;
if (thread->context) thread->context->debug.i386_regs.dr1 = context->debug.i386_regs.dr1;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(2), context->debug.i386_regs.dr2 ) == -1) goto error;
if (thread->context) thread->context->debug.i386_regs.dr2 = context->debug.i386_regs.dr2;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(3), context->debug.i386_regs.dr3 ) == -1) goto error;
if (thread->context) thread->context->debug.i386_regs.dr3 = context->debug.i386_regs.dr3;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(6), context->debug.i386_regs.dr6 ) == -1) goto error;
if (thread->context) thread->context->debug.i386_regs.dr6 = context->debug.i386_regs.dr6;
/* Linux 2.6.33+ needs enable bits set briefly to update value returned by PEEKUSER later */
ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(7), context->debug.i386_regs.dr7 | 0x55 );
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(7), context->debug.i386_regs.dr7 ) == -1) goto error;
if (thread->context) thread->context->debug.i386_regs.dr7 = context->debug.i386_regs.dr7;
thread->system_regs |= SERVER_CTX_DEBUG_REGISTERS;
break;
case CPU_x86_64:
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(7), context->debug.x86_64_regs.dr7 & 0xffff0000 ) == -1) goto error;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(0), context->debug.x86_64_regs.dr0 ) == -1) goto error;
if (thread->context) thread->context->debug.x86_64_regs.dr0 = context->debug.x86_64_regs.dr0;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(1), context->debug.x86_64_regs.dr1 ) == -1) goto error;
if (thread->context) thread->context->debug.x86_64_regs.dr1 = context->debug.x86_64_regs.dr1;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(2), context->debug.x86_64_regs.dr2 ) == -1) goto error;
if (thread->context) thread->context->debug.x86_64_regs.dr2 = context->debug.x86_64_regs.dr2;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(3), context->debug.x86_64_regs.dr3 ) == -1) goto error;
if (thread->context) thread->context->debug.x86_64_regs.dr3 = context->debug.x86_64_regs.dr3;
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(6), context->debug.x86_64_regs.dr6 ) == -1) goto error;
if (thread->context) thread->context->debug.x86_64_regs.dr6 = context->debug.x86_64_regs.dr6;
ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(7), context->debug.x86_64_regs.dr7 | 0x55 );
if (ptrace( PTRACE_POKEUSER, pid, DR_OFFSET(7), context->debug.x86_64_regs.dr7 ) == -1) goto error;
if (thread->context) thread->context->debug.x86_64_regs.dr7 = context->debug.x86_64_regs.dr7;
thread->system_regs |= SERVER_CTX_DEBUG_REGISTERS;
break;
default:
@ -785,8 +773,6 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
#endif
if (ptrace( PTRACE_SETDBREGS, pid, (caddr_t)&dbregs, 0 ) != -1)
{
if (thread->context)
thread->context->debug.i386_regs = context->debug.i386_regs; /* update the cached values */
thread->system_regs |= SERVER_CTX_DEBUG_REGISTERS;
}
else file_set_error();

View File

@ -1823,7 +1823,7 @@ DECL_HANDLER(set_thread_context)
if (system_flags) set_thread_context( thread, context, system_flags );
if (thread->context && !get_error())
{
copy_context( thread->context, context, client_flags );
copy_context( thread->context, context, context->flags );
thread->context->flags |= client_flags;
}
}