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