[PATCH 2/5] [Server]: correctly set the DR0..7 registers on Linux for x86_64 architecture

Eric Pouech eric.pouech at orange.fr
Tue Apr 6 15:28:30 CDT 2010




A+
---

 server/ptrace.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)


diff --git a/server/ptrace.c b/server/ptrace.c
index 4fa48ec..d1d6cdc 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -549,12 +549,21 @@ void get_thread_context( struct thread *thread, context_t *context, unsigned int
             goto done;
         }
     }
+#ifdef __i386__
     context->debug.i386_regs.dr0 = data[0];
     context->debug.i386_regs.dr1 = data[1];
     context->debug.i386_regs.dr2 = data[2];
     context->debug.i386_regs.dr3 = data[3];
     context->debug.i386_regs.dr6 = data[6];
     context->debug.i386_regs.dr7 = data[7];
+#else /* __x86_64__ */
+    context->debug.x86_64_regs.dr0 = data[0];
+    context->debug.x86_64_regs.dr1 = data[1];
+    context->debug.x86_64_regs.dr2 = data[2];
+    context->debug.x86_64_regs.dr3 = data[3];
+    context->debug.x86_64_regs.dr6 = data[6];
+    context->debug.x86_64_regs.dr7 = data[7];
+#endif
     context->flags |= SERVER_CTX_DEBUG_REGISTERS;
 done:
     resume_after_ptrace( thread );
@@ -570,6 +579,7 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
 
     if (!suspend_for_ptrace( thread )) return;
 
+#ifdef __i386__
     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;
@@ -582,6 +592,20 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
     if (thread->context) thread->context->debug.i386_regs.dr6 = context->debug.i386_regs.dr6;
     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;
+#else /* __x86_64__ */
+    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;
+    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;
+#endif
     resume_after_ptrace( thread );
     return;
  error:






More information about the wine-patches mailing list