gdb/remote-notif.h - gdb

Global variables defined

Data types defined

Macros defined

Source code

  1. /* Remote notification in GDB protocol

  2.    Copyright (C) 1988-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #ifndef REMOTE_NOTIF_H
  15. #define REMOTE_NOTIF_H

  16. #include "queue.h"

  17. /* An event of a type of async remote notification.  */

  18. struct notif_event
  19. {
  20.   /* Destructor.  Release everything from SELF, but not SELF
  21.      itself.  */
  22.   void (*dtr) (struct notif_event *self);
  23. };

  24. /* ID of the notif_client.  */

  25. enum REMOTE_NOTIF_ID
  26. {
  27.   REMOTE_NOTIF_STOP = 0,
  28.   REMOTE_NOTIF_LAST,
  29. };

  30. /* A client to a sort of async remote notification.  */

  31. typedef struct notif_client
  32. {
  33.   /* The name of notification packet.  */
  34.   const char *name;

  35.   /* The packet to acknowledge a previous reply.  */
  36.   const char *ack_command;

  37.   /* Parse BUF to get the expected event and update EVENT.  This
  38.      function may throw exception if contents in BUF is not the
  39.      expected event.  */
  40.   void (*parse) (struct notif_client *self, char *buf,
  41.                  struct notif_event *event);

  42.   /* Send field <ack_command> to remote, and do some checking.  If
  43.      something wrong, throw an exception.  */
  44.   void (*ack) (struct notif_client *self, char *buf,
  45.                struct notif_event *event);

  46.   /* Check this notification client can get pending events in
  47.      'remote_notif_process'.  */
  48.   int (*can_get_pending_events) (struct notif_client *self);

  49.   /* Allocate an event.  */
  50.   struct notif_event *(*alloc_event) (void);

  51.   /* Id of this notif_client.  */
  52.   const enum REMOTE_NOTIF_ID id;
  53. } *notif_client_p;

  54. DECLARE_QUEUE_P (notif_client_p);

  55. /* State on remote async notification.  */

  56. struct remote_notif_state
  57. {
  58.   /* Notification queue.  */

  59.   QUEUE(notif_client_p) *notif_queue;

  60.   /* Asynchronous signal handle registered as event loop source for when
  61.      the remote sent us a notification.  The registered callback
  62.      will do a ACK sequence to pull the rest of the events out of
  63.      the remote side into our event queue.  */

  64.   struct async_event_handler *get_pending_events_token;

  65. /* One pending event for each notification client.  This is where we
  66.    keep it until it is acknowledged.  When there is a notification
  67.    packet, parse it, and create an object of 'struct notif_event' to
  68.    assign to it.  This field is unchanged until GDB starts to ack
  69.    this notification (which is done by
  70.    remote.c:remote_notif_pending_replies).  */

  71.   struct notif_event *pending_event[REMOTE_NOTIF_LAST];
  72. };

  73. void remote_notif_ack (struct notif_client *nc, char *buf);
  74. struct notif_event *remote_notif_parse (struct notif_client *nc,
  75.                                         char *buf);

  76. void notif_event_xfree (struct notif_event *event);

  77. void handle_notification (struct remote_notif_state *notif_state,
  78.                           char *buf);

  79. void remote_notif_process (struct remote_notif_state *state,
  80.                            struct notif_client *except);
  81. struct remote_notif_state *remote_notif_state_allocate (void);
  82. void remote_notif_state_xfree (struct remote_notif_state *state);

  83. extern struct notif_client notif_client_stop;

  84. extern int notif_debug;

  85. #endif /* REMOTE_NOTIF_H */