From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10814 invoked by alias); 8 May 2006 12:41:34 -0000 Received: (qmail 10804 invoked by uid 22791); 8 May 2006 12:41:34 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 08 May 2006 12:41:29 +0000 Received: from farnswood.snap.net.nz (p202-124-115-6.snap.net.nz [202.124.115.6]) by viper.snap.net.nz (Postfix) with ESMTP id E1C377582BD; Tue, 9 May 2006 00:41:26 +1200 (NZST) Received: by farnswood.snap.net.nz (Postfix, from userid 500) id 57B0A627ED; Mon, 8 May 2006 13:40:44 +0100 (BST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17503.15435.371371.707494@farnswood.snap.net.nz> Date: Mon, 08 May 2006 12:41:00 -0000 To: gdb-patches@sources.redhat.com Cc: Vladimir Prus Subject: [PATCH] -var-update [was Re: Variable objects: references formatting] In-Reply-To: <200605041610.16153.ghost@cs.msu.su> References: <17497.14121.225320.477428@farnswood.snap.net.nz> <200605041100.09748.ghost@cs.msu.su> <17497.43822.261192.673547@farnswood.snap.net.nz> <200605041610.16153.ghost@cs.msu.su> X-Mailer: VM 7.19 under Emacs 22.0.50.48 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00153.txt.bz2 > > However, do you see the problem with references that I mentioned earlier > > (that they don't seem to disappear from the changelist with -var-update)? > > This seems to be the case for any variable object made from a reference. > > Yes, I see that for variable object created from reference, -var-update * > always mentions that. Looking at this under debugger, it seems that the call > to my_value_equal in varobj_update compares the value of *reference* to the > value of new *referenced-to* object. This happens in my_value_equal > (varobj.c): > > static int > my_value_equal (struct value *val1, struct value *volatile val2, int > *error2) > ... > ...Alas, quick attempt to do that results in segfault, and I'm out of > time for today. Feel free to beat me to it ;-) I think this patch works. My reasoning is one of symmetry: whatever is done to val2 should also be done to val1, and that you probably don't want to change the contents of val1 (hence val3). I don't know exactly what coerce_array does, apart from convert the type from TYPE_CODE_REF to TYPE_CODE_INT or TYPE_CODE_FLOAT or whatever, so the comment might not be quite right. AFAICS it introduces no new fails into the testsuite. Then again there are no tests for references, so I guess a new one would be appropriate -- Nick http://www.inet.net.nz/~nickrob 2006-05-09 Nick Roberts * varobj.c (my_value_equal): Make it work for references. *** varobj.c 04 May 2006 22:11:38 +1200 1.60 --- varobj.c 09 May 2006 00:08:55 +1200 *************** *** 1460,1465 **** --- 1460,1466 ---- my_value_equal (struct value *val1, struct value *volatile val2, int *error2) { volatile struct gdb_exception except; + struct value *val3; /* As a special case, if both are null, we say they're equal. */ if (val1 == NULL && val2 == NULL) *************** *** 1470,1475 **** --- 1471,1479 ---- /* The contents of VAL1 are supposed to be known. */ gdb_assert (!value_lazy (val1)); + /* Make sure we get the contents of VAL1. */ + val3 = coerce_array (val1); + /* Make sure we also know the contents of VAL2. */ val2 = coerce_array (val2); TRY_CATCH (except, RETURN_MASK_ERROR) *************** *** 1484,1490 **** } gdb_assert (!value_lazy (val2)); ! return value_contents_equal (val1, val2); } /* FIXME: The following should be generic for any pointer */ --- 1488,1494 ---- } gdb_assert (!value_lazy (val2)); ! return value_contents_equal (val3, val2); } /* FIXME: The following should be generic for any pointer */