From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113025 invoked by alias); 16 Jul 2018 13:54:36 -0000 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 Received: (qmail 113015 invoked by uid 89); 16 Jul 2018 13:54:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*M:9e43, H*Ad:U*palves, H*f:sk:490c9b6 X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Jul 2018 13:54:35 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8D3E94022414; Mon, 16 Jul 2018 13:54:33 +0000 (UTC) Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id D01C42026D65; Mon, 16 Jul 2018 13:54:32 +0000 (UTC) Subject: Re: [RFA 04/13] Call some functions in guile/ for effect To: Tom Tromey , Simon Marchi References: <20180712205208.32646-1-tom@tromey.com> <20180712205208.32646-5-tom@tromey.com> <490c9b62-f209-e5b6-e47d-615d64a39451@simark.ca> <87muuu9ekc.fsf@tromey.com> Cc: gdb-patches@sourceware.org From: Pedro Alves Message-ID: Date: Mon, 16 Jul 2018 13:54:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <87muuu9ekc.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2018-07/txt/msg00476.txt.bz2 On 07/14/2018 01:39 PM, Tom Tromey wrote: >>>>>> "Simon" == Simon Marchi writes: > > Simon> On 2018-07-12 04:51 PM, Tom Tromey wrote: >>> This changes a few spots in guile/ to remove a variable declaration >>> but to still call a function for effect. > > Simon> LGTM, though it would be nice to mention in the comments what is the > Simon> desired side-effect (if known). > > I really do not know, I just noticed that those functions can throw. No idea on the guile bits, but for this one: > --- a/gdb/guile/scm-pretty-print.c > +++ b/gdb/guile/scm-pretty-print.c > @@ -970,7 +970,9 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang, > struct cleanup *cleanups; > enum ext_lang_rc result = EXT_LANG_RC_NOP; > enum string_repr_result print_result; > - const gdb_byte *valaddr = value_contents_for_printing (val); > + > + /* Call for side effects. */ > + value_contents_for_printing (val); > > /* No pretty-printer support for unavailable values. */ > if (!value_bytes_available (val, embedded_offset ... we can't call value_bytes_available on a lazy value (because that function must be usable with values in the values history, that's why it works with a const value *), so the desired side effect here is fetching a lazy value. So I think we should replace that with: if (value_lazy (val)) value_fetch_lazy (val); The Python seems to have the same issue, so I think it'd be a little better to handle both this hunk and the equivalent bit in Python in the same patch, and in its own patch. Thanks, Pedro Alves