[PATCH 3/3] server: Set debug enable bits briefly to commit the addresses to kernel.

Grazvydas Ignotas notasas at gmail.com
Fri Jul 15 15:19:11 CDT 2011


Linux 2.6.33+ only updates debug address registers when corresponding
enable bits are set in DR7, so make sure they are set before writing
DR7 value the windows app wants.

Alternatively we could maintain local register cache and only inform
the kernel about enabled breakpoints..
---
 dlls/ntdll/tests/exception.c |    1 -
 server/ptrace.c              |    3 +++
 2 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index 9f80651..5d3f8c1 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -510,7 +510,6 @@ static void check_debug_registers(int test_num, const struct dbgreg_test *test)
     CHECK_DEBUG_REG(0, ~0);
     CHECK_DEBUG_REG(1, ~0);
     CHECK_DEBUG_REG(2, ~0);
-if (test_num == 2) todo_wine
     CHECK_DEBUG_REG(3, ~0);
     CHECK_DEBUG_REG(6, 0x0f);
     CHECK_DEBUG_REG(7, ~0xdc00);
diff --git a/server/ptrace.c b/server/ptrace.c
index 6df9555..51157ab 100644
--- a/server/ptrace.c
+++ b/server/ptrace.c
@@ -605,6 +605,8 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
         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;
         break;
@@ -620,6 +622,7 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign
         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;
         break;
-- 
1.7.0.4




More information about the wine-patches mailing list