From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10790 invoked by alias); 22 Jul 2011 16:40:27 -0000 Received: (qmail 10780 invoked by uid 22791); 22 Jul 2011 16:40:25 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Jul 2011 16:40:11 +0000 Received: (qmail 2483 invoked from network); 22 Jul 2011 16:40:10 -0000 Received: from unknown (HELO scottsdale.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 22 Jul 2011 16:40:10 -0000 From: Pedro Alves To: gdb-patches@sourceware.org, Thiago Jung Bauermann Subject: Re: x86 watchpoints bug (Re: ping: Re: PATCH : allow to set length of hw watchpoints (e.g. for Valgrind gdbserver)) Date: Fri, 22 Jul 2011 16:43:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-8-generic; KDE/4.6.2; x86_64; ; ) Cc: "Philippe Waroquiers" , yao@codesourcery.com References: <201107211712.26443.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Message-Id: <201107221740.07110.pedro@codesourcery.com> X-IsSubscribed: yes 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-07/txt/msg00624.txt.bz2 On Friday 22 July 2011 17:02:42, Philippe Waroquiers wrote: > During the testing, I however found something else slightly strange. > With reference to the previous s.c test program, watching a string length= 1000 > is ok at the start (handled as a sw breakpoint), but this watchpoint cann= ot be disabled > then re-enabled: > (gdb) watch s1000 > Hardware watchpoint 1: s1000 > (gdb) start <<<<<<<<<<<<<<<<<<<<<<<<<< this runs slowly as s1000 i= s sw-watched > Temporary breakpoint 2 at 0x400480: file s.c, line 22. > Starting program: /home/philippe/gdb/s=20 > Error in re-setting breakpoint 1: Expression cannot be implemented wit= h read/access watchpoint. > Error in re-setting breakpoint 1: Expression cannot be implemented wit= h read/access watchpoint. > Error in re-setting breakpoint 1: Expression cannot be implemented wit= h read/access watchpoint. >=20 > Temporary breakpoint 2, main () at s.c:22 > 22 char * p =3D s1000; > (gdb) dis 1 > (gdb) ena 1 > Cannot enable watchpoint 1: Expression cannot be implemented with read= /access watchpoint. > (gdb)=20 > At this point, if the watchpoint is deleted then re-created, then the wat= chpoint is again 'sw-accepted'. > Note that this looks to be a regression in 7.3.50.20110722-cvs, as I do n= ot see the same problem on 7.2. Hmm, I can reproduce this.=20=20 #0 error (string=3D...) at ../../src/gdb/utils.c:776 #1 0x000000000064733d in update_watchpoint (b=3D0x1f4fde0, reparse=3D1) at= ../../src/gdb/breakpoint.c:1456 #2 0x000000000065a364 in enable_breakpoint_disp (bpt=3D0x1f4fde0, disposit= ion=3Ddisp_donttouch) at ../../src/gdb/breakpoint.c:11917 1453 } 1454 else if (b->ops && b->ops->works_in_software_mode 1455 && !b->ops->works_in_software_mode (b)) 1456 error (_("Expression cannot be implemented with " 1457 "read/access watchpoint.")); 1458 else 1459 b->type =3D bp_watchpoint; (top-gdb) info symbol b->ops watchpoint_breakpoint_ops in section .data of /home/pedro/gdb/baseline/buil= d/gdb/gdb (top-gdb) info symbol b->ops->works_in_software_mode works_in_software_mode_watchpoint in section .text of /home/pedro/gdb/basel= ine/build/gdb/gdb int works_in_software_mode_watchpoint (const struct breakpoint *b) { return b->type =3D=3D bp_hardware_watchpoint; } (top-gdb) p b->type=20 $5 =3D bp_watchpoint =46rom the error string, looks like the check should be something like: else if (b->type =3D=3D bp_read_watchpoint || b->type =3D=3D bp_access_watchpoint) error (_("Expression cannot be implemented with " "read/access watchpoint.")); instead, as those watchpoints can't indeed be implemented as software watchpoints. Though the intention may have been to catch something about masked watchpoints. Maybe better would be to change works_in_software_mode_watchpoint to: int works_in_software_mode_watchpoint (const struct breakpoint *b) { - return b->type =3D=3D bp_hardware_watchpoint; + return (b->type =3D=3D bp_watchpoint || b->type =3D=3D bp_hardware_watch= point); } The error string could also be enhanced to include the real watchpoint type (so a user of masked watchpoints doesn't get confused). Thiago, WDYT? --=20 Pedro Alves