From patchwork Mon Nov 27 00:48:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 24544 Received: (qmail 35403 invoked by alias); 27 Nov 2017 00:48:39 -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 35355 invoked by uid 89); 27 Nov 2017 00:48:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=worker, matcher, gil, GIL X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Nov 2017 00:48:27 +0000 X-ASG-Debug-ID: 1511743701-0c856e65d53d0e1f0001-fS2M51 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id M5AtCDUc38Et2cbF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 26 Nov 2017 19:48:21 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.lan (192-222-251-162.qc.cable.ebox.net [192.222.251.162]) by smtp.ebox.ca (Postfix) with ESMTP id C3FF8441D64; Sun, 26 Nov 2017 19:48:21 -0500 (EST) From: Simon Marchi X-Barracuda-Effective-Source-IP: 192-222-251-162.qc.cable.ebox.net[192.222.251.162] X-Barracuda-Apparent-Source-IP: 192.222.251.162 X-Barracuda-RBL-IP: 192.222.251.162 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 2/2] Remove xmethod_worker::clone Date: Sun, 26 Nov 2017 19:48:19 -0500 X-ASG-Orig-Subj: [PATCH 2/2] Remove xmethod_worker::clone Message-Id: <20171127004819.18941-2-simon.marchi@polymtl.ca> In-Reply-To: <20171127004819.18941-1-simon.marchi@polymtl.ca> References: <20171127004819.18941-1-simon.marchi@polymtl.ca> X-Barracuda-Connect: smtp.electronicbox.net[96.127.255.82] X-Barracuda-Start-Time: 1511743701 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 3335 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.45236 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-IsSubscribed: yes I think that the clone method of xmethod_worker can be removed. It is only used in find_overload_match, to clone an xmethod we want to keep. Instead, we can just std::move it out of the vector and into value_from_xmethod. value_from_xmethod creates a value that will own the xmethod_worker from that point. Other xmethod_workers left in the vector will get destroyed when the vector gets destroyed, but the chosen one will keep living inside the value struct. gdb/ChangeLog: * extension.h (struct xmethod_worker) : Remove. * python/py-xmethods.c (struct python_xmethod_worker) : Remove. (python_xmethod_worker::clone): Remove. * valops.c (find_overload_match): Use std::move instead of clone. --- gdb/extension.h | 7 ------- gdb/python/py-xmethods.c | 17 ----------------- gdb/valops.c | 2 +- 3 files changed, 1 insertion(+), 25 deletions(-) diff --git a/gdb/extension.h b/gdb/extension.h index e1f26acdc1..ebdcb34aba 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -182,13 +182,6 @@ struct xmethod_worker virtual value *invoke (value *obj, value **args, int nargs) = 0; - /* Clone this worker, returns a new but identical worker. - The function get_matching_xmethod_workers returns a vector of matching - workers. If a particular worker is selected by GDB to invoke a method, - then this function can help in cloning the selected worker. */ - - virtual std::unique_ptr clone () = 0; - /* Return the arg types of the xmethod encapsulated in this worker. An array of arg types is returned. The length of the array is returned in NARGS. The type of the 'this' object is returned as the first element of diff --git a/gdb/python/py-xmethods.c b/gdb/python/py-xmethods.c index 6d839c5dac..31d0bda647 100644 --- a/gdb/python/py-xmethods.c +++ b/gdb/python/py-xmethods.c @@ -48,10 +48,6 @@ struct python_xmethod_worker : xmethod_worker value *invoke (value *obj, value **args, int nargs) override; - /* Implementation of xmethod_worker::clone for Python. */ - - xmethod_worker_up clone () override; - /* Implementation of xmethod_worker::do_get_arg_types for Python. */ ext_lang_rc do_get_arg_types (int *nargs, type ***arg_types) override; @@ -80,19 +76,6 @@ python_xmethod_worker::~python_xmethod_worker () Py_DECREF (m_this_type); } -/* See declaration. */ - -xmethod_worker_up -python_xmethod_worker::clone () -{ - /* We don't do much here, but we still need the GIL. */ - gdbpy_enter enter_py (get_current_arch (), current_language); - - xmethod_worker *worker = new python_xmethod_worker (m_py_worker, m_this_type); - - return xmethod_worker_up (worker); -} - /* Invoke the "match" method of the MATCHER and return a new reference to the result. Returns NULL on error. */ diff --git a/gdb/valops.c b/gdb/valops.c index f9f9439b0c..32dc083752 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -2778,7 +2778,7 @@ find_overload_match (struct value **args, int nargs, } else *valp = value_from_xmethod - (xm_worker_vec[ext_method_oload_champ]->clone ()); + (std::move (xm_worker_vec[ext_method_oload_champ])); } else *symp = oload_syms[func_oload_champ];