GDB (xrefs)

/tmp/gdb-8.1/gdb/remote-notif.h
Go to the documentation of this file.
1 /* Remote notification in GDB protocol
2
3 Copyright (C) 1988-2018 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
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.
11
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.
16
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/>. */
19
20 #ifndef REMOTE_NOTIF_H
21 #define REMOTE_NOTIF_H
22
23 #include "queue.h"
24
25 /* An event of a type of async remote notification. */
26
27 struct notif_event
28 {
29 /* Destructor. Release everything from SELF, but not SELF
30 itself. */
31 void (*dtr) (struct notif_event *self);
32 };
33
34 /* ID of the notif_client. */
35
36 enum REMOTE_NOTIF_ID
37 {
38 REMOTE_NOTIF_STOP = 0,
39 REMOTE_NOTIF_LAST,
40 };
41
42 /* A client to a sort of async remote notification. */
43
44 typedef struct notif_client
45 {
46 /* The name of notification packet. */
47 const char *name;
48
49 /* The packet to acknowledge a previous reply. */
50 const char *ack_command;
51
52 /* Parse BUF to get the expected event and update EVENT. This
53 function may throw exception if contents in BUF is not the
54 expected event. */
55 void (*parse) (struct notif_client *self, char *buf,
56 struct notif_event *event);
57
58 /* Send field <ack_command> to remote, and do some checking. If
59 something wrong, throw an exception. */
60 void (*ack) (struct notif_client *self, char *buf,
61 struct notif_event *event);
62
63 /* Check this notification client can get pending events in
64 'remote_notif_process'. */
65 int (*can_get_pending_events) (struct notif_client *self);
66
67 /* Allocate an event. */
68 struct notif_event *(*alloc_event) (void);
69
70 /* Id of this notif_client. */
71 const enum REMOTE_NOTIF_ID id;
72 } *notif_client_p;
73
74 DECLARE_QUEUE_P (notif_client_p);
75
76 /* State on remote async notification. */
77
78 struct remote_notif_state
79 {
80 /* Notification queue. */
81
82 QUEUE(notif_client_p) *notif_queue;
83
84 /* Asynchronous signal handle registered as event loop source for when
85 the remote sent us a notification. The registered callback
86 will do a ACK sequence to pull the rest of the events out of
87 the remote side into our event queue. */
88
89 struct async_event_handler *get_pending_events_token;
90
91 /* One pending event for each notification client. This is where we
92 keep it until it is acknowledged. When there is a notification
93 packet, parse it, and create an object of 'struct notif_event' to
94 assign to it. This field is unchanged until GDB starts to ack
95 this notification (which is done by
96 remote.c:remote_notif_pending_replies). */
97
98 struct notif_event *pending_event[REMOTE_NOTIF_LAST];
99 };
100
101 void remote_notif_ack (struct notif_client *nc, char *buf);
102 struct notif_event *remote_notif_parse (struct notif_client *nc,
103 char *buf);
104
105 void notif_event_xfree (struct notif_event *event);
106
107 void handle_notification (struct remote_notif_state *notif_state,
108 char *buf);
109
110 void remote_notif_process (struct remote_notif_state *state,
111 struct notif_client *except);
112 struct remote_notif_state *remote_notif_state_allocate (void);
113 void remote_notif_state_xfree (struct remote_notif_state *state);
114
115 extern struct notif_client notif_client_stop;
116
117 extern int notif_debug;
118
119 #endif /* REMOTE_NOTIF_H */
notif_event
Definition: remote-notif.h:27
remote_notif_state_allocate
struct remote_notif_state * remote_notif_state_allocate(void)
Definition: remote-notif.c:239
remote_notif_parse
struct notif_event * remote_notif_parse(struct notif_client *nc, char *buf)
Definition: remote-notif.c:80
REMOTE_NOTIF_STOP
Definition: remote-notif.h:38
remote_notif_state::pending_event
struct notif_event * pending_event[REMOTE_NOTIF_LAST]
Definition: remote-notif.h:98
notif_client::can_get_pending_events
int(* can_get_pending_events)(struct notif_client *self)
Definition: remote-notif.h:65
remote_notif_state_xfree
void remote_notif_state_xfree(struct remote_notif_state *state)
Definition: remote-notif.c:257
async_event_handler
Definition: event-loop.c:123
remote_notif_state
Definition: remote-notif.h:78
handle_notification
void handle_notification(struct remote_notif_state *notif_state, char *buf)
Definition: remote-notif.c:127
notif_event_xfree
void notif_event_xfree(struct notif_event *event)
Definition: remote-notif.c:220
queue.h
remote_notif_ack
void remote_notif_ack(struct notif_client *nc, char *buf)
Definition: remote-notif.c:61
REMOTE_NOTIF_LAST
Definition: remote-notif.h:39
remote_notif_state::QUEUE
QUEUE(notif_client_p) *notif_queue
DECLARE_QUEUE_P
DECLARE_QUEUE_P(notif_client_p)
notif_client::ack_command
const char * ack_command
Definition: remote-notif.h:50
notif_client
Definition: remote-notif.h:44
notif_client_stop
struct notif_client notif_client_stop
Definition: remote.c:6381
notif_client::id
enum REMOTE_NOTIF_ID id
Definition: remote-notif.h:71
notif_client::ack
void(* ack)(struct notif_client *self, char *buf, struct notif_event *event)
Definition: remote-notif.h:60
notif_debug
int notif_debug
Definition: remote-notif.c:44
REMOTE_NOTIF_ID
REMOTE_NOTIF_ID
Definition: remote-notif.h:36
notif_event::dtr
void(* dtr)(struct notif_event *self)
Definition: remote-notif.h:31
notif_client::parse
void(* parse)(struct notif_client *self, char *buf, struct notif_event *event)
Definition: remote-notif.h:55
remote_notif_state::get_pending_events_token
struct async_event_handler * get_pending_events_token
Definition: remote-notif.h:89
notif_client::name
const char * name
Definition: remote-notif.h:47
notif_client_p
struct notif_client * notif_client_p
remote_notif_process
void remote_notif_process(struct remote_notif_state *state, struct notif_client *except)
Definition: remote-notif.c:101