From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124595 invoked by alias); 6 Mar 2019 19:23:40 -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 124410 invoked by uid 89); 6 Mar 2019 19:23:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=BAYES_00,DNS_FROM_AHBL_RHSBL,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.1 spammy=acknowledge X-HELO: mail-wr1-f45.google.com Received: from mail-wr1-f45.google.com (HELO mail-wr1-f45.google.com) (209.85.221.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Mar 2019 19:23:30 +0000 Received: by mail-wr1-f45.google.com with SMTP id n2so14723316wrw.8 for ; Wed, 06 Mar 2019 11:23:29 -0800 (PST) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4c97:6d52:2cea:997b? ([2001:8a0:f913:f700:4c97:6d52:2cea:997b]) by smtp.gmail.com with ESMTPSA id a131sm3847430wmh.34.2019.03.06.11.23.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Mar 2019 11:23:27 -0800 (PST) Subject: Re: [PATCH v2 04/22] C++ify remote notification code To: Tom Tromey , gdb-patches@sourceware.org References: <20190227201849.32210-1-tom@tromey.com> <20190227201849.32210-5-tom@tromey.com> From: Pedro Alves Message-ID: <6f911dfb-3018-33b0-fbb1-48ece1607c1e@redhat.com> Date: Wed, 06 Mar 2019 19:23:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190227201849.32210-5-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-03/txt/msg00117.txt.bz2 On 02/27/2019 08:18 PM, Tom Tromey wrote: > This C++ifies the remote notification code -- replacing function > pointers with virtual methods and using unique_ptr. This allows for > the removal of some cleanups. > > gdb/ChangeLog > 2019-02-27 Tom Tromey > > * remote.c (struct stop_reply_deleter): Remove. > (stop_reply_up): Update. > (struct stop_reply): Derive from notif_event. Don't typedef. > : Now a std::vector. > (stop_reply_xfree): Remove. > (stop_reply::~stop_reply): Rename from stop_reply_dtr. > (remote_notif_stop_alloc_reply): Return a unique_ptr. Use new. > (remote_target::discard_pending_stop_replies): Use delete. > (remote_target::remote_parse_stop_reply): Update. > (remote_target::process_stop_reply): Update. > * remote-notif.h (struct notif_event): Add virtual destructor. > Remove "dtr" member. > (struct notif_client) : Return a unique_ptr. > (notif_event_xfree): Don't declare. > * remote-notif.c (remote_notif_ack, remote_notif_parse): Update. > (notif_event_xfree, do_notif_event_xfree): Remove. > (remote_notif_state_xfree): Update. > --- > gdb/ChangeLog | 20 ++++++++++++ > gdb/remote-notif.c | 42 ++++-------------------- > gdb/remote-notif.h | 11 +++---- > gdb/remote.c | 80 +++++++++++++--------------------------------- > 4 files changed, 54 insertions(+), 99 deletions(-) > > diff --git a/gdb/remote-notif.c b/gdb/remote-notif.c > index ae9a94d9c94..5a70ca128d5 100644 > --- a/gdb/remote-notif.c > +++ b/gdb/remote-notif.c > @@ -52,8 +52,6 @@ static struct notif_client *notifs[] = > > gdb_static_assert (ARRAY_SIZE (notifs) == REMOTE_NOTIF_LAST); > > -static void do_notif_event_xfree (void *arg); > - > /* Parse the BUF for the expected notification NC, and send packet to > acknowledge. */ > > @@ -61,18 +59,14 @@ void > remote_notif_ack (remote_target *remote, > struct notif_client *nc, const char *buf) > { > - struct notif_event *event = nc->alloc_event (); > - struct cleanup *old_chain > - = make_cleanup (do_notif_event_xfree, event); > + std::unique_ptr event = nc->alloc_event (); "std::unique_ptr" appears in a number of places in the patch. Did you consider adding a "notif_event_up" typedef ? > -typedef std::unique_ptr stop_reply_up; > +typedef std::unique_ptr stop_reply_up; Odd that you added the "struct". I tend to remove it when touching code instead. :-) Anyway, patch is OK. Thanks, Pedro Alves