From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 53B2B3AA981B for ; Wed, 28 Apr 2021 16:59:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 53B2B3AA981B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x42a.google.com with SMTP id a4so63834379wrr.2 for ; Wed, 28 Apr 2021 09:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=TIBubYy363fr7v/i4AhS7xpcoskpsbk1dzoLYMwHSI0=; b=AMrN3bBd0nva1TVtxWOtf1YyoiO3GVqeHti+fUhjLkbpxOEkYwRuUECMY6RfHzkZ45 pGx0RQbB0nW0v9fkXcsJFbhtbEi6+zvJWVgU3qUduyQkIC2wPvoewt9H8PJJWdic1aos +a7WIDRzEmpp1i+cHTfP5JFxTlyX/X9IGgMlkgJ5DF/dQdhjUySnqCDUEAFR4gLC1NSn M/TNYdaYlL6jrXGJr+aAD8yihGXmoObufMFuh603O5g0Opfo51IdV5rQ1a9SIfoN5Vnu A+9b5S9Ex0DP+SgIn8uT6V/GXag5yGyPtu3ENoaoZ/gsCXxjbTDXdzeIq6YMxruZMmuM 1eqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=TIBubYy363fr7v/i4AhS7xpcoskpsbk1dzoLYMwHSI0=; b=jViqUr/1NT6FgwlVLhy+DqS/1Ald4ceZRhoqHM5LnFdp2GpK0SrVsRu8o+Qg0LuG3/ fC44dh/BcGqWPqLI2mgne93L7g58IaDJX10tGd0hewnfd9e23D4xGajU+sTfeqKSHAwW 1EWsAyYEuug80bV5Vh4tMqAEOdYTinfAG019+ntzlTlGr4fAOBPst8C71/XHYx3cAOfK 9eb3pFKRnYtV+5TxrTACzL+D26/eW9IxVZP8EUo/GjZ/3EeSWO3DSaWKicWX9ZzYBuwm DT+hBmCDJairFafanvjqvsuAjA5F9A8G6lGqs/bGEkqiyPrJXiklcrBOpCCKz/qDx7ju xdtw== X-Gm-Message-State: AOAM531ivOkys3iJ/mSZtiD2B5r7aj5FKmQ5CU/alBAU/O5AJmk0GkW1 xov1okUqr5QF4qrgoHGTr4OURmfFFQ3v5Q== X-Google-Smtp-Source: ABdhPJyo24bQJ7cNrrXUmZPqWca3SpAB2KIms20NLM/dwubPkH6AiaSluwSZ9Dh6tCDHBv/87MxfNQ== X-Received: by 2002:adf:84e6:: with SMTP id 93mr35714657wrg.376.1619629186381; Wed, 28 Apr 2021 09:59:46 -0700 (PDT) Received: from localhost (host109-151-46-70.range109-151.btcentralplus.com. [109.151.46.70]) by smtp.gmail.com with ESMTPSA id z7sm456865wrl.11.2021.04.28.09.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 09:59:46 -0700 (PDT) Date: Wed, 28 Apr 2021 17:59:45 +0100 From: Andrew Burgess To: George Barrett Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v3 2/3] Guile: add {r,}value-reference-value Message-ID: <20210428165945.GB2364578@embecosm.com> References: <&e1lx8mojs1b03hu3o_asydo0za8-nyh&337akgbzjn.o13/-otj@mail.bob131.so> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux/5.8.18-100.fc31.x86_64 (x86_64) X-Uptime: 17:56:23 up 18 days, 3:43, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Apr 2021 16:59:49 -0000 * George Barrett via Gdb-patches [2021-04-29 02:27:37 +1000]: > The Guile API doesn't currently have an equivalent to the Python API's > Value.reference_value() or Value.rvalue_reference_value(). This commit > adds a procedure with equivalent semantics to the Guile API. Thank you for doing this work. I'm sorry to be a real pain, but could you rename the second new function to value-rvalue-reference-value please, I think this would be inline with the existing naming convention; the first 'value-' indicates that the function applies to something of value type, and the rest of the name 'rvalue-reference-value' indicates what you're going to get. If you just make the rename as suggested, then this patch is approved. Thanks, Andrew > > gdb/ChangeLog: > > 2021-04-29 George Barrett > > * guile/scm-value.c (gdbscm_reference_value): Add helper > function for reference value creation. > (gdbscm_value_reference_value): Add implementation of > value-reference-value procedure. > (gdbscm_rvalue_reference_value): Add implementation of > rvalue-reference-value procedure. > (value_functions): Add value-reference-value procedure. > Add rvalue-reference-value procedure. > * NEWS (Guile API): Note the addition of new procedures. > > gdb/doc/ChangeLog: > > 2021-04-29 George Barrett > > * guile.texi (Values From Inferior In Guile): Add > documentation for value-reference-value. > Add documentation for rvalue-reference-value. > > gdb/testsuite/ChangeLog: > > 2021-04-29 George Barrett > > * gdb.guile/scm-value.exp (test_value_in_inferior): Add test > for value-reference-value. > Add test for rvalue-reference-value. > --- > gdb/NEWS | 3 ++ > gdb/doc/guile.texi | 10 +++++++ > gdb/guile/scm-value.c | 42 +++++++++++++++++++++++++++ > gdb/testsuite/gdb.guile/scm-value.exp | 10 +++++++ > 4 files changed, 65 insertions(+) > > diff --git a/gdb/NEWS b/gdb/NEWS > index 9c76df8b6d5..0c51f5fceca 100644 > --- a/gdb/NEWS > +++ b/gdb/NEWS > @@ -192,6 +192,9 @@ QMemTags > value-referenced-value procedure now handles rvalue reference > values. > > + ** New procedures for obtaining reference values: > + value-reference-value and rvalue-reference-value. > + > *** Changes in GDB 10 > > * There are new feature names for ARC targets: "org.gnu.gdb.arc.core" > diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi > index c7904574002..18782bb7589 100644 > --- a/gdb/doc/guile.texi > +++ b/gdb/doc/guile.texi > @@ -801,6 +801,16 @@ The @code{} object @code{scm-val} is identical to that > corresponding to @code{val}. > @end deffn > > +@deffn {Scheme Procedure} value-reference-value value > +Return a new @code{} object which is a reference to the value > +encapsulated by @code{} object @var{value}. > +@end deffn > + > +@deffn {Scheme Procedure} rvalue-reference-value value > +Return a new @code{} object which is an rvalue reference to > +the value encapsulated by @code{} object @var{value}. > +@end deffn > + > @deffn {Scheme Procedure} value-field value field-name > Return field @var{field-name} from @code{} object @var{value}. > @end deffn > diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c > index f50e8b5b46c..2ab193f044a 100644 > --- a/gdb/guile/scm-value.c > +++ b/gdb/guile/scm-value.c > @@ -488,6 +488,38 @@ gdbscm_value_referenced_value (SCM self) > }); > } > > +static SCM > +gdbscm_reference_value (SCM self, enum type_code refcode) > +{ > + value_smob *v_smob > + = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); > + struct value *value = v_smob->value; > + > + return gdbscm_wrap ([=] > + { > + scoped_value_mark free_values; > + > + struct value *res_val = value_ref (value, refcode); > + return vlscm_scm_from_value (res_val); > + }); > +} > + > +/* (value-reference-value ) -> */ > + > +static SCM > +gdbscm_value_reference_value (SCM self) > +{ > + return gdbscm_reference_value (self, TYPE_CODE_REF); > +} > + > +/* (rvalue-reference-value ) -> */ > + > +static SCM > +gdbscm_rvalue_reference_value (SCM self) > +{ > + return gdbscm_reference_value (self, TYPE_CODE_RVALUE_REF); > +} > + > /* (value-type ) -> */ > > static SCM > @@ -1352,6 +1384,16 @@ For example, for a value which is a reference to an 'int' pointer ('int *'),\n\ > value-dereference will result in a value of type 'int' while\n\ > value-referenced-value will result in a value of type 'int *'." }, > > + { "value-reference-value", 1, 0, 0, > + as_a_scm_t_subr (gdbscm_value_reference_value), > + "\ > +Return a object which is a reference to the given value." }, > + > + { "rvalue-reference-value", 1, 0, 0, > + as_a_scm_t_subr (gdbscm_rvalue_reference_value), > + "\ > +Return a object which is an rvalue reference to the given value." }, > + > { "value-field", 2, 0, 0, as_a_scm_t_subr (gdbscm_value_field), > "\ > Return the specified field of the value.\n\ > diff --git a/gdb/testsuite/gdb.guile/scm-value.exp b/gdb/testsuite/gdb.guile/scm-value.exp > index 191af1d71a6..883c4bea72e 100644 > --- a/gdb/testsuite/gdb.guile/scm-value.exp > +++ b/gdb/testsuite/gdb.guile/scm-value.exp > @@ -173,6 +173,16 @@ proc test_value_in_inferior {} { > "get string beyond null" > gdb_test "gu (print nullst)" \ > "= divide\\\\000et" > + > + gdb_scm_test_silent_cmd "gu (define argv-ref (value-reference-value argv))" \ > + "test value-reference-value" > + gdb_test "gu (equal? argv (value-referenced-value argv-ref))" "#t" > + gdb_test "gu (eqv? (type-code (value-type argv-ref)) TYPE_CODE_REF)" "#t" > + > + gdb_scm_test_silent_cmd "gu (define argv-rref (rvalue-reference-value argv))" \ > + "test rvalue-reference-value" > + gdb_test "gu (equal? argv (value-referenced-value argv-rref))" "#t" > + gdb_test "gu (eqv? (type-code (value-type argv-rref)) TYPE_CODE_RVALUE_REF)" "#t" > } > > proc test_strings {} { > -- > 2.30.2