aboutsummaryrefslogtreecommitdiff
path: root/gdb/remote-notif.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-01-23 22:16:53 -0700
committerTom Tromey <tom@tromey.com>2019-03-06 16:04:31 -0700
commit32603266e5688718faad35b7502aa0b72a42764a (patch)
treef686b0e4adf854552bacf4aa2079bd9ae6ac0a4b /gdb/remote-notif.h
parent9799571ecb648ea2e911498cfdc7fafe3237c94a (diff)
downloadgdb-32603266e5688718faad35b7502aa0b72a42764a.zip
gdb-32603266e5688718faad35b7502aa0b72a42764a.tar.gz
gdb-32603266e5688718faad35b7502aa0b72a42764a.tar.bz2
C++ify remote notification code
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. 2019-03-06 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. (notif_event_up): New typedef. * remote-notif.c (remote_notif_ack, remote_notif_parse): Update. (notif_event_xfree, do_notif_event_xfree): Remove. (remote_notif_state_xfree): Update.
Diffstat (limited to 'gdb/remote-notif.h')
-rw-r--r--gdb/remote-notif.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/gdb/remote-notif.h b/gdb/remote-notif.h
index d766327..87b52a1 100644
--- a/gdb/remote-notif.h
+++ b/gdb/remote-notif.h
@@ -20,17 +20,22 @@
#ifndef REMOTE_NOTIF_H
#define REMOTE_NOTIF_H
+#include <memory>
#include "common/queue.h"
/* An event of a type of async remote notification. */
struct notif_event
{
- /* Destructor. Release everything from SELF, but not SELF
- itself. */
- void (*dtr) (struct notif_event *self);
+ virtual ~notif_event ()
+ {
+ }
};
+/* A unique pointer holding a notif_event. */
+
+typedef std::unique_ptr<notif_event> notif_event_up;
+
/* ID of the notif_client. */
enum REMOTE_NOTIF_ID
@@ -70,7 +75,7 @@ typedef struct notif_client
struct notif_client *self);
/* Allocate an event. */
- struct notif_event *(*alloc_event) (void);
+ notif_event_up (*alloc_event) ();
/* Id of this notif_client. */
const enum REMOTE_NOTIF_ID id;
@@ -112,8 +117,6 @@ struct notif_event *remote_notif_parse (remote_target *remote,
notif_client *nc,
const char *buf);
-void notif_event_xfree (struct notif_event *event);
-
void handle_notification (struct remote_notif_state *notif_state,
const char *buf);