Add three new builtin types (builtin_type_long_double, builtin_type_complex,
[binutils-gdb.git] / gdb / defs.h
1 /* Basic definitions for GDB, the GNU debugger.
2 Copyright (C) 1986, 1989, 1991 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
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.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20 #if !defined (DEFS_H)
21 #define DEFS_H
22
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 */
39 #ifndef const
40 #ifndef __STDC__
41 # ifdef __GNUC__
42 # define const __const__
43 # else
44 # define const /*nothing*/
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
54 # define volatile /*nothing*/
55 # endif /* GNUC */
56 #endif /* STDC */
57 #endif /* volatile */
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();
72
73 /* Various possibilities for alloca. */
74 #ifndef alloca
75 # ifdef __GNUC__
76 # define alloca __builtin_alloca
77 # else
78 # ifdef sparc
79 # include <alloca.h>
80 # endif
81 extern char *alloca ();
82 # endif
83 #endif
84
85 extern int errno; /* System call error return status */
86
87 extern int quit_flag;
88 extern int immediate_quit;
89 extern void quit ();
90
91 #define QUIT { if (quit_flag) quit (); }
92
93 /* Notes on classes: class_alias is for alias commands which are not
94 abbreviations of the original command. */
95
96 enum command_class
97 {
98 /* Special args to help_list */
99 all_classes = -2, all_commands = -1,
100 /* Classes of commands */
101 no_class = -1, class_run = 0, class_vars, class_stack,
102 class_files, class_support, class_info, class_breakpoint,
103 class_alias, class_obscure, class_user
104 };
105
106 /* the cleanup list records things that have to be undone
107 if an error happens (descriptors to be closed, memory to be freed, etc.)
108 Each link in the chain records a function to call and an
109 argument to give it.
110
111 Use make_cleanup to add an element to the cleanup chain.
112 Use do_cleanups to do all cleanup actions back to a given
113 point in the chain. Use discard_cleanups to remove cleanups
114 from the chain back to a given point, not doing them. */
115
116 struct cleanup
117 {
118 struct cleanup *next;
119 void (*function) ();
120 int arg;
121 };
122
123 /* From utils.c. */
124 extern void do_cleanups ();
125 extern void discard_cleanups ();
126 extern struct cleanup *make_cleanup ();
127 extern struct cleanup *save_cleanups ();
128 extern void restore_cleanups ();
129 extern void free_current_contents ();
130 extern int myread ();
131 extern int query ();
132 extern void wrap_here (
133 #ifdef __STDC__
134 char *
135 #endif
136 );
137 extern void reinitialize_more_filter ();
138 extern void fputs_filtered ();
139 extern void puts_filtered ();
140 extern void fprintf_filtered ();
141 extern void printf_filtered ();
142 extern void print_spaces ();
143 extern void print_spaces_filtered ();
144 extern char *n_spaces ();
145 extern void printchar ();
146 extern void fprint_symbol ();
147 extern void fputs_demangled ();
148 extern void perror_with_name ();
149 extern void print_sys_errmsg ();
150
151 /* From printcmd.c */
152 extern void print_address_symbolic ();
153 extern void print_address ();
154
155 /* From source.c */
156 void mod_path (
157 #ifdef __STDC__
158 char *, char **
159 #endif
160 );
161
162 /* From readline (but not in any readline .h files). */
163 extern char *tilde_expand ();
164
165 /* Structure for saved commands lines
166 (for breakpoints, defined commands, etc). */
167
168 struct command_line
169 {
170 struct command_line *next;
171 char *line;
172 };
173
174 extern struct command_line *read_command_lines ();
175 extern void free_command_lines ();
176
177 /* String containing the current directory (what getwd would return). */
178
179 char *current_directory;
180
181 /* Default radixes for input and output. Only some values supported. */
182 extern unsigned input_radix;
183 extern unsigned output_radix;
184
185 /* Baud rate specified for communication with serial target systems. */
186 char *baud_rate;
187
188 #if !defined (UINT_MAX)
189 #define UINT_MAX 0xffffffff
190 #endif
191
192 #if !defined (LONG_MAX)
193 #define LONG_MAX 0x7fffffff
194 #endif
195
196 #if !defined (INT_MAX)
197 #define INT_MAX 0x7fffffff
198 #endif
199
200 #if !defined (INT_MIN)
201 /* Two's complement, 32 bit. */
202 #define INT_MIN -0x80000000
203 #endif
204
205 /* Number of bits in a char or unsigned char for the target machine.
206 Just like CHAR_BIT in <limits.h> but describes the target machine. */
207 #if !defined (TARGET_CHAR_BIT)
208 #define TARGET_CHAR_BIT 8
209 #endif
210
211 /* Number of bits in a short or unsigned short for the target machine. */
212 #if !defined (TARGET_SHORT_BIT)
213 #define TARGET_SHORT_BIT (sizeof (short) * TARGET_CHAR_BIT)
214 #endif
215
216 /* Number of bits in an int or unsigned int for the target machine. */
217 #if !defined (TARGET_INT_BIT)
218 #define TARGET_INT_BIT (sizeof (int) * TARGET_CHAR_BIT)
219 #endif
220
221 /* Number of bits in a long or unsigned long for the target machine. */
222 #if !defined (TARGET_LONG_BIT)
223 #define TARGET_LONG_BIT (sizeof (long) * TARGET_CHAR_BIT)
224 #endif
225
226 /* Number of bits in a long long or unsigned long long for the target machine. */
227 #if !defined (TARGET_LONG_LONG_BIT)
228 #define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT)
229 #endif
230
231 /* Number of bits in a float for the target machine. */
232 #if !defined (TARGET_FLOAT_BIT)
233 #define TARGET_FLOAT_BIT (sizeof (float) * TARGET_CHAR_BIT)
234 #endif
235
236 /* Number of bits in a double for the target machine. */
237 #if !defined (TARGET_DOUBLE_BIT)
238 #define TARGET_DOUBLE_BIT (sizeof (double) * TARGET_CHAR_BIT)
239 #endif
240
241 /* Number of bits in a long double for the target machine. */
242 #if !defined (TARGET_LONG_DOUBLE_BIT)
243 #define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT)
244 #endif
245
246 /* Number of bits in a "complex" for the target machine. */
247 #if !defined (TARGET_COMPLEX_BIT)
248 #define TARGET_COMPLEX_BIT (2 * TARGET_FLOAT_BIT)
249 #endif
250
251 /* Number of bits in a "double complex" for the target machine. */
252 #if !defined (TARGET_DOUBLE_COMPLEX_BIT)
253 #define TARGET_DOUBLE_COMPLEX_BIT (2 * TARGET_DOUBLE_BIT)
254 #endif
255
256 /* Convert a LONGEST to an int. This is used in contexts (e.g. number
257 of arguments to a function, number in a value history, register
258 number, etc.) where the value must not be larger than can fit
259 in an int. */
260 #if !defined (longest_to_int)
261 #if defined (LONG_LONG)
262 #define longest_to_int(x) (((x) > INT_MAX || (x) < INT_MIN) \
263 ? error ("Value out of range.") : (int) (x))
264 #else /* No LONG_LONG. */
265 /* Assume sizeof (int) == sizeof (long). */
266 #define longest_to_int(x) ((int) (x))
267 #endif /* No LONG_LONG. */
268 #endif /* No longest_to_int. */
269
270 /* Languages represented in the symbol table and elsewhere. */
271
272 enum language
273 {
274 language_unknown, /* Language not known */
275 language_auto, /* Placeholder for automatic setting */
276 language_c, /* C */
277 language_m2, /* Modula-2 */
278 };
279
280 /* Return a format string for printf that will print a number in the local
281 (language-specific) hexadecimal format. Result is static and is
282 overwritten by the next call. local_hex_format_custom takes printf
283 options like "08" or "l" (to produce e.g. %08x or %lx). */
284
285 #define local_hex_format() (current_language->la_hex_format)
286 char *local_hex_format_custom(); /* language.c */
287
288 /* Return a string that contains a number formatted in the local
289 (language-specific) hexadecimal format. Result is static and is
290 overwritten by the next call. local_hex_string_custom takes printf
291 options like "08" or "l". */
292
293 char *local_hex_string (); /* language.c */
294 char *local_hex_string_custom (); /* language.c */
295
296 #endif /* no DEFS_H */