From patchwork Wed Oct 24 19:12:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 29875 Received: (qmail 53895 invoked by alias); 24 Oct 2018 19:12:19 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53766 invoked by uid 89); 24 Oct 2018 19:12:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Gm-Message-State:AGRZ1gK, H*r:sk:f8-v6so X-HELO: mail-wm1-f65.google.com Received: from mail-wm1-f65.google.com (HELO mail-wm1-f65.google.com) (209.85.128.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 24 Oct 2018 19:12:16 +0000 Received: by mail-wm1-f65.google.com with SMTP id f8-v6so4134118wmc.3 for ; Wed, 24 Oct 2018 12:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=Qgrd5tk0gyoLnmw8ZDP/nitFcBnLfn7S5K44mTyHm/A=; b=CDwYPpiHtU9oJSVX4M+7NeitOXOaAzkKwNINRQgPy/VmPcVB2+1UcVzmtVfbFJpkY4 SkSLsfzld+Cds7vMDl7PMWWKELRqRNSwRGTPgv0uWQHT7Wu/lBidy3LOUUCLvLIJKUTT youmhz9NzqE0t3HVeuTsi/Rzh83RRds72/KfGrGJpvRJDkwun97Bf39LeK0L7M48GHIh /zD82NFdrtypnrYOsMw/l7WBm2fARashcGOQ1AOGOqztXY7BapaH7htEcR2r4vwAN7fJ e4sDySOE91WpgACp/t7bYqwF/enLTweDIxycC//5iBJSg60epLcHtDx+ycD2tRldy9/O OUnA== Return-Path: Received: from localhost (host86-164-85-193.range86-164.btcentralplus.com. [86.164.85.193]) by smtp.gmail.com with ESMTPSA id q17-v6sm5151049wrw.19.2018.10.24.12.12.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 24 Oct 2018 12:12:13 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 2/2] gdb/python: Make a function return gdbpy_ref<> Date: Wed, 24 Oct 2018 20:12:03 +0100 Message-Id: <3d0d7723dc6b3116efc41a05b573938defee801c.1540407540.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Make convert_values_to_python return a gdbpy_ref<> directly rather than building a gdbpy_ref<>, releasing it, and then having a new gdbpy_ref<> created to hold the result. I also added a header comment to convert_values_to_python. gdb/ChangeLog: * python/py-function.c (convert_values_to_python): Return gdbpy_ref<>. Add header comment. (fnpy_call): Adjust. --- gdb/ChangeLog | 6 ++++++ gdb/python/py-function.c | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gdb/python/py-function.c b/gdb/python/py-function.c index 1900f0ff0c0..cf5e68a0545 100644 --- a/gdb/python/py-function.c +++ b/gdb/python/py-function.c @@ -34,7 +34,10 @@ extern PyTypeObject fnpy_object_type -static PyObject * +/* Return a reference to a tuple ARGC elements long. Each element of the + tuple is a PyObject converted from the corresponding element of ARGV. */ + +static gdbpy_ref<> convert_values_to_python (int argc, struct value **argv) { int i; @@ -50,7 +53,7 @@ convert_values_to_python (int argc, struct value **argv) return NULL; PyTuple_SetItem (result.get (), i, elt.release ()); } - return result.release (); + return result; } /* Call a Python function object's invoke method. */ @@ -64,7 +67,7 @@ fnpy_call (struct gdbarch *gdbarch, const struct language_defn *language, gdbpy_enter enter_py (gdbarch, language); struct value *value; gdbpy_ref<> result; - gdbpy_ref<> args (convert_values_to_python (argc, argv)); + gdbpy_ref<> args = convert_values_to_python (argc, argv); /* convert_values_to_python can return NULL on error. If we encounter this, do not call the function, but allow the Python ->