OSDN Git Service

Merge branch 'master' of git://github.com/monaka/binutils
[pf3gnuchains/pf3gnuchains3x.git] / rda / include / gdbsocket.h
1 /* gdbsocket.h
2
3    Copyright 1998, 2001, 2002 Red Hat, Inc.
4
5    This file is part of RDA, the Red Hat Debug Agent (and library).
6
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.
11
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.
16
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.
21    
22    Alternative licenses for RDA may be arranged by contacting Red Hat,
23    Inc.  */
24
25 #ifdef __cplusplus
26 extern "C" {
27 #elif 0
28 }
29 #endif
30
31 struct gdbserv;
32 struct gdbserv_target;
33 struct gdblog;
34
35 /* When non-NULL, used for logging the socket interface. */
36 extern struct gdblog *gdbsocket_log;
37
38
39 /* Generic callback function's signature */
40
41 typedef struct gdbserv_target *gdbsocket_attach_ftype (struct gdbserv *gdbserv,
42                                                        void *attatch_data);
43
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.  */
49
50 void gdbsocket_async (int async_p);
51
52
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
60    open. */
61
62 extern int gdbsocket_startup (int port_nr,
63                               gdbsocket_attach_ftype *to_target_attach,
64                               void *target_attatch_data);
65
66
67 /* Shut down the gdbserver.  Force the closure of any active remote
68    sessions.  */
69
70 void gdbsocket_shutdown (void);
71
72
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.  */
78
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);
83
84
85
86 /* External SELECT/POLL interface.
87
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. */
92
93 enum gdbsocket_fd_event {
94   GDBSOCKET_FD_READ,
95   GDBSOCKET_FD_WRITE
96 };
97
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);
100
101 /* Iterate through all of GDBSERVER's open file descriptors
102    accumulating a list of events to be polled using FD_SET(). */
103
104 void gdbsocket_fd_set (gdbsocket_fd_set_ftype *fd_set, void *context);
105
106 /* Iterate through all of GDBSERVER's open file descriptors checking
107    for any returned events using FD_ISSET().  Process each returned
108    event. */
109
110 void gdbsocket_fd_isset (gdbsocket_fd_isset_ftype *fd_isset, void *context);
111
112 #ifdef __cplusplus
113 }
114 #endif