From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5889 invoked by alias); 22 Sep 2009 12:55:41 -0000 Received: (qmail 5878 invoked by uid 22791); 22 Sep 2009 12:55:38 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.157) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Sep 2009 12:55:33 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.2/jtpda-5.5pre1) with ESMTP id n8MCsKNl047962 ; Tue, 22 Sep 2009 14:54:20 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) Received: from mailserver.u-strasbg.fr (ms3.u-strasbg.fr [IPv6:2001:660:2402:d::12]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id n8MCsKBD019371 ; Tue, 22 Sep 2009 14:54:20 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) Received: from d620muller (www-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id n8MCsJBN014346 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) ; Tue, 22 Sep 2009 14:54:19 +0200 (CEST) (envelope-from muller@ics.u-strasbg.fr) From: "Pierre Muller" To: "'Eli Zaretskii'" , "'Joel Brobecker'" , "'Mark Kettenis'" Cc: References: <000601c9e4a3$b2f2f980$18d8ec80$@u-strasbg.fr> <000001c9e4de$6e550cb0$4aff2610$@u-strasbg.fr> <000301c9e4e6$b40c5d50$1c2517f0$@u-strasbg.fr> <001501c9e523$feffc1c0$fcff4540$@u-strasbg.fr> <000301c9eed3$c7239d80$556ad880$@u-strasbg.fr> <20090622205616.GD7766@adacore.com> In-Reply-To: Subject: [RFA-v3] Fix a windows bug if two watchpoints are used Date: Tue, 22 Sep 2009 12:55:00 -0000 Message-ID: <000301ca3b83$d15fee00$741fca00$@u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: 2009-09/txt/msg00699.txt.bz2 Mark never answered that thread, as a result, this one line patch that fixes a problem with multiple watches for windows is not in 7.0 branch :( The thread started here: http://sourceware.org/ml/gdb-patches/2009-06/msg00054.html with http://sourceware.org/ml/gdb-patches/2009-06/msg00416.html containing the final one code line patch. Mark, could you give your impression? Thanks in advance, Pierre Muller Pascal language support maintainer for GDB PS: I tested the patch on Compile Farm, on a amd64 linux, no failure on new watchpoints.exp test, nor on CVS head nor with patched version. 2009-09-22 Pierre Muller * i386-nat.c (i386_stopped_data_address): Also check that hitted watch register is not vacant. gdb/testsuite ChangeLog entry: 2009-09-22 Pierre Muller New test for two watchpoints, with disabling of the first inserted. * testsuite/gdb.base/watchpoints.c: New file. * testsuite/gdb.base/watchpoints.exp: New file. Index: src/gdb/i386-nat.c =================================================================== RCS file: /cvs/src/src/gdb/i386-nat.c,v retrieving revision 1.24 diff -u -p -r1.24 i386-nat.c --- src/gdb/i386-nat.c 2 Jul 2009 17:21:06 -0000 1.24 +++ src/gdb/i386-nat.c 22 Sep 2009 08:25:36 -0000 @@ -555,7 +555,10 @@ i386_stopped_data_address (struct target that GDB doesn't call the target_stopped_data_address method except for data watchpoints. In other words, I'm being paranoiac. */ - && I386_DR_GET_RW_LEN (i) != 0) + && I386_DR_GET_RW_LEN (i) != 0 + /* This third condition makes sure DRi is not vacant, this + avoids false positives in windows-nat.c. */ + && !I386_DR_VACANT (i)) { addr = dr_mirror[i]; rc = 1; Index: src/gdb/testsuite/gdb.base/watchpoints.c =================================================================== RCS file: testsuite/gdb.base/watchpoints.c diff -N testsuite/gdb.base/watchpoints.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/testsuite/gdb.base/watchpoints.c 25 Jun 2009 22:44:17 -0000 @@ -0,0 +1,33 @@ +#include +#include +/* + * This source is mainly to test + * what happens when a watchpoint is removed + * while another watchpoint, inserted later is + * left active. + */ + +int count = -1; +int ival1 = -1; +int ival2 = -1; +int ival3 = -1; +int ival4 = -1; + +int +main () +{ +#ifdef usestubs + set_debug_traps(); + breakpoint(); +#endif + + for (count = 0; count < 4; count++) { + ival1 = count; ival2 = count; + ival3 = count; ival4 = count; + } + + ival1 = count; ival2 = count; /* Outside loop */ + ival3 = count; ival4 = count; + + return 0; +} Index: src/gdb/testsuite/gdb.base/watchpoints.exp =================================================================== RCS file: testsuite/gdb.base/watchpoints.exp diff -N testsuite/gdb.base/watchpoints.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/testsuite/gdb.base/watchpoints.exp 25 Jun 2009 22:44:17 -0000 @@ -0,0 +1,101 @@ +# Copyright 2009 +# Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# This file was written by Pierre Muller. (muller@ics.u-strasbg.fr) + +if $tracelevel then { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +set testfile "watchpoints" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +set wp_set 1 + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested watchpoint.exp + return -1 +} + +# Start with a fresh gdb. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load $binfile + + runto_main + gdb_test "watch ival1" "" "" + gdb_test "watch ival3" "" "" + + set timeout 600 + + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = -1.*New value = 0.*ival1 = count; ival2 = count;.*" "watchpoint hit, first time" + + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = -1.*New value = 0.*ival3 = count; ival4 = count;.*" "watchpoint hit, first time" + + # Check that the ival3 hit count is reported correctly + gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 1 time.*" "Watchpoint hit count is 1" + + # Continue until the next change for ival1, from 0 to 1. + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = 0.*New value = 1.*ival1 = count; ival2 = count;.*" "watchpoint ival1 hit, second time" + + # Check that the hit count for ival1 is reported correctly + gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival1\r\n\[ \t]+breakpoint already hit 2 times.*" "Watchpoint ival1 hit count is 2" + + # Continue until the next change for ival3, from 0 to 1. + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 0.*New value = 1.*ival3 = count; ival4 = count;.*" "watchpoint hit, second time" + + # Check that the hit count is reported correctly + gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 2 times.*" "Watchpoint hit count is 2" + + # Continue until the next change, from 1 to 2. + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival1.*Old value = 1.*New value = 2.*ival1 = count; ival2 = count;.*" "watchpoint ival1 hit, third time" + + # Check that the hit count is reported correctly + gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival1\r\n\[ \t]+breakpoint already hit 3 times.*" "Watchpoint ival1 hit count is 3" + # Disable ival1 watchpoint + gdb_test "disable 2" "" "" + + # Continue until the next change, from 1 to 2. + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 1.*New value = 2.*ival3 = count; ival4 = count;.*" "watchpoint hit, third time" + + # Check that the hit count is reported correctly + gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 3 times.*" "Watchpoint hit count is 3" + + # Continue until the next change, from 2 to 3. + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 2.*New value = 3.*ival3 = count; ival4 = count;.*" "watchpoint hit, fourth time" + + # Check that the hit count is reported correctly + gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 4 times.*" "Watchpoint hit count is 4" + + # Continue until the next change, from 3 to 4. + # Note that this one is outside the loop. + + gdb_test "cont" "Continuing.*\[Ww\]atchpoint.*ival3.*Old value = 3.*New value = 4.*ival3 = count; ival4 = count;.*" "watchpoint hit, fifth time" + + # Check that the hit count is reported correctly + gdb_test "info break" ".*watchpoint\[ \t\]+keep\[ \t\]+y\[ \t\]+ival3\r\n\[ \t]+breakpoint already hit 5 times.*" "Watchpoint hit count is 5" + +