]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/gdbserver/server.h
* configure.ac: Check for memmem declaration.
[thirdparty/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
179 int putpkt (char *buf);
180 int putpkt_binary (char *buf, int len);
181 int getpkt (char *buf);
182 void remote_open (char *name);
183 void remote_close (void);
184 void write_ok (char *buf);
185 void write_enn (char *buf);
186 void initialize_async_io (void);
187 void enable_async_io (void);
188 void disable_async_io (void);
189 void check_remote_input_interrupt_request (void);
190 void convert_ascii_to_int (char *from, unsigned char *to, int n);
191 void convert_int_to_ascii (unsigned char *from, char *to, int n);
192 void new_thread_notify (int id);
193 void dead_thread_notify (int id);
194 void prepare_resume_reply (char *buf, char status, unsigned char sig);
195
196 const char *decode_address_to_semicolon (CORE_ADDR *addrp, const char *start);
197 void decode_address (CORE_ADDR *addrp, const char *start, int len);
198 void decode_m_packet (char *from, CORE_ADDR * mem_addr_ptr,
199 unsigned int *len_ptr);
200 void decode_M_packet (char *from, CORE_ADDR * mem_addr_ptr,
201 unsigned int *len_ptr, unsigned char *to);
202 int decode_X_packet (char *from, int packet_len, CORE_ADDR * mem_addr_ptr,
203 unsigned int *len_ptr, unsigned char *to);
204 int decode_xfer_write (char *buf, int packet_len, char **annex,
205 CORE_ADDR *offset, unsigned int *len,
206 unsigned char *data);
207 int decode_search_memory_packet (const char *buf, int packet_len,
208 CORE_ADDR *start_addrp,
209 CORE_ADDR *search_space_lenp,
210 gdb_byte *pattern, unsigned int *pattern_lenp);
211
212 int unhexify (char *bin, const char *hex, int count);
213 int hexify (char *hex, const char *bin, int count);
214 int remote_escape_output (const gdb_byte *buffer, int len,
215 gdb_byte *out_buf, int *out_len,
216 int out_maxlen);
217
218 int look_up_one_symbol (const char *name, CORE_ADDR *addrp);
219
220 void monitor_output (const char *msg);
221
222 char *xml_escape_text (const char *text);
223
224 /* Functions from ``signals.c''. */
225 enum target_signal target_signal_from_host (int hostsig);
226 int target_signal_to_host_p (enum target_signal oursig);
227 int target_signal_to_host (enum target_signal oursig);
228 char *target_signal_to_name (enum target_signal);
229
230 /* Functions from utils.c */
231
232 void perror_with_name (char *string);
233 void error (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
234 void fatal (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
235 void warning (const char *string,...) ATTR_FORMAT (printf, 1, 2);
236
237 /* Maximum number of bytes to read/write at once. The value here
238 is chosen to fill up a packet (the headers account for the 32). */
239 #define MAXBUFBYTES(N) (((N)-32)/2)
240
241 /* Buffer sizes for transferring memory, registers, etc. Set to a constant
242 value to accomodate multiple register formats. This value must be at least
243 as large as the largest register set supported by gdbserver. */
244 #define PBUFSIZ 16384
245
246 /* Version information, from version.c. */
247 extern const char version[];
248 extern const char host_name[];
249
250 #endif /* SERVER_H */