xref: /dflybsd-src/contrib/gdb-7/gdb/remote-notif.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
1*ef5ccd6cSJohn Marino /* Remote notification in GDB protocol
2*ef5ccd6cSJohn Marino 
3*ef5ccd6cSJohn Marino    Copyright (C) 1988-2013 Free Software Foundation, Inc.
4*ef5ccd6cSJohn Marino 
5*ef5ccd6cSJohn Marino    This file is part of GDB.
6*ef5ccd6cSJohn Marino 
7*ef5ccd6cSJohn Marino    This program is free software; you can redistribute it and/or modify
8*ef5ccd6cSJohn Marino    it under the terms of the GNU General Public License as published by
9*ef5ccd6cSJohn Marino    the Free Software Foundation; either version 3 of the License, or
10*ef5ccd6cSJohn Marino    (at your option) any later version.
11*ef5ccd6cSJohn Marino 
12*ef5ccd6cSJohn Marino    This program is distributed in the hope that it will be useful,
13*ef5ccd6cSJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
14*ef5ccd6cSJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*ef5ccd6cSJohn Marino    GNU General Public License for more details.
16*ef5ccd6cSJohn Marino 
17*ef5ccd6cSJohn Marino    You should have received a copy of the GNU General Public License
18*ef5ccd6cSJohn Marino    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19*ef5ccd6cSJohn Marino 
20*ef5ccd6cSJohn Marino #ifndef REMOTE_NOTIF_H
21*ef5ccd6cSJohn Marino #define REMOTE_NOTIF_H
22*ef5ccd6cSJohn Marino 
23*ef5ccd6cSJohn Marino #include "queue.h"
24*ef5ccd6cSJohn Marino 
25*ef5ccd6cSJohn Marino /* An event of a type of async remote notification.  */
26*ef5ccd6cSJohn Marino 
27*ef5ccd6cSJohn Marino struct notif_event
28*ef5ccd6cSJohn Marino {
29*ef5ccd6cSJohn Marino   /* Destructor.  Release everything from SELF, but not SELF
30*ef5ccd6cSJohn Marino      itself.  */
31*ef5ccd6cSJohn Marino   void (*dtr) (struct notif_event *self);
32*ef5ccd6cSJohn Marino };
33*ef5ccd6cSJohn Marino 
34*ef5ccd6cSJohn Marino /* A client to a sort of async remote notification.  */
35*ef5ccd6cSJohn Marino 
36*ef5ccd6cSJohn Marino typedef struct notif_client
37*ef5ccd6cSJohn Marino {
38*ef5ccd6cSJohn Marino   /* The name of notification packet.  */
39*ef5ccd6cSJohn Marino   const char *name;
40*ef5ccd6cSJohn Marino 
41*ef5ccd6cSJohn Marino   /* The packet to acknowledge a previous reply.  */
42*ef5ccd6cSJohn Marino   const char *ack_command;
43*ef5ccd6cSJohn Marino 
44*ef5ccd6cSJohn Marino   /* Parse BUF to get the expected event and update EVENT.  This
45*ef5ccd6cSJohn Marino      function may throw exception if contents in BUF is not the
46*ef5ccd6cSJohn Marino      expected event.  */
47*ef5ccd6cSJohn Marino   void (*parse) (struct notif_client *self, char *buf,
48*ef5ccd6cSJohn Marino 		 struct notif_event *event);
49*ef5ccd6cSJohn Marino 
50*ef5ccd6cSJohn Marino   /* Send field <ack_command> to remote, and do some checking.  If
51*ef5ccd6cSJohn Marino      something wrong, throw an exception.  */
52*ef5ccd6cSJohn Marino   void (*ack) (struct notif_client *self, char *buf,
53*ef5ccd6cSJohn Marino 	       struct notif_event *event);
54*ef5ccd6cSJohn Marino 
55*ef5ccd6cSJohn Marino   /* Check this notification client can get pending events in
56*ef5ccd6cSJohn Marino      'remote_notif_process'.  */
57*ef5ccd6cSJohn Marino   int (*can_get_pending_events) (struct notif_client *self);
58*ef5ccd6cSJohn Marino 
59*ef5ccd6cSJohn Marino   /* Allocate an event.  */
60*ef5ccd6cSJohn Marino   struct notif_event *(*alloc_event) (void);
61*ef5ccd6cSJohn Marino 
62*ef5ccd6cSJohn Marino   /* One pending event.  This is where we keep it until it is
63*ef5ccd6cSJohn Marino      acknowledged.  When there is a notification packet, parse it,
64*ef5ccd6cSJohn Marino      and create an object of 'struct notif_event' to assign to
65*ef5ccd6cSJohn Marino      it.  This field is unchanged until GDB starts to ack this
66*ef5ccd6cSJohn Marino      notification (which is done by
67*ef5ccd6cSJohn Marino      remote.c:remote_notif_pending_replies).  */
68*ef5ccd6cSJohn Marino   struct notif_event *pending_event;
69*ef5ccd6cSJohn Marino } *notif_client_p;
70*ef5ccd6cSJohn Marino 
71*ef5ccd6cSJohn Marino void remote_notif_ack (struct notif_client *nc, char *buf);
72*ef5ccd6cSJohn Marino struct notif_event *remote_notif_parse (struct notif_client *nc,
73*ef5ccd6cSJohn Marino 					char *buf);
74*ef5ccd6cSJohn Marino 
75*ef5ccd6cSJohn Marino void handle_notification (char *buf);
76*ef5ccd6cSJohn Marino 
77*ef5ccd6cSJohn Marino void remote_notif_register_async_event_handler (void);
78*ef5ccd6cSJohn Marino void remote_notif_unregister_async_event_handler (void);
79*ef5ccd6cSJohn Marino 
80*ef5ccd6cSJohn Marino void remote_notif_process (struct notif_client *except);
81*ef5ccd6cSJohn Marino extern struct notif_client notif_client_stop;
82*ef5ccd6cSJohn Marino 
83*ef5ccd6cSJohn Marino extern int notif_debug;
84*ef5ccd6cSJohn Marino 
85*ef5ccd6cSJohn Marino #endif /* REMOTE_NOTIF_H */
86