3d233a1201b77eac1cf8ea0cc277b80f7420606a
[platform/upstream/binutils.git] / gdb / gdbserver / notif.h
1 /* Notification to GDB.
2    Copyright (C) 1989-2014 Free Software Foundation, Inc.
3
4    This file is part of GDB.
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 #include "ptid.h"
20 #include "server.h"
21 #include "target.h"
22 #include "queue.h"
23
24 /* Structure holding information related to a single event.  We
25    keep a queue of these to push to GDB.  It can be extended if
26    the event of given notification contains more information.  */
27
28 typedef struct notif_event
29 {
30   /* C requires that a struct or union has at least one member.  */
31   char dummy;
32 } *notif_event_p;
33
34 DECLARE_QUEUE_P (notif_event_p);
35
36 /* A type notification to GDB.  An object of 'struct notif_server'
37    represents a type of notification.  */
38
39 typedef struct notif_server
40 {
41   /* The name of ack packet, for example, 'vStopped'.  */
42   const char *ack_name;
43
44   /* The notification packet, for example, '%Stop'.  Note that '%' is
45      not in 'notif_name'.  */
46   const char *notif_name;
47
48   /* A queue of events to GDB.  A new notif_event can be enque'ed
49      into QUEUE at any appropriate time, and the notif_reply is
50      deque'ed only when the ack from GDB arrives.  */
51   QUEUE (notif_event_p) *queue;
52
53   /* Write event EVENT to OWN_BUF.  */
54   void (*write) (struct notif_event *event, char *own_buf);
55 } *notif_server_p;
56
57 extern struct notif_server notif_stop;
58
59 int handle_notif_ack (char *own_buf, int packet_len);
60 void notif_write_event (struct notif_server *notif, char *own_buf);
61
62 void notif_push (struct notif_server *np, struct notif_event *event);
63 void notif_event_enque (struct notif_server *notif,
64                         struct notif_event *event);
65
66 void initialize_notif (void);