3 Copyright 1998, 2001, 2002 Red Hat, Inc.
5 This file is part of RDA, the Red Hat Debug Agent (and library).
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 2 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 Alternative licenses for RDA may be arranged by contacting Red Hat,
32 struct gdbserv_target;
35 /* When non-NULL, used for logging the socket interface. */
36 extern struct gdblog *gdbsocket_log;
39 /* Generic callback function's signature */
41 typedef struct gdbserv_target *gdbsocket_attach_ftype (struct gdbserv *gdbserv,
44 /* Open/create all connections in asynchronous mode. Asynchronous
45 connections will generate a SIGIO when they are ready for data
46 transfer (or attach). If enabling async, the call would normally
47 occure before any sockets have been created. By default async is
48 disabled. See samples/async. */
50 void gdbsocket_async (int async_p);
53 /* Start a server listening on tcp port PORT_NR. When an attatch to
54 that port is received, call ATTATCH(DATA) to see if the connection
55 should be accepted or rejected. TO_ATTATCH shall return (rejecting
56 the connection) or a ``struct gdbserv_target'' (accepting the
57 connection). The server allows multiple connections to the same
58 port. A typical target implementation, however, will only allow
59 one active connection, returning NULL when a connection is already
62 extern int gdbsocket_startup (int port_nr,
63 gdbsocket_attach_ftype *to_target_attach,
64 void *target_attatch_data);
67 /* Shut down the gdbserver. Force the closure of any active remote
70 void gdbsocket_shutdown (void);
73 /* ``Re-open'' readfd/writefd as an active gdb-server connection.
74 Interface is shutdown using CLOSE when EOF is detected on readfd.
75 Does not need an active running gdbsocket server. The readfd and
76 writefd can have the same value. Returns a negative value if the
77 target rejects the connection, otherwise a cardinal is returned. */
79 int gdbsocket_reopen (int fdin, int fdout,
80 void (*close) (int fdin, int fdout),
81 gdbsocket_attach_ftype *to_target_attach,
82 void *target_attach_data);
86 /* External SELECT/POLL interface.
88 The interface is loosely based on UNIX select(). A set of
89 read/write events to be polled is created using fd_set().
90 POLL/SELECT is then called. The list is then checked, using
91 fd_isset() for any returned events. */
93 enum gdbsocket_fd_event {
98 typedef void gdbsocket_fd_set_ftype (int fd, void *context, enum gdbsocket_fd_event event);
99 typedef int gdbsocket_fd_isset_ftype (int fd, void *context, enum gdbsocket_fd_event event);
101 /* Iterate through all of GDBSERVER's open file descriptors
102 accumulating a list of events to be polled using FD_SET(). */
104 void gdbsocket_fd_set (gdbsocket_fd_set_ftype *fd_set, void *context);
106 /* Iterate through all of GDBSERVER's open file descriptors checking
107 for any returned events using FD_ISSET(). Process each returned
110 void gdbsocket_fd_isset (gdbsocket_fd_isset_ftype *fd_isset, void *context);