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
;
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
);
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
);
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
,
218 int look_up_one_symbol (const char *name
, CORE_ADDR
*addrp
);
220 void monitor_output (const char *msg
);
222 char *xml_escape_text (const char *text
);
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
);
230 /* Functions from utils.c */
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);
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)
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
246 /* Version information, from version.c. */
247 extern const char version
[];
248 extern const char host_name
[];
250 #endif /* SERVER_H */