From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29180 invoked by alias); 3 Mar 2009 21:18:14 -0000 Received: (qmail 29171 invoked by uid 22791); 3 Mar 2009 21:18:13 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: sourceware.org Received: from eu1sys200aog108.obsmtp.com (HELO eu1sys200aog108.obsmtp.com) (207.126.144.125) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 03 Mar 2009 21:18:07 +0000 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob108.postini.com ([207.126.147.11]) with SMTP ID DSNKSa2ejHCDSPHHb7pZoPXfIOV7UQEuuKr4@postini.com; Tue, 03 Mar 2009 21:18:07 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8C000DA4D for ; Tue, 3 Mar 2009 21:17:12 +0000 (GMT) Received: from mail1.bri.st.com (mail1.bri.st.com [164.129.8.218]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 902614C5AA for ; Tue, 3 Mar 2009 21:18:03 +0000 (GMT) Received: from [164.129.14.85] (bri1017.bri.st.com [164.129.14.85]) by mail1.bri.st.com (MOS 3.8.7a) with ESMTP id CLJ05752 (AUTH antony); Tue, 3 Mar 2009 21:18:03 GMT Message-ID: <49AD9E8A.3020608@st.com> Date: Tue, 03 Mar 2009 21:18:00 -0000 From: Antony KING User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: gdb@sourceware.org Subject: Re: [GDB 6.8] Problem using watchpoints with compound objects References: <49AD6B30.2010102@st.com> <20090303203309.GA2672@caradoc.them.org> In-Reply-To: <20090303203309.GA2672@caradoc.them.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-03/txt/msg00028.txt.bz2 The following is the example I am using: int a[4]; int main (void) { a[0] = 1; return 0; } and the GDB command is "watch a", so GDB should be watching the contents of the array object and not its address. I have also tried the following test with the same effect: struct {int m1, m2, m3, m4;} a; int main (void) { a.m1 = 1; return 0; } In both cases value_equal is comparing the address of the object and not the contents. This is caused, I believe, by the following code at the start of value_equal: arg1 = coerce_array (arg1); arg2 = coerce_array (arg2); which is converting the compound objects into pointers. These are then used in the latter tests of value_equal. Cheers, Antony. Daniel Jacobowitz wrote: > On Tue, Mar 03, 2009 at 05:38:56PM +0000, Antony KING wrote: >> After applying the patch for problem 1 I then encountered a second >> problem where a watchpoint is being erroneously dismissed as being >> unchanged. I believe this problem is due to the following test in >> watchpoint_check(): >> >> if (!value_equal (b->val, new_val)) >> >> This test is only comparing the address of the object and not its >> contents. I think the test should be revised to the following: > > What are you setting a watchpoint on? value_equal is an > implementation of the equality operator in the CLI. If you have a > pointer, it will only compare the addresses, but for a struct object > it should compare contents.