This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2 04/22] C++ify remote notification code
- From: Pedro Alves <palves at redhat dot com>
- To: Tom Tromey <tom at tromey dot com>, gdb-patches at sourceware dot org
- Date: Wed, 6 Mar 2019 19:23:26 +0000
- Subject: Re: [PATCH v2 04/22] C++ify remote notification code
- References: <20190227201849.32210-1-tom@tromey.com> <20190227201849.32210-5-tom@tromey.com>
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 <tom@tromey.com>
>
> * remote.c (struct stop_reply_deleter): Remove.
> (stop_reply_up): Update.
> (struct stop_reply): Derive from notif_event. Don't typedef.
> <regcache>: 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) <alloc_event>: 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<struct notif_event> event = nc->alloc_event ();
"std::unique_ptr<struct notif_event>" appears in a number of places
in the patch. Did you consider adding a "notif_event_up" typedef ?
> -typedef std::unique_ptr<stop_reply, stop_reply_deleter> stop_reply_up;
> +typedef std::unique_ptr<struct stop_reply> 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