Jacek Caban : server: Don't change cached thread context in set_thread_context.
Alexandre Julliard
julliard at winehq.org
Wed Apr 22 15:29:26 CDT 2020
Module: wine
Branch: master
Commit: 80ceafc2a1da1630be7665ca5d960a2972f9689e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=80ceafc2a1da1630be7665ca5d960a2972f9689e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Apr 22 14:31:18 2020 +0200
server: Don't change cached thread context in set_thread_context.
Let the caller take care of that.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
server/mach.c | 13 +------------
server/ptrace.c | 14 --------------
server/thread.c | 2 +-
3 files changed, 2 insertions(+), 27 deletions(-)
diff --git a/server/mach.c b/server/mach.c
index 3690b29004..69f3ee22a9 100644
--- a/server/mach.c
+++ b/server/mach.c
@@ -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
}
diff --git a/server/ptrace.c b/server/ptrace.c
index 6be1591d54..49347791d8 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -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();
diff --git a/server/thread.c b/server/thread.c
index 0d3cb28f5c..534fab6597 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -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;
}
}
More information about the wine-cvs
mailing list