From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13050 invoked by alias); 21 Sep 2011 15:33:09 -0000 Received: (qmail 13030 invoked by uid 22791); 21 Sep 2011 15:33:08 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Sep 2011 15:32:49 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=EU1-MAIL.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1R6On2-0007jL-ET from pedro_alves@mentor.com ; Wed, 21 Sep 2011 08:32:48 -0700 Received: from scottsdale.localnet ([172.16.63.104]) by EU1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.1830); Wed, 21 Sep 2011 16:32:46 +0100 From: Pedro Alves To: Jan Kratochvil Subject: Re: [patch 11/12] entryval#2: @entry values even for references Date: Wed, 21 Sep 2011 15:54:00 -0000 User-Agent: KMail/1.13.6 (Linux/2.6.38-11-generic; KDE/4.7.0; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <20110913195046.GL12849@host1.jankratochvil.net> <201109161326.09350.pedro@codesourcery.com> <20110916182434.GA12066@host1.jankratochvil.net> In-Reply-To: <20110916182434.GA12066@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201109211632.44816.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-09/txt/msg00390.txt.bz2 On Friday 16 September 2011 19:24:34, Jan Kratochvil wrote: > On Fri, 16 Sep 2011 14:26:09 +0200, Pedro Alves wrote: > > On Tuesday 13 September 2011 20:50:47, Jan Kratochvil wrote: > > > + struct value *deref_val; > > > + > > > + deref_val = coerce_ref_if_computed (original_value); > > > > Hmm, this doesn't look right. It ignores embedded_offset. What if the reference > > we're currently printing is a field of a struct at offset != 0? > > E.g., `struct { long l; long &r } foo;', and we're `p foo', which descends > > into printing R at FOO + offset of R ? > > It is not perfect but I do not know about some short way out. > > coerce_ref_if_computed currently can have effect only for @entry values > (only entry_data_value_funcs has coerce_ref != NULL) and in such case the > first printing code will have embedded_offset == 0 and further printing gets But not in the example I gave? Or are you saying that there can't be an entryval whose type is a struct? If that's the case, I'm okay with the assert for now. > resolved via common_val_print passed the dereferenced value with > original_value no longer present anywhere. > > If it should work really correctly there are more cases to catch such as > f77_print_array (*) being passed original_value etc. The correct way would be > the rework to full struct value * printing > http://sourceware.org/ml/gdb-patches/2010-10/msg00127.html > but I did not want to get deeper in the patchset dependencies. I'm not sure that'd be necessary. (the first 2 steps are complete, btw). That would change the running-offset scheme, allowing value contents to be even more lazy, but that does not mean the current scheme doesn't work. E.g, if entryval's lval_funcs->coerce_ref took an embedded_offset, and returned the target value with value_offset adjusted you'd be almost there? The problem is that you share/refcount the target value, so we'd either need to unshare it so we could have copies with different offsets set, or we'd add a new lval_computed type that serves as view with offset into a current value, as I proposed in that URL, but without changing everything else in valprint. > (*) Fortran support is planned for entry_values, it was even AFAIK one of the > reasons for DW_AT_GNU_call_site_data_value at all, it waits now on > gcc PR debug/49981 but that can be incremental GDB update later. > > Is it OK this way? > > + deref_val = coerce_ref_if_computed (original_value); > + if (deref_val != NULL) > + { > + /* More complicated computed references are not supported. */ > + gdb_assert (embedded_offset == 0); > + } > + else -- Pedro Alves