Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Common definitions for remote server for GDB. |
28e7fd62 | 2 | Copyright (C) 1993-2013 Free Software Foundation, Inc. |
c906108c | 3 | |
c5aa993b | 4 | This file is part of GDB. |
c906108c | 5 | |
c5aa993b JM |
6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 9 | (at your option) any later version. |
c906108c | 10 | |
c5aa993b JM |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
c906108c | 15 | |
c5aa993b | 16 | You should have received a copy of the GNU General Public License |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 18 | |
0a30fbc4 DJ |
19 | #ifndef SERVER_H |
20 | #define SERVER_H | |
21 | ||
22 | #include "config.h" | |
406b1477 | 23 | #include "build-gnulib-gdbserver/config.h" |
0729219d | 24 | |
68070c10 PA |
25 | #ifdef __MINGW32CE__ |
26 | #include "wincecompat.h" | |
27 | #endif | |
28 | ||
18c1b81a YQ |
29 | #include "libiberty.h" |
30 | #include "ansidecl.h" | |
01208463 | 31 | #include "version.h" |
18c1b81a | 32 | |
0a30fbc4 DJ |
33 | #include <stdarg.h> |
34 | #include <stdio.h> | |
35 | #include <stdlib.h> | |
68070c10 | 36 | #ifdef HAVE_ERRNO_H |
0a30fbc4 | 37 | #include <errno.h> |
68070c10 | 38 | #endif |
0729219d | 39 | #include <setjmp.h> |
0a30fbc4 | 40 | |
d8d2a3ee PA |
41 | /* For gnulib's PATH_MAX. */ |
42 | #include "pathmax.h" | |
43 | ||
d64b8841 DJ |
44 | #ifdef HAVE_STRING_H |
45 | #include <string.h> | |
46 | #endif | |
47 | ||
a1723c35 | 48 | #ifdef HAVE_ALLOCA_H |
49 | #include <alloca.h> | |
50 | #endif | |
a778ab81 | 51 | /* On some systems such as MinGW, alloca is declared in malloc.h |
52 | (there is no alloca.h). */ | |
53 | #if HAVE_MALLOC_H | |
54 | #include <malloc.h> | |
55 | #endif | |
a1723c35 | 56 | |
e122f1f5 | 57 | #if !HAVE_DECL_STRERROR |
43d5792c DJ |
58 | #ifndef strerror |
59 | extern char *strerror (int); /* X3.159-1989 4.11.6.2 */ | |
60 | #endif | |
61 | #endif | |
62 | ||
68070c10 PA |
63 | #if !HAVE_DECL_PERROR |
64 | #ifndef perror | |
65 | extern void perror (const char *); | |
66 | #endif | |
67 | #endif | |
68 | ||
bb0116a4 JB |
69 | #if !HAVE_DECL_VASPRINTF |
70 | extern int vasprintf(char **strp, const char *fmt, va_list ap); | |
71 | #endif | |
72 | #if !HAVE_DECL_VSNPRINTF | |
73 | int vsnprintf(char *str, size_t size, const char *format, va_list ap); | |
74 | #endif | |
75 | ||
5e1dc496 LM |
76 | #ifdef IN_PROCESS_AGENT |
77 | # define PROG "ipa" | |
78 | #else | |
79 | # define PROG "gdbserver" | |
80 | #endif | |
81 | ||
01f9e8fa DJ |
82 | /* A type used for binary buffers. */ |
83 | typedef unsigned char gdb_byte; | |
84 | ||
d26e3629 KY |
85 | #include "ptid.h" |
86 | #include "buffer.h" | |
87 | #include "xml-utils.h" | |
88 | #include "gdb_locale.h" | |
89 | ||
0729219d DJ |
90 | /* FIXME: This should probably be autoconf'd for. It's an integer type at |
91 | least the size of a (void *). */ | |
0a30fbc4 DJ |
92 | typedef long long CORE_ADDR; |
93 | ||
219f2f23 | 94 | typedef long long LONGEST; |
95954743 PA |
95 | typedef unsigned long long ULONGEST; |
96 | ||
0d62e5e8 DJ |
97 | /* Generic information for tracking a list of ``inferiors'' - threads, |
98 | processes, etc. */ | |
99 | struct inferior_list | |
100 | { | |
101 | struct inferior_list_entry *head; | |
102 | struct inferior_list_entry *tail; | |
103 | }; | |
104 | struct inferior_list_entry | |
105 | { | |
95954743 | 106 | ptid_t id; |
0d62e5e8 DJ |
107 | struct inferior_list_entry *next; |
108 | }; | |
109 | ||
0d62e5e8 | 110 | struct thread_info; |
d50171e4 PA |
111 | struct process_info; |
112 | struct regcache; | |
3aee8918 | 113 | struct target_desc; |
d50171e4 PA |
114 | |
115 | #include "regcache.h" | |
116 | #include "gdb/signals.h" | |
117 | #include "gdb_signals.h" | |
118 | #include "target.h" | |
119 | #include "mem-break.h" | |
623b6bdf | 120 | #include "gdbthread.h" |
c04a1aa8 | 121 | |
255e7678 DJ |
122 | struct dll_info |
123 | { | |
124 | struct inferior_list_entry entry; | |
125 | char *name; | |
126 | CORE_ADDR base_addr; | |
127 | }; | |
128 | ||
95954743 PA |
129 | struct sym_cache; |
130 | struct breakpoint; | |
8b07ae33 | 131 | struct raw_breakpoint; |
fa593d66 | 132 | struct fast_tracepoint_jump; |
95954743 PA |
133 | struct process_info_private; |
134 | ||
135 | struct process_info | |
136 | { | |
137 | struct inferior_list_entry head; | |
138 | ||
8336d594 PA |
139 | /* Nonzero if this child process was attached rather than |
140 | spawned. */ | |
95954743 PA |
141 | int attached; |
142 | ||
8336d594 PA |
143 | /* True if GDB asked us to detach from this process, but we remained |
144 | attached anyway. */ | |
145 | int gdb_detached; | |
146 | ||
95954743 PA |
147 | /* The symbol cache. */ |
148 | struct sym_cache *symbol_cache; | |
149 | ||
95954743 PA |
150 | /* The list of memory breakpoints. */ |
151 | struct breakpoint *breakpoints; | |
152 | ||
8b07ae33 PA |
153 | /* The list of raw memory breakpoints. */ |
154 | struct raw_breakpoint *raw_breakpoints; | |
155 | ||
fa593d66 PA |
156 | /* The list of installed fast tracepoints. */ |
157 | struct fast_tracepoint_jump *fast_tracepoint_jumps; | |
158 | ||
3aee8918 PA |
159 | const struct target_desc *tdesc; |
160 | ||
95954743 PA |
161 | /* Private target data. */ |
162 | struct process_info_private *private; | |
163 | }; | |
164 | ||
165 | /* Return a pointer to the process that corresponds to the current | |
166 | thread (current_inferior). It is an error to call this if there is | |
167 | no current thread selected. */ | |
168 | ||
169 | struct process_info *current_process (void); | |
7fe519cb | 170 | struct process_info *get_thread_process (struct thread_info *); |
95954743 | 171 | |
c906108c SS |
172 | /* Target-specific functions */ |
173 | ||
4ce44c66 | 174 | void initialize_low (); |
c906108c | 175 | |
ce3a066d DJ |
176 | /* From inferiors.c. */ |
177 | ||
95954743 | 178 | extern struct inferior_list all_processes; |
255e7678 DJ |
179 | extern struct inferior_list all_dlls; |
180 | extern int dlls_changed; | |
bf4c19f7 | 181 | extern void clear_dlls (void); |
255e7678 | 182 | |
0d62e5e8 DJ |
183 | void add_inferior_to_list (struct inferior_list *list, |
184 | struct inferior_list_entry *new_inferior); | |
185 | void for_each_inferior (struct inferior_list *list, | |
186 | void (*action) (struct inferior_list_entry *)); | |
95954743 | 187 | |
0d62e5e8 DJ |
188 | extern struct thread_info *current_inferior; |
189 | void remove_inferior (struct inferior_list *list, | |
190 | struct inferior_list_entry *entry); | |
95954743 PA |
191 | |
192 | struct process_info *add_process (int pid, int attached); | |
193 | void remove_process (struct process_info *process); | |
194 | struct process_info *find_process_pid (int pid); | |
9f767825 DE |
195 | int have_started_inferiors_p (void); |
196 | int have_attached_inferiors_p (void); | |
95954743 | 197 | |
95954743 PA |
198 | ptid_t thread_id_to_gdb_id (ptid_t); |
199 | ptid_t thread_to_gdb_id (struct thread_info *); | |
200 | ptid_t gdb_id_to_thread_id (ptid_t); | |
623b6bdf | 201 | |
ce3a066d | 202 | void clear_inferiors (void); |
0d62e5e8 DJ |
203 | struct inferior_list_entry *find_inferior |
204 | (struct inferior_list *, | |
205 | int (*func) (struct inferior_list_entry *, | |
206 | void *), | |
207 | void *arg); | |
208 | struct inferior_list_entry *find_inferior_id (struct inferior_list *list, | |
95954743 | 209 | ptid_t id); |
0d62e5e8 DJ |
210 | void *inferior_target_data (struct thread_info *); |
211 | void set_inferior_target_data (struct thread_info *, void *); | |
212 | void *inferior_regcache_data (struct thread_info *); | |
213 | void set_inferior_regcache_data (struct thread_info *, void *); | |
ce3a066d | 214 | |
255e7678 DJ |
215 | void loaded_dll (const char *name, CORE_ADDR base_addr); |
216 | void unloaded_dll (const char *name, CORE_ADDR base_addr); | |
217 | ||
c906108c SS |
218 | /* Public variables in server.c */ |
219 | ||
95954743 PA |
220 | extern ptid_t cont_thread; |
221 | extern ptid_t general_thread; | |
5b1c542e | 222 | |
0d62e5e8 | 223 | extern int server_waiting; |
c74d0ad8 | 224 | extern int debug_threads; |
aa5ca48f | 225 | extern int debug_hw_points; |
89be2091 | 226 | extern int pass_signals[]; |
9b224c5e PA |
227 | extern int program_signals[]; |
228 | extern int program_signals_p; | |
c906108c SS |
229 | |
230 | extern jmp_buf toplevel; | |
c906108c | 231 | |
db42f210 PA |
232 | extern int disable_packet_vCont; |
233 | extern int disable_packet_Tthread; | |
234 | extern int disable_packet_qC; | |
235 | extern int disable_packet_qfThreadInfo; | |
236 | ||
03f2bd59 | 237 | extern int run_once; |
95954743 | 238 | extern int multi_process; |
bd99dc85 PA |
239 | extern int non_stop; |
240 | ||
03583c20 UW |
241 | extern int disable_randomization; |
242 | ||
ec48365d PA |
243 | #if USE_WIN32API |
244 | #include <winsock2.h> | |
245 | typedef SOCKET gdb_fildes_t; | |
246 | #else | |
247 | typedef int gdb_fildes_t; | |
248 | #endif | |
249 | ||
bd99dc85 PA |
250 | /* Functions from event-loop.c. */ |
251 | typedef void *gdb_client_data; | |
8336d594 | 252 | typedef int (handler_func) (int, gdb_client_data); |
24b066ba | 253 | typedef int (callback_handler_func) (gdb_client_data); |
bd99dc85 | 254 | |
ec48365d PA |
255 | extern void delete_file_handler (gdb_fildes_t fd); |
256 | extern void add_file_handler (gdb_fildes_t fd, handler_func *proc, | |
bd99dc85 | 257 | gdb_client_data client_data); |
24b066ba DE |
258 | extern int append_callback_event (callback_handler_func *proc, |
259 | gdb_client_data client_data); | |
260 | extern void delete_callback_event (int id); | |
bd99dc85 PA |
261 | |
262 | extern void start_event_loop (void); | |
60f662b0 | 263 | extern void initialize_event_loop (void); |
bd99dc85 PA |
264 | |
265 | /* Functions from server.c. */ | |
8336d594 PA |
266 | extern int handle_serial_event (int err, gdb_client_data client_data); |
267 | extern int handle_target_event (int err, gdb_client_data client_data); | |
bd99dc85 | 268 | |
a6b151f1 DJ |
269 | /* Functions from hostio.c. */ |
270 | extern int handle_vFile (char *, int, int *); | |
271 | ||
59a016f0 PA |
272 | /* Functions from hostio-errno.c. */ |
273 | extern void hostio_last_error_from_errno (char *own_buf); | |
274 | ||
541af0f4 | 275 | #include "remote-utils.h" |
c74d0ad8 | 276 | |
d26e3629 | 277 | #include "common-utils.h" |
ff42e6ab | 278 | #include "utils.h" |
0a30fbc4 | 279 | |
d26e3629 | 280 | #include "gdb_assert.h" |
e92d13d5 | 281 | |
5c44784c JM |
282 | /* Maximum number of bytes to read/write at once. The value here |
283 | is chosen to fill up a packet (the headers account for the 32). */ | |
284 | #define MAXBUFBYTES(N) (((N)-32)/2) | |
285 | ||
bb9c3d36 UW |
286 | /* Buffer sizes for transferring memory, registers, etc. Set to a constant |
287 | value to accomodate multiple register formats. This value must be at least | |
288 | as large as the largest register set supported by gdbserver. */ | |
289 | #define PBUFSIZ 16384 | |
0a30fbc4 DJ |
290 | |
291 | #endif /* SERVER_H */ |