From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32166 invoked by alias); 15 Jan 2006 11:21:08 -0000 Received: (qmail 32139 invoked by uid 22791); 15 Jan 2006 11:21:03 -0000 X-Spam-Check-By: sourceware.org Received: from ausmtp03.au.ibm.com (HELO ausmtp03.au.ibm.com) (202.81.18.151) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 15 Jan 2006 11:21:01 +0000 Received: from sd0208e0.au.ibm.com (d23rh904.au.ibm.com [202.81.18.202]) by ausmtp03.au.ibm.com (8.12.10/8.12.10) with ESMTP id k0FBO69Z067012 for ; Sun, 15 Jan 2006 22:24:10 +1100 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.250.242]) by sd0208e0.au.ibm.com (8.12.10/NCO/VERS6.8) with ESMTP id k0FBNwe4257766 for ; Sun, 15 Jan 2006 22:23:58 +1100 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.12.11/8.13.3) with ESMTP id k0FBKpBC022137 for ; Sun, 15 Jan 2006 22:20:51 +1100 Received: from wks190239wss.cn.ibm.com (wks190239wss.cn.ibm.com [9.181.133.187] (may be forged)) by d23av01.au.ibm.com (8.12.11/8.12.11) with ESMTP id k0FBKnBo022119; Sun, 15 Jan 2006 22:20:50 +1100 Date: Sun, 15 Jan 2006 11:21:00 -0000 From: Wu Zhou To: gdb@sources.redhat.com cc: anton@au1.ibm.com, pgilliam@us.ibm.com Subject: A problem about read / access watchpoint Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-01/txt/msg00118.txt.bz2 In the process of writing a testcase for read / access watchpoint, I find something very strange: read/access watchpoints don't always work as expected. Here is a simplified example: 1 #include 2 3 int var0 = 0; 4 5 void subr (int *var1) 6 { 7 printf ("just to do sth\n"); 8 } 9 10 void main (int argc, char **argv) 11 { 12 int var1 = 0; 13 14 subr (&var1); 15 var0 = var1; 16 printf ("var0 = %d, var1 = %d\n", var0, var1); 17 } if I set read watchpoint on var1, it will only catch the watchpoint at the line 16 (for both x86 and ppc64). In my opinion, it should stop at line 15 as well. if I set access watchpoint on var1, it will stop at line 12, 15, 16 on ppc64, and only stop line 12, 16 on x86. I did some tracing on that, and find that the kernel _did_ issue signal trap on line 15, and gdb could also get the stopped data address by ptrace. But when gdb call watchpoint_check to check if the value changed or not. It will reports WP_VALUE_CHANGED, which really confuse me. I am now reading the code of watchpoint_check, but I don't understand why it will compare the new_val with b->val, and not bs->old_value. The code following the comparison is also out of my understanding: struct value *mark = value_mark (); struct value *new_val = evaluate_expression (bs->breakpoint_at->exp); if (!value_equal (b->val, new_val)) { release_value (new_val); value_free_to_mark (mark); bs->old_val = b->val; b->val = new_val; /* We will stop here */ return WP_VALUE_CHANGED; } Anyone can help me out of this question? Thanks a lot. Regards - Wu Zhou