From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31067 invoked by alias); 25 Nov 2009 17:52:10 -0000 Received: (qmail 31055 invoked by uid 22791); 25 Nov 2009 17:52:09 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 25 Nov 2009 17:51:56 +0000 Received: from zps35.corp.google.com (zps35.corp.google.com [172.25.146.35]) by smtp-out.google.com with ESMTP id nAPHpqk3011595 for ; Wed, 25 Nov 2009 17:51:53 GMT Received: from ppluzhnikov.mtv.corp.google.com (ppluzhnikov.mtv.corp.google.com [172.18.118.92]) by zps35.corp.google.com with ESMTP id nAPHpnR9013852; Wed, 25 Nov 2009 09:51:50 -0800 Received: by ppluzhnikov.mtv.corp.google.com (Postfix, from userid 74925) id BB89D76D99; Wed, 25 Nov 2009 09:51:49 -0800 (PST) To: gdb-patches@sourceware.org Cc: ppluzhnikov@google.com Subject: [RFC] Interaction between HW watchpoints and 'set var'. Message-Id: <20091125175149.BB89D76D99@ppluzhnikov.mtv.corp.google.com> Date: Wed, 25 Nov 2009 17:52:00 -0000 From: ppluzhnikov@google.com (Paul Pluzhnikov) 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: 2009-11/txt/msg00551.txt.bz2 Greetings, Consider the following test case: --- cut --- int x; int main() { int i, j; for (i = 0; i < 500; ++i) { j = 0; // break here x = 42; j = i; // expect HW watchpoint stop } return 0; } --- cut --- gdb64-cvs -q ./a.out Reading symbols from /tmp/a.out...done. (gdb) b 7 Breakpoint 1 at 0x400455: file foo.c, line 7. (gdb) r Breakpoint 1, main () at foo.c:7 7 j = 0; // break here (gdb) watch x Hardware watchpoint 2: x (gdb) c Hardware watchpoint 2: x Old value = 0 New value = 42 main () at foo.c:9 9 j = i; // expect HW watchpoint stop (gdb) c Breakpoint 1, main () at foo.c:7 7 j = 0; // break here So far, everything is working just as one would expect. (gdb) p x $1 = 42 (gdb) set var x = 1 (gdb) print x $2 = 1 (gdb) c Breakpoint 1, main () at foo.c:7 7 j = 0; // break here (gdb) print x $3 = 42 Why didn't HW watchpoint fire? Clearly 'x' changed from 1 to 42. Setting 'debug infrun' shows that the watchpoint does indeed fire, but is ignored by watchpoint_check() because GDB thinks the old value was 42 as well. And GDB believes that because value_assign() does not update breakpoints. Now, I can fix that by installing deprecated_memory_changed_hook, but the deprecated part gives me pause. Should I create a new memory_changed observer and remove deprecated_memory_changed_hook instead? Thanks, -- Paul Pluzhnikov