GDB (API)
/home/stan/gdb/src/gdb/remote-notif.h
Go to the documentation of this file.
00001 /* Remote notification in GDB protocol
00002 
00003    Copyright (C) 1988-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 #ifndef REMOTE_NOTIF_H
00021 #define REMOTE_NOTIF_H
00022 
00023 #include "queue.h"
00024 
00025 /* An event of a type of async remote notification.  */
00026 
00027 struct notif_event
00028 {
00029   /* Destructor.  Release everything from SELF, but not SELF
00030      itself.  */
00031   void (*dtr) (struct notif_event *self);
00032 };
00033 
00034 /* ID of the notif_client.  */
00035 
00036 enum REMOTE_NOTIF_ID
00037 {
00038   REMOTE_NOTIF_STOP = 0,
00039   REMOTE_NOTIF_LAST,
00040 };
00041 
00042 /* A client to a sort of async remote notification.  */
00043 
00044 typedef struct notif_client
00045 {
00046   /* The name of notification packet.  */
00047   const char *name;
00048 
00049   /* The packet to acknowledge a previous reply.  */
00050   const char *ack_command;
00051 
00052   /* Parse BUF to get the expected event and update EVENT.  This
00053      function may throw exception if contents in BUF is not the
00054      expected event.  */
00055   void (*parse) (struct notif_client *self, char *buf,
00056                  struct notif_event *event);
00057 
00058   /* Send field <ack_command> to remote, and do some checking.  If
00059      something wrong, throw an exception.  */
00060   void (*ack) (struct notif_client *self, char *buf,
00061                struct notif_event *event);
00062 
00063   /* Check this notification client can get pending events in
00064      'remote_notif_process'.  */
00065   int (*can_get_pending_events) (struct notif_client *self);
00066 
00067   /* Allocate an event.  */
00068   struct notif_event *(*alloc_event) (void);
00069 
00070   /* Id of this notif_client.  */
00071   const enum REMOTE_NOTIF_ID id;
00072 } *notif_client_p;
00073 
00074 DECLARE_QUEUE_P (notif_client_p);
00075 
00076 /* State on remote async notification.  */
00077 
00078 struct remote_notif_state
00079 {
00080   /* Notification queue.  */
00081 
00082   QUEUE(notif_client_p) *notif_queue;
00083 
00084   /* Asynchronous signal handle registered as event loop source for when
00085      the remote sent us a notification.  The registered callback
00086      will do a ACK sequence to pull the rest of the events out of
00087      the remote side into our event queue.  */
00088 
00089   struct async_event_handler *get_pending_events_token;
00090 
00091 /* One pending event for each notification client.  This is where we
00092    keep it until it is acknowledged.  When there is a notification
00093    packet, parse it, and create an object of 'struct notif_event' to
00094    assign to it.  This field is unchanged until GDB starts to ack
00095    this notification (which is done by
00096    remote.c:remote_notif_pending_replies).  */
00097 
00098   struct notif_event *pending_event[REMOTE_NOTIF_LAST];
00099 };
00100 
00101 void remote_notif_ack (struct notif_client *nc, char *buf);
00102 struct notif_event *remote_notif_parse (struct notif_client *nc,
00103                                         char *buf);
00104 
00105 void notif_event_xfree (struct notif_event *event);
00106 
00107 void handle_notification (struct remote_notif_state *notif_state,
00108                           char *buf);
00109 
00110 void remote_notif_process (struct remote_notif_state *state,
00111                            struct notif_client *except);
00112 struct remote_notif_state *remote_notif_state_allocate (void);
00113 void remote_notif_state_xfree (struct remote_notif_state *state);
00114 
00115 extern struct notif_client notif_client_stop;
00116 
00117 extern int notif_debug;
00118 
00119 #endif /* REMOTE_NOTIF_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines