Implement -list-thread-groups --available
[deliverable/binutils-gdb.git] / gdb / gdbserver / server.h
1 /* Common definitions for remote server for GDB.
2 Copyright (C) 1993, 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005,
3 2006, 2007, 2008 Free Software Foundation, Inc.
4
5 This file is part of GDB.
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 3 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, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef SERVER_H
21 #define SERVER_H
22
23 #include "config.h"
24
25 #ifdef __MINGW32CE__
26 #include "wincecompat.h"
27 #endif
28
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 #ifdef HAVE_ERRNO_H
33 #include <errno.h>
34 #endif
35 #include <setjmp.h>
36
37 #ifdef HAVE_STRING_H
38 #include <string.h>
39 #endif
40
41 #if !HAVE_DECL_STRERROR
42 #ifndef strerror
43 extern char *strerror (int); /* X3.159-1989 4.11.6.2 */
44 #endif
45 #endif
46
47 #if !HAVE_DECL_PERROR
48 #ifndef perror
49 extern void perror (const char *);
50 #endif
51 #endif
52
53 #if !HAVE_DECL_MEMMEM
54 extern void *memmem (const void *, size_t , const void *, size_t);
55 #endif
56
57 #ifndef ATTR_NORETURN
58 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
59 #define ATTR_NORETURN __attribute__ ((noreturn))
60 #else
61 #define ATTR_NORETURN /* nothing */
62 #endif
63 #endif
64
65 #ifndef ATTR_FORMAT
66 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4))
67 #define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y)))
68 #else
69 #define ATTR_FORMAT(type, x, y) /* nothing */
70 #endif
71 #endif
72
73 /* A type used for binary buffers. */
74 typedef unsigned char gdb_byte;
75
76 /* FIXME: This should probably be autoconf'd for. It's an integer type at
77 least the size of a (void *). */
78 typedef long long CORE_ADDR;
79
80 /* Generic information for tracking a list of ``inferiors'' - threads,
81 processes, etc. */
82 struct inferior_list
83 {
84 struct inferior_list_entry *head;
85 struct inferior_list_entry *tail;
86 };
87 struct inferior_list_entry
88 {
89 unsigned long id;
90 struct inferior_list_entry *next;
91 };
92
93 /* Opaque type for user-visible threads. */
94 struct thread_info;
95
96 struct dll_info
97 {
98 struct inferior_list_entry entry;
99 char *name;
100 CORE_ADDR base_addr;
101 };
102
103 #include "regcache.h"
104 #include "gdb/signals.h"
105
106 #include "target.h"
107 #include "mem-break.h"
108
109 /* Target-specific functions */
110
111 void initialize_low ();
112
113 /* From inferiors.c. */
114
115 extern struct inferior_list all_threads;
116 extern struct inferior_list all_dlls;
117 extern int dlls_changed;
118
119 void add_inferior_to_list (struct inferior_list *list,
120 struct inferior_list_entry *new_inferior);
121 void for_each_inferior (struct inferior_list *list,
122 void (*action) (struct inferior_list_entry *));
123 extern struct thread_info *current_inferior;
124 void remove_inferior (struct inferior_list *list,
125 struct inferior_list_entry *entry);
126 void remove_thread (struct thread_info *thread);
127 void add_thread (unsigned long thread_id, void *target_data, unsigned int);
128 unsigned int thread_id_to_gdb_id (unsigned long);
129 unsigned int thread_to_gdb_id (struct thread_info *);
130 unsigned long gdb_id_to_thread_id (unsigned int);
131 struct thread_info *gdb_id_to_thread (unsigned int);
132 void clear_inferiors (void);
133 struct inferior_list_entry *find_inferior
134 (struct inferior_list *,
135 int (*func) (struct inferior_list_entry *,
136 void *),
137 void *arg);
138 struct inferior_list_entry *find_inferior_id (struct inferior_list *list,
139 unsigned long id);
140 void *inferior_target_data (struct thread_info *);
141 void set_inferior_target_data (struct thread_info *, void *);
142 void *inferior_regcache_data (struct thread_info *);
143 void set_inferior_regcache_data (struct thread_info *, void *);
144 void add_pid_to_list (struct inferior_list *list, unsigned long pid);
145 int pull_pid_from_list (struct inferior_list *list, unsigned long pid);
146
147 void loaded_dll (const char *name, CORE_ADDR base_addr);
148 void unloaded_dll (const char *name, CORE_ADDR base_addr);
149
150 /* Public variables in server.c */
151
152 extern unsigned long cont_thread;
153 extern unsigned long general_thread;
154 extern unsigned long step_thread;
155 extern unsigned long thread_from_wait;
156 extern unsigned long old_thread_from_wait;
157 extern int server_waiting;
158 extern int debug_threads;
159 extern int pass_signals[];
160
161 extern jmp_buf toplevel;
162
163 extern int disable_packet_vCont;
164 extern int disable_packet_Tthread;
165 extern int disable_packet_qC;
166 extern int disable_packet_qfThreadInfo;
167
168 /* Functions from hostio.c. */
169 extern int handle_vFile (char *, int, int *);
170
171 /* Functions from hostio-errno.c. */
172 extern void hostio_last_error_from_errno (char *own_buf);
173
174 /* From remote-utils.c */
175
176 extern int remote_debug;
177 extern int all_symbols_looked_up;
178 extern int noack_mode;
179 extern int transport_is_reliable;
180
181 int putpkt (char *buf);
182 int putpkt_binary (char *buf, int len);
183 int getpkt (char *buf);
184 void remote_open (char *name);
185 void remote_close (void);
186 void write_ok (char *buf);
187 void write_enn (char *buf);
188 void initialize_async_io (void);
189 void enable_async_io (void);
190 void disable_async_io (void);
191 void check_remote_input_interrupt_request (void);
192 void convert_ascii_to_int (char *from, unsigned char *to, int n);
193 void convert_int_to_ascii (unsigned char *from, char *to, int n);
194 void new_thread_notify (int id);
195 void dead_thread_notify (int id);
196 void prepare_resume_reply (char *buf, char status, unsigned char sig);
197
198 const char *decode_address_to_semicolon (CORE_ADDR *addrp, const char *start);
199 void decode_address (CORE_ADDR *addrp, const char *start, int len);
200 void decode_m_packet (char *from, CORE_ADDR * mem_addr_ptr,
201 unsigned int *len_ptr);
202 void decode_M_packet (char *from, CORE_ADDR * mem_addr_ptr,
203 unsigned int *len_ptr, unsigned char *to);
204 int decode_X_packet (char *from, int packet_len, CORE_ADDR * mem_addr_ptr,
205 unsigned int *len_ptr, unsigned char *to);
206 int decode_xfer_write (char *buf, int packet_len, char **annex,
207 CORE_ADDR *offset, unsigned int *len,
208 unsigned char *data);
209 int decode_search_memory_packet (const char *buf, int packet_len,
210 CORE_ADDR *start_addrp,
211 CORE_ADDR *search_space_lenp,
212 gdb_byte *pattern, unsigned int *pattern_lenp);
213
214 int unhexify (char *bin, const char *hex, int count);
215 int hexify (char *hex, const char *bin, int count);
216 int remote_escape_output (const gdb_byte *buffer, int len,
217 gdb_byte *out_buf, int *out_len,
218 int out_maxlen);
219
220 int look_up_one_symbol (const char *name, CORE_ADDR *addrp);
221
222 void monitor_output (const char *msg);
223
224 char *xml_escape_text (const char *text);
225
226 /* Simple growing buffer. */
227
228 struct buffer
229 {
230 char *buffer;
231 size_t buffer_size; /* allocated size */
232 size_t used_size; /* actually used size */
233 };
234
235 /* Append DATA of size SIZE to the end of BUFFER. Grows the buffer to
236 accommodate the new data. */
237 void buffer_grow (struct buffer *buffer, const char *data, size_t size);
238
239 /* Release any memory held by BUFFER. */
240 void buffer_free (struct buffer *buffer);
241
242 /* Initialize BUFFER. BUFFER holds no memory afterwards. */
243 void buffer_init (struct buffer *buffer);
244
245 /* Return a pointer into BUFFER data, effectivelly transfering
246 ownership of the buffer memory to the caller. Calling buffer_free
247 afterwards has no effect on the returned data. */
248 char* buffer_finish (struct buffer *buffer);
249
250 /* Simple printf to BUFFER function. Current implemented formatters:
251 %s - grow an xml escaped text in OBSTACK. */
252 void buffer_xml_printf (struct buffer *buffer, const char *format, ...)
253 ATTR_FORMAT (printf, 2, 3);;
254
255 #define buffer_grow_str(BUFFER,STRING) \
256 buffer_grow (BUFFER, STRING, strlen (STRING))
257 #define buffer_grow_str0(BUFFER,STRING) \
258 buffer_grow (BUFFER, STRING, strlen (STRING) + 1)
259
260 /* Functions from ``signals.c''. */
261 enum target_signal target_signal_from_host (int hostsig);
262 int target_signal_to_host_p (enum target_signal oursig);
263 int target_signal_to_host (enum target_signal oursig);
264 char *target_signal_to_name (enum target_signal);
265
266 /* Functions from utils.c */
267
268 void perror_with_name (char *string);
269 void error (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
270 void fatal (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
271 void warning (const char *string,...) ATTR_FORMAT (printf, 1, 2);
272
273 /* Maximum number of bytes to read/write at once. The value here
274 is chosen to fill up a packet (the headers account for the 32). */
275 #define MAXBUFBYTES(N) (((N)-32)/2)
276
277 /* Buffer sizes for transferring memory, registers, etc. Set to a constant
278 value to accomodate multiple register formats. This value must be at least
279 as large as the largest register set supported by gdbserver. */
280 #define PBUFSIZ 16384
281
282 /* Version information, from version.c. */
283 extern const char version[];
284 extern const char host_name[];
285
286 #endif /* SERVER_H */
This page took 0.034787 seconds and 4 git commands to generate.