From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20561 invoked by alias); 21 Dec 2007 14:02:04 -0000 Received: (qmail 20532 invoked by uid 22791); 21 Dec 2007 14:02:02 -0000 X-Spam-Check-By: sourceware.org Received: from ics.u-strasbg.fr (HELO ics.u-strasbg.fr) (130.79.112.250) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 21 Dec 2007 14:01:16 +0000 Received: from ICSMULLER (laocoon.u-strasbg.fr [130.79.112.72]) by ics.u-strasbg.fr (Postfix) with ESMTP id 87546187023; Fri, 21 Dec 2007 15:05:20 +0100 (CET) From: "Pierre Muller" To: Cc: Subject: [RFA] win32-nat.c: Fix for bug report gdb/2388 Date: Fri, 21 Dec 2007 14:31:00 -0000 Message-ID: <007101c843d9$ef5023b0$cdf06b10$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Content-Language: en-us 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: 2007-12/txt/msg00372.txt.bz2 I examined the bug report gdb/2388 Go to: http://sourceware.org/cgi-bin/gnatsweb.pl and enter number 2388 I think that this is a bug that I introduced when I first wrote the cygwin hardware watchpoint support a while ago. The problem is that there is a common dr array that keeps track of the values of all the debug registers, while, on Win32 API, each thread has its own copy of those registers. The only possible pitfall is if the program itself changes the debug registers (I do not know if this is possible, without generating a exception). The dr[6] status register, that might indicate that we did trigger a watchpoint, is anyhow set at the moment As long as we only use the same copy of dr array for all the threads, I think that the patch below should fix the reported bug. The patch simply does not overwrite dr array is debug_registers_changed is set, which happens if the i386 debug registers are changed. I tested the patch, and the SIGTRAP reported in the bug report is suppressed by my patch. I also ran the testsuite with no regressions. OK to commit? Pierre Muller ChangeLog entry: 2007-12-21 Pierre Muller * win32-nat.c: Fix PR/2388. (do_win32_fetch_inferior_registers): Do not overwrite debug register array dr if debug_registers_changed variable is set. Index: gdb/win32-nat.c =================================================================== RCS file: /cvs/src/src/gdb/win32-nat.c,v retrieving revision 1.143 diff -u -p -r1.143 win32-nat.c --- gdb/win32-nat.c 6 Dec 2007 11:17:03 -0000 1.143 +++ gdb/win32-nat.c 20 Dec 2007 15:11:42 -0000 @@ -382,13 +382,17 @@ do_win32_fetch_inferior_registers (struc thread_info *th = current_thread; th->context.ContextFlags = CONTEXT_DEBUGGER_DR; GetThreadContext (th->h, &th->context); - /* Copy dr values from that thread. */ - dr[0] = th->context.Dr0; - dr[1] = th->context.Dr1; - dr[2] = th->context.Dr2; - dr[3] = th->context.Dr3; - dr[6] = th->context.Dr6; - dr[7] = th->context.Dr7; + /* Copy dr values from that thread. + But only if there were not modified since last stop. PR gdb/2388 */ + if (!debug_registers_changed) + { + dr[0] = th->context.Dr0; + dr[1] = th->context.Dr1; + dr[2] = th->context.Dr2; + dr[3] = th->context.Dr3; + dr[6] = th->context.Dr6; + dr[7] = th->context.Dr7; + } } current_thread->reload_context = 0; }