This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2 04/22] C++ify remote notification code


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]