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.
5 This file is part of GDB.
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.
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, see <http://www.gnu.org/licenses/>. */
26 #include "wincecompat.h"
41 #if !HAVE_DECL_STRERROR
43 extern char *strerror (int); /* X3.159-1989 4.11.6.2 */
49 extern void perror (const char *);
54 extern void *memmem (const void *, size_t , const void *, size_t);
58 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
59 #define ATTR_NORETURN __attribute__ ((noreturn))
61 #define ATTR_NORETURN /* nothing */
66 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4))
67 #define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y)))
69 #define ATTR_FORMAT(type, x, y) /* nothing */
73 /* A type used for binary buffers. */
74 typedef unsigned char gdb_byte;
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;
80 /* Generic information for tracking a list of ``inferiors'' - threads,
84 struct inferior_list_entry *head;
85 struct inferior_list_entry *tail;
87 struct inferior_list_entry
90 struct inferior_list_entry *next;
93 /* Opaque type for user-visible threads. */
98 struct inferior_list_entry entry;
103 #include "regcache.h"
104 #include "gdb/signals.h"
107 #include "mem-break.h"
109 /* Target-specific functions */
111 void initialize_low ();
113 /* From inferiors.c. */
115 extern struct inferior_list all_threads;
116 extern struct inferior_list all_dlls;
117 extern int dlls_changed;
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 *,
138 struct inferior_list_entry *find_inferior_id (struct inferior_list *list,
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);
147 void loaded_dll (const char *name, CORE_ADDR base_addr);
148 void unloaded_dll (const char *name, CORE_ADDR base_addr);
150 /* Public variables in server.c */
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[];
161 extern jmp_buf toplevel;
163 extern int disable_packet_vCont;
164 extern int disable_packet_Tthread;
165 extern int disable_packet_qC;
166 extern int disable_packet_qfThreadInfo;
168 /* Functions from hostio.c. */
169 extern int handle_vFile (char *, int, int *);
171 /* Functions from hostio-errno.c. */
172 extern void hostio_last_error_from_errno (char *own_buf);
174 /* From remote-utils.c */
176 extern int remote_debug;
177 extern int all_symbols_looked_up;
178 extern int noack_mode;
179 extern int transport_is_reliable;
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);
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);
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,
220 int look_up_one_symbol (const char *name, CORE_ADDR *addrp);
222 void monitor_output (const char *msg);
224 char *xml_escape_text (const char *text);
226 /* Functions from ``signals.c''. */
227 enum target_signal target_signal_from_host (int hostsig);
228 int target_signal_to_host_p (enum target_signal oursig);
229 int target_signal_to_host (enum target_signal oursig);
230 char *target_signal_to_name (enum target_signal);
232 /* Functions from utils.c */
234 void perror_with_name (char *string);
235 void error (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
236 void fatal (const char *string,...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
237 void warning (const char *string,...) ATTR_FORMAT (printf, 1, 2);
239 /* Maximum number of bytes to read/write at once. The value here
240 is chosen to fill up a packet (the headers account for the 32). */
241 #define MAXBUFBYTES(N) (((N)-32)/2)
243 /* Buffer sizes for transferring memory, registers, etc. Set to a constant
244 value to accomodate multiple register formats. This value must be at least
245 as large as the largest register set supported by gdbserver. */
246 #define PBUFSIZ 16384
248 /* Version information, from version.c. */
249 extern const char version[];
250 extern const char host_name[];
252 #endif /* SERVER_H */