From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7481 invoked by alias); 21 Oct 2011 17:13:19 -0000 Received: (qmail 7464 invoked by uid 22791); 21 Oct 2011 17:13:15 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Oct 2011 17:13:00 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id CF9882BB49E; Fri, 21 Oct 2011 13:12:59 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id z3er2dgB7TIJ; Fri, 21 Oct 2011 13:12:59 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 9D1B22BB485; Fri, 21 Oct 2011 13:12:59 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 031E3145615; Fri, 21 Oct 2011 13:12:56 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [RFA/gdbserver] Fix watchpoint support on Windows Date: Fri, 21 Oct 2011 17:23:00 -0000 Message-Id: <1319217176-3782-1-git-send-email-brobecker@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00597.txt.bz2 Watchpoint support doesn't work anymore when using gdbserver on Windows. They just never trigger. The problem comes from the fact that we always set the debug registers to zero, no matter what. This in turn comes from the fact that we use i386_low_insert_watchpoint to compute the DR values: return i386_low_insert_watchpoint (&debug_reg_state, type, addr, len); This function saves the new values in debug_reg_state. However, the values we actually use when setting the DR registers are taken from two different globals: static unsigned dr_status_mirror; static unsigned dr_control_mirror; These are really never actually changed (their value is set from the DR values read from the inferior, but since we never change them, in practice, they never change). The fix is to use the values provided by debug_reg_state, and to eliminate the two dr_[...] globals. gdb/gdbserver/ChangeLog: * win32-i386-low.c (dr_status_mirror, dr_control_mirror): Delete. (i386_dr_low_get_control, i386_dr_low_get_status): Use dr_status_mirror and dr_control_mirror from debug_reg_state. (i386_dr_low_get_status): Use debug_reg_state.dr_status_mirror (i386_initial_stuff): Remove use of deleted globals. (i386_get_thread_context, i386_set_thread_context, i386_thread_added): Use dr_status_mirror and dr_control_mirror from debug_reg_state. OK to commit? Thanks, -- Joel --- gdb/gdbserver/win32-i386-low.c | 20 ++++++++------------ 1 files changed, 8 insertions(+), 12 deletions(-) diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c index c29b9b0..19629c9 100644 --- a/gdb/gdbserver/win32-i386-low.c +++ b/gdb/gdbserver/win32-i386-low.c @@ -37,8 +37,6 @@ void init_registers_i386 (void); #endif static struct i386_debug_reg_state debug_reg_state; -static unsigned dr_status_mirror; -static unsigned dr_control_mirror; static int debug_registers_changed = 0; static int debug_registers_used = 0; @@ -81,7 +79,7 @@ i386_dr_low_set_control (const struct i386_debug_reg_state *state) unsigned i386_dr_low_get_control (void) { - return dr_control_mirror; + return debug_reg_state.dr_control_mirror; } /* Get the value of the DR6 debug status register from the inferior @@ -92,7 +90,7 @@ i386_dr_low_get_status (void) { /* We don't need to do anything here, the last call to thread_rec for current_event.dwThreadId id has already set it. */ - return dr_status_mirror; + return debug_reg_state.dr_status_mirror; } /* Watchpoint support. */ @@ -150,8 +148,6 @@ i386_initial_stuff (void) i386_low_init_dregs (&debug_reg_state); debug_registers_changed = 0; debug_registers_used = 0; - dr_status_mirror = 0; - dr_control_mirror = 0; } static void @@ -190,8 +186,8 @@ i386_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event) dr->dr_mirror[1] = th->context.Dr1; dr->dr_mirror[2] = th->context.Dr2; dr->dr_mirror[3] = th->context.Dr3; - dr_status_mirror = th->context.Dr6; - dr_control_mirror = th->context.Dr7; + dr->dr_status_mirror = th->context.Dr6; + dr->dr_control_mirror = th->context.Dr7; } } @@ -205,9 +201,9 @@ i386_set_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event) th->context.Dr1 = dr->dr_mirror[1]; th->context.Dr2 = dr->dr_mirror[2]; th->context.Dr3 = dr->dr_mirror[3]; - /* th->context.Dr6 = dr_status_mirror; + /* th->context.Dr6 = dr->dr_status_mirror; FIXME: should we set dr6 also ?? */ - th->context.Dr7 = dr_control_mirror; + th->context.Dr7 = dr->dr_control_mirror; } SetThreadContext (th->h, &th->context); @@ -227,9 +223,9 @@ i386_thread_added (win32_thread_info *th) th->context.Dr1 = dr->dr_mirror[1]; th->context.Dr2 = dr->dr_mirror[2]; th->context.Dr3 = dr->dr_mirror[3]; - /* th->context.Dr6 = dr_status_mirror; + /* th->context.Dr6 = dr->dr_status_mirror; FIXME: should we set dr6 also ?? */ - th->context.Dr7 = dr_control_mirror; + th->context.Dr7 = dr->dr_control_mirror; SetThreadContext (th->h, &th->context); th->context.ContextFlags = 0; -- 1.7.1