]>
Commit | Line | Data |
---|---|---|
7d9884b9 | 1 | /* Basic, host-specific, and target-specific definitions for GDB. |
bd5635a1 RP |
2 | Copyright (C) 1986, 1989, 1991 Free Software Foundation, Inc. |
3 | ||
4 | This file is part of GDB. | |
5 | ||
a10c0d36 | 6 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 7 | it under the terms of the GNU General Public License as published by |
a10c0d36 JG |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
bd5635a1 | 10 | |
a10c0d36 | 11 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
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. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
a10c0d36 JG |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
bd5635a1 | 19 | |
c1ace5b5 JK |
20 | #if !defined (DEFS_H) |
21 | #define DEFS_H | |
22 | ||
bd5635a1 RP |
23 | /* An address in the program being debugged. Host byte order. */ |
24 | typedef unsigned int CORE_ADDR; | |
25 | ||
26 | #define min(a, b) ((a) < (b) ? (a) : (b)) | |
27 | #define max(a, b) ((a) > (b) ? (a) : (b)) | |
28 | ||
29 | /* The character C++ uses to build identifiers that must be unique from | |
30 | the program's identifiers (such as $this and $$vptr). */ | |
31 | #define CPLUS_MARKER '$' /* May be overridden to '.' for SysV */ | |
32 | ||
33 | /* | |
34 | * Allow things in gdb to be declared "const". If compiling ANSI, it | |
35 | * just works. If compiling with gcc but non-ansi, redefine to __const__. | |
36 | * If non-ansi, non-gcc, then eliminate "const" entirely, making those | |
37 | * objects be read-write rather than read-only. | |
38 | */ | |
d11c44f1 | 39 | #ifndef const |
bd5635a1 RP |
40 | #ifndef __STDC__ |
41 | # ifdef __GNUC__ | |
42 | # define const __const__ | |
bd5635a1 RP |
43 | # else |
44 | # define const /*nothing*/ | |
d11c44f1 JG |
45 | # endif /* GNUC */ |
46 | #endif /* STDC */ | |
47 | #endif /* const */ | |
48 | ||
49 | #ifndef volatile | |
50 | #ifndef __STDC__ | |
51 | # ifdef __GNUC__ | |
52 | # define volatile __volatile__ | |
53 | # else | |
bd5635a1 RP |
54 | # define volatile /*nothing*/ |
55 | # endif /* GNUC */ | |
56 | #endif /* STDC */ | |
d11c44f1 | 57 | #endif /* volatile */ |
bd5635a1 RP |
58 | |
59 | extern char *savestring (); | |
60 | extern char *strsave (); | |
61 | extern char *concat (); | |
62 | #ifdef __STDC__ | |
63 | extern void *xmalloc (), *xrealloc (); | |
64 | #else | |
65 | extern char *xmalloc (), *xrealloc (); | |
66 | #endif | |
67 | extern void free (); | |
68 | extern int parse_escape (); | |
69 | extern char *reg_names[]; | |
70 | /* Indicate that these routines do not return to the caller. */ | |
71 | extern volatile void error(), fatal(); | |
7d9884b9 | 72 | extern void warning_setup(), warning(); |
bd5635a1 RP |
73 | |
74 | /* Various possibilities for alloca. */ | |
d11c44f1 JG |
75 | #ifndef alloca |
76 | # ifdef __GNUC__ | |
77 | # define alloca __builtin_alloca | |
78 | # else | |
79 | # ifdef sparc | |
80 | # include <alloca.h> | |
81 | # endif | |
82 | extern char *alloca (); | |
bd5635a1 | 83 | # endif |
d11c44f1 | 84 | #endif |
bd5635a1 RP |
85 | |
86 | extern int errno; /* System call error return status */ | |
87 | ||
88 | extern int quit_flag; | |
89 | extern int immediate_quit; | |
90 | extern void quit (); | |
91 | ||
92 | #define QUIT { if (quit_flag) quit (); } | |
93 | ||
94 | /* Notes on classes: class_alias is for alias commands which are not | |
95 | abbreviations of the original command. */ | |
96 | ||
97 | enum command_class | |
98 | { | |
99 | /* Special args to help_list */ | |
100 | all_classes = -2, all_commands = -1, | |
101 | /* Classes of commands */ | |
102 | no_class = -1, class_run = 0, class_vars, class_stack, | |
103 | class_files, class_support, class_info, class_breakpoint, | |
104 | class_alias, class_obscure, class_user | |
105 | }; | |
106 | ||
107 | /* the cleanup list records things that have to be undone | |
108 | if an error happens (descriptors to be closed, memory to be freed, etc.) | |
109 | Each link in the chain records a function to call and an | |
110 | argument to give it. | |
111 | ||
112 | Use make_cleanup to add an element to the cleanup chain. | |
113 | Use do_cleanups to do all cleanup actions back to a given | |
114 | point in the chain. Use discard_cleanups to remove cleanups | |
115 | from the chain back to a given point, not doing them. */ | |
116 | ||
117 | struct cleanup | |
118 | { | |
119 | struct cleanup *next; | |
120 | void (*function) (); | |
121 | int arg; | |
122 | }; | |
123 | ||
124 | /* From utils.c. */ | |
125 | extern void do_cleanups (); | |
126 | extern void discard_cleanups (); | |
127 | extern struct cleanup *make_cleanup (); | |
128 | extern struct cleanup *save_cleanups (); | |
129 | extern void restore_cleanups (); | |
130 | extern void free_current_contents (); | |
131 | extern int myread (); | |
132 | extern int query (); | |
e1ce8aa5 JK |
133 | extern void wrap_here ( |
134 | #ifdef __STDC__ | |
135 | char * | |
136 | #endif | |
137 | ); | |
bd5635a1 RP |
138 | extern void reinitialize_more_filter (); |
139 | extern void fputs_filtered (); | |
140 | extern void puts_filtered (); | |
141 | extern void fprintf_filtered (); | |
142 | extern void printf_filtered (); | |
143 | extern void print_spaces (); | |
144 | extern void print_spaces_filtered (); | |
145 | extern char *n_spaces (); | |
146 | extern void printchar (); | |
147 | extern void fprint_symbol (); | |
148 | extern void fputs_demangled (); | |
149 | extern void perror_with_name (); | |
150 | extern void print_sys_errmsg (); | |
151 | ||
152 | /* From printcmd.c */ | |
153 | extern void print_address_symbolic (); | |
154 | extern void print_address (); | |
155 | ||
e1ce8aa5 JK |
156 | /* From source.c */ |
157 | void mod_path ( | |
158 | #ifdef __STDC__ | |
159 | char *, char ** | |
160 | #endif | |
161 | ); | |
162 | ||
bd5635a1 RP |
163 | /* From readline (but not in any readline .h files). */ |
164 | extern char *tilde_expand (); | |
165 | ||
166 | /* Structure for saved commands lines | |
167 | (for breakpoints, defined commands, etc). */ | |
168 | ||
169 | struct command_line | |
170 | { | |
171 | struct command_line *next; | |
172 | char *line; | |
173 | }; | |
174 | ||
175 | extern struct command_line *read_command_lines (); | |
176 | extern void free_command_lines (); | |
177 | ||
178 | /* String containing the current directory (what getwd would return). */ | |
179 | ||
180 | char *current_directory; | |
181 | ||
182 | /* Default radixes for input and output. Only some values supported. */ | |
183 | extern unsigned input_radix; | |
184 | extern unsigned output_radix; | |
185 | ||
186 | /* Baud rate specified for communication with serial target systems. */ | |
187 | char *baud_rate; | |
188 | ||
189 | #if !defined (UINT_MAX) | |
190 | #define UINT_MAX 0xffffffff | |
191 | #endif | |
192 | ||
193 | #if !defined (LONG_MAX) | |
194 | #define LONG_MAX 0x7fffffff | |
195 | #endif | |
196 | ||
e1ce8aa5 JK |
197 | #if !defined (INT_MAX) |
198 | #define INT_MAX 0x7fffffff | |
199 | #endif | |
200 | ||
201 | #if !defined (INT_MIN) | |
202 | /* Two's complement, 32 bit. */ | |
203 | #define INT_MIN -0x80000000 | |
204 | #endif | |
205 | ||
e2aab031 FF |
206 | /* Number of bits in a char or unsigned char for the target machine. |
207 | Just like CHAR_BIT in <limits.h> but describes the target machine. */ | |
bd5635a1 RP |
208 | #if !defined (TARGET_CHAR_BIT) |
209 | #define TARGET_CHAR_BIT 8 | |
210 | #endif | |
c1ace5b5 | 211 | |
e2aab031 FF |
212 | /* Number of bits in a short or unsigned short for the target machine. */ |
213 | #if !defined (TARGET_SHORT_BIT) | |
214 | #define TARGET_SHORT_BIT (sizeof (short) * TARGET_CHAR_BIT) | |
215 | #endif | |
216 | ||
217 | /* Number of bits in an int or unsigned int for the target machine. */ | |
218 | #if !defined (TARGET_INT_BIT) | |
219 | #define TARGET_INT_BIT (sizeof (int) * TARGET_CHAR_BIT) | |
220 | #endif | |
221 | ||
222 | /* Number of bits in a long or unsigned long for the target machine. */ | |
223 | #if !defined (TARGET_LONG_BIT) | |
224 | #define TARGET_LONG_BIT (sizeof (long) * TARGET_CHAR_BIT) | |
225 | #endif | |
226 | ||
227 | /* Number of bits in a long long or unsigned long long for the target machine. */ | |
d166df9b | 228 | #if !defined (TARGET_LONG_LONG_BIT) |
e2aab031 FF |
229 | #define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT) |
230 | #endif | |
231 | ||
232 | /* Number of bits in a float for the target machine. */ | |
233 | #if !defined (TARGET_FLOAT_BIT) | |
234 | #define TARGET_FLOAT_BIT (sizeof (float) * TARGET_CHAR_BIT) | |
235 | #endif | |
236 | ||
237 | /* Number of bits in a double for the target machine. */ | |
238 | #if !defined (TARGET_DOUBLE_BIT) | |
239 | #define TARGET_DOUBLE_BIT (sizeof (double) * TARGET_CHAR_BIT) | |
240 | #endif | |
241 | ||
242 | /* Number of bits in a long double for the target machine. */ | |
243 | #if !defined (TARGET_LONG_DOUBLE_BIT) | |
244 | #define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT) | |
245 | #endif | |
246 | ||
247 | /* Number of bits in a "complex" for the target machine. */ | |
248 | #if !defined (TARGET_COMPLEX_BIT) | |
249 | #define TARGET_COMPLEX_BIT (2 * TARGET_FLOAT_BIT) | |
250 | #endif | |
251 | ||
252 | /* Number of bits in a "double complex" for the target machine. */ | |
253 | #if !defined (TARGET_DOUBLE_COMPLEX_BIT) | |
254 | #define TARGET_DOUBLE_COMPLEX_BIT (2 * TARGET_DOUBLE_BIT) | |
d166df9b JK |
255 | #endif |
256 | ||
e1ce8aa5 JK |
257 | /* Convert a LONGEST to an int. This is used in contexts (e.g. number |
258 | of arguments to a function, number in a value history, register | |
259 | number, etc.) where the value must not be larger than can fit | |
260 | in an int. */ | |
261 | #if !defined (longest_to_int) | |
262 | #if defined (LONG_LONG) | |
263 | #define longest_to_int(x) (((x) > INT_MAX || (x) < INT_MIN) \ | |
264 | ? error ("Value out of range.") : (int) (x)) | |
265 | #else /* No LONG_LONG. */ | |
266 | /* Assume sizeof (int) == sizeof (long). */ | |
267 | #define longest_to_int(x) ((int) (x)) | |
268 | #endif /* No LONG_LONG. */ | |
269 | #endif /* No longest_to_int. */ | |
270 | ||
e2aab031 FF |
271 | /* Languages represented in the symbol table and elsewhere. */ |
272 | ||
273 | enum language | |
274 | { | |
275 | language_unknown, /* Language not known */ | |
276 | language_auto, /* Placeholder for automatic setting */ | |
277 | language_c, /* C */ | |
7d9884b9 | 278 | language_cplus, /* C++ */ |
e2aab031 FF |
279 | language_m2, /* Modula-2 */ |
280 | }; | |
281 | ||
a10c0d36 JG |
282 | /* Return a format string for printf that will print a number in the local |
283 | (language-specific) hexadecimal format. Result is static and is | |
284 | overwritten by the next call. local_hex_format_custom takes printf | |
285 | options like "08" or "l" (to produce e.g. %08x or %lx). */ | |
286 | ||
e2aab031 | 287 | #define local_hex_format() (current_language->la_hex_format) |
a10c0d36 JG |
288 | char *local_hex_format_custom(); /* language.c */ |
289 | ||
290 | /* Return a string that contains a number formatted in the local | |
291 | (language-specific) hexadecimal format. Result is static and is | |
292 | overwritten by the next call. local_hex_string_custom takes printf | |
293 | options like "08" or "l". */ | |
294 | ||
e2aab031 FF |
295 | char *local_hex_string (); /* language.c */ |
296 | char *local_hex_string_custom (); /* language.c */ | |
7d9884b9 JG |
297 | \f |
298 | /* System-dependent parameters for GDB. | |
299 | ||
300 | The standard thing is to include defs.h. However, files that are | |
301 | specific to a particular target can define TM_FILE_OVERRIDE before | |
302 | including defs.h, then can include any particular tm-file they desire. */ | |
303 | ||
304 | /* Target machine definition. This will be a symlink to one of the | |
305 | tm-*.h files, built by the `configure' script. */ | |
306 | ||
307 | #ifndef TM_FILE_OVERRIDE | |
308 | #include "tm.h" | |
309 | #endif | |
310 | ||
311 | /* Host machine definition. This will be a symlink to one of the | |
312 | xm-*.h files, built by the `configure' script. */ | |
313 | ||
314 | #include "xm.h" | |
315 | ||
316 | /* TARGET_BYTE_ORDER and HOST_BYTE_ORDER should be defined to one of these. */ | |
317 | #if !defined (BIG_ENDIAN) | |
318 | #define BIG_ENDIAN 4321 | |
319 | #endif | |
320 | ||
321 | #if !defined (LITTLE_ENDIAN) | |
322 | #define LITTLE_ENDIAN 1234 | |
323 | #endif | |
324 | ||
325 | /* The bit byte-order has to do just with numbering of bits in | |
326 | debugging symbols and such. Conceptually, it's quite separate | |
327 | from byte/word byte order. */ | |
328 | ||
329 | #if !defined (BITS_BIG_ENDIAN) | |
330 | #if TARGET_BYTE_ORDER == BIG_ENDIAN | |
331 | #define BITS_BIG_ENDIAN 1 | |
332 | #endif /* Big endian. */ | |
333 | ||
334 | #if TARGET_BYTE_ORDER == LITTLE_ENDIAN | |
335 | #define BITS_BIG_ENDIAN 0 | |
336 | #endif /* Little endian. */ | |
337 | #endif /* BITS_BIG_ENDIAN not defined. */ | |
338 | ||
339 | /* Swap LEN bytes at BUFFER between target and host byte-order. */ | |
340 | #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER | |
341 | #define SWAP_TARGET_AND_HOST(buffer,len) | |
342 | #else /* Target and host byte order differ. */ | |
343 | #define SWAP_TARGET_AND_HOST(buffer,len) \ | |
344 | { \ | |
345 | char tmp; \ | |
346 | char *p = (char *)(buffer); \ | |
347 | char *q = ((char *)(buffer)) + len - 1; \ | |
348 | for (; p < q; p++, q--) \ | |
349 | { \ | |
350 | tmp = *q; \ | |
351 | *q = *p; \ | |
352 | *p = tmp; \ | |
353 | } \ | |
354 | } | |
355 | #endif /* Target and host byte order differ. */ | |
356 | ||
357 | /* On some machines there are bits in addresses which are not really | |
358 | part of the address, but are used by the kernel, the hardware, etc. | |
359 | for special purposes. ADDR_BITS_REMOVE takes out any such bits | |
360 | so we get a "real" address such as one would find in a symbol | |
361 | table. ADDR_BITS_SET sets those bits the way the system wants | |
362 | them. */ | |
363 | #if !defined (ADDR_BITS_REMOVE) | |
364 | #define ADDR_BITS_REMOVE(addr) (addr) | |
365 | #define ADDR_BITS_SET(addr) (addr) | |
366 | #endif /* No ADDR_BITS_REMOVE. */ | |
367 | ||
368 | #if !defined (SYS_SIGLIST_MISSING) | |
369 | #define SYS_SIGLIST_MISSING defined (USG) | |
370 | #endif /* No SYS_SIGLIST_MISSING */ | |
a10c0d36 | 371 | |
c1ace5b5 | 372 | #endif /* no DEFS_H */ |