Commit | Line | Data |
---|---|---|
722247f1 YQ |
1 | /* Remote notification in GDB protocol |
2 | ||
e2882c85 | 3 | Copyright (C) 1988-2018 Free Software Foundation, Inc. |
722247f1 YQ |
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 | ||
f48ff2a7 YQ |
34 | /* ID of the notif_client. */ |
35 | ||
36 | enum REMOTE_NOTIF_ID | |
37 | { | |
38 | REMOTE_NOTIF_STOP = 0, | |
39 | REMOTE_NOTIF_LAST, | |
40 | }; | |
41 | ||
6b8edb51 PA |
42 | struct remote_target; |
43 | ||
722247f1 YQ |
44 | /* A client to a sort of async remote notification. */ |
45 | ||
46 | typedef struct notif_client | |
47 | { | |
48 | /* The name of notification packet. */ | |
49 | const char *name; | |
50 | ||
51 | /* The packet to acknowledge a previous reply. */ | |
52 | const char *ack_command; | |
53 | ||
54 | /* Parse BUF to get the expected event and update EVENT. This | |
55 | function may throw exception if contents in BUF is not the | |
56 | expected event. */ | |
6b8edb51 PA |
57 | void (*parse) (remote_target *remote, |
58 | struct notif_client *self, char *buf, | |
722247f1 YQ |
59 | struct notif_event *event); |
60 | ||
61 | /* Send field <ack_command> to remote, and do some checking. If | |
62 | something wrong, throw an exception. */ | |
6b8edb51 PA |
63 | void (*ack) (remote_target *remote, |
64 | struct notif_client *self, char *buf, | |
722247f1 YQ |
65 | struct notif_event *event); |
66 | ||
67 | /* Check this notification client can get pending events in | |
68 | 'remote_notif_process'. */ | |
6b8edb51 PA |
69 | int (*can_get_pending_events) (remote_target *remote, |
70 | struct notif_client *self); | |
722247f1 YQ |
71 | |
72 | /* Allocate an event. */ | |
73 | struct notif_event *(*alloc_event) (void); | |
74 | ||
f48ff2a7 YQ |
75 | /* Id of this notif_client. */ |
76 | const enum REMOTE_NOTIF_ID id; | |
722247f1 YQ |
77 | } *notif_client_p; |
78 | ||
5965e028 YQ |
79 | DECLARE_QUEUE_P (notif_client_p); |
80 | ||
81 | /* State on remote async notification. */ | |
82 | ||
83 | struct remote_notif_state | |
84 | { | |
6b8edb51 PA |
85 | /* The remote target. */ |
86 | remote_target *remote; | |
87 | ||
5965e028 YQ |
88 | /* Notification queue. */ |
89 | ||
90 | QUEUE(notif_client_p) *notif_queue; | |
91 | ||
92 | /* Asynchronous signal handle registered as event loop source for when | |
93 | the remote sent us a notification. The registered callback | |
94 | will do a ACK sequence to pull the rest of the events out of | |
95 | the remote side into our event queue. */ | |
96 | ||
97 | struct async_event_handler *get_pending_events_token; | |
f48ff2a7 YQ |
98 | |
99 | /* One pending event for each notification client. This is where we | |
100 | keep it until it is acknowledged. When there is a notification | |
101 | packet, parse it, and create an object of 'struct notif_event' to | |
102 | assign to it. This field is unchanged until GDB starts to ack | |
103 | this notification (which is done by | |
104 | remote.c:remote_notif_pending_replies). */ | |
105 | ||
106 | struct notif_event *pending_event[REMOTE_NOTIF_LAST]; | |
5965e028 YQ |
107 | }; |
108 | ||
6b8edb51 PA |
109 | void remote_notif_ack (remote_target *remote, notif_client *nc, char *buf); |
110 | struct notif_event *remote_notif_parse (remote_target *remote, | |
111 | notif_client *nc, | |
722247f1 YQ |
112 | char *buf); |
113 | ||
f48ff2a7 YQ |
114 | void notif_event_xfree (struct notif_event *event); |
115 | ||
5965e028 YQ |
116 | void handle_notification (struct remote_notif_state *notif_state, |
117 | char *buf); | |
722247f1 | 118 | |
5965e028 YQ |
119 | void remote_notif_process (struct remote_notif_state *state, |
120 | struct notif_client *except); | |
6b8edb51 | 121 | remote_notif_state *remote_notif_state_allocate (remote_target *remote); |
5965e028 | 122 | void remote_notif_state_xfree (struct remote_notif_state *state); |
722247f1 | 123 | |
722247f1 YQ |
124 | extern struct notif_client notif_client_stop; |
125 | ||
99f0a309 | 126 | extern int notif_debug; |
722247f1 YQ |
127 | |
128 | #endif /* REMOTE_NOTIF_H */ |