1 /* Remote notification in GDB protocol
3 Copyright (C) 1988-2019 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef REMOTE_NOTIF_H
21 #define REMOTE_NOTIF_H
24 #include "common/queue.h"
26 /* An event of a type of async remote notification. */
30 virtual ~notif_event ()
35 /* A unique pointer holding a notif_event. */
37 typedef std::unique_ptr<notif_event> notif_event_up;
39 /* ID of the notif_client. */
43 REMOTE_NOTIF_STOP = 0,
49 /* A client to a sort of async remote notification. */
51 typedef struct notif_client
53 /* The name of notification packet. */
56 /* The packet to acknowledge a previous reply. */
57 const char *ack_command;
59 /* Parse BUF to get the expected event and update EVENT. This
60 function may throw exception if contents in BUF is not the
62 void (*parse) (remote_target *remote,
63 struct notif_client *self, const char *buf,
64 struct notif_event *event);
66 /* Send field <ack_command> to remote, and do some checking. If
67 something wrong, throw an exception. */
68 void (*ack) (remote_target *remote,
69 struct notif_client *self, const char *buf,
70 struct notif_event *event);
72 /* Check this notification client can get pending events in
73 'remote_notif_process'. */
74 int (*can_get_pending_events) (remote_target *remote,
75 struct notif_client *self);
77 /* Allocate an event. */
78 notif_event_up (*alloc_event) ();
80 /* Id of this notif_client. */
81 const enum REMOTE_NOTIF_ID id;
84 DECLARE_QUEUE_P (notif_client_p);
86 /* State on remote async notification. */
88 struct remote_notif_state
90 /* The remote target. */
91 remote_target *remote;
93 /* Notification queue. */
95 QUEUE(notif_client_p) *notif_queue;
97 /* Asynchronous signal handle registered as event loop source for when
98 the remote sent us a notification. The registered callback
99 will do a ACK sequence to pull the rest of the events out of
100 the remote side into our event queue. */
102 struct async_event_handler *get_pending_events_token;
104 /* One pending event for each notification client. This is where we
105 keep it until it is acknowledged. When there is a notification
106 packet, parse it, and create an object of 'struct notif_event' to
107 assign to it. This field is unchanged until GDB starts to ack
108 this notification (which is done by
109 remote.c:remote_notif_pending_replies). */
111 struct notif_event *pending_event[REMOTE_NOTIF_LAST];
114 void remote_notif_ack (remote_target *remote, notif_client *nc,
116 struct notif_event *remote_notif_parse (remote_target *remote,
120 void handle_notification (struct remote_notif_state *notif_state,
123 void remote_notif_process (struct remote_notif_state *state,
124 struct notif_client *except);
125 remote_notif_state *remote_notif_state_allocate (remote_target *remote);
126 void remote_notif_state_xfree (struct remote_notif_state *state);
128 extern struct notif_client notif_client_stop;
130 extern int notif_debug;
132 #endif /* REMOTE_NOTIF_H */