xref: /csrg-svn/contrib/gdb-4.7.LBL/gdb/defs.h (revision 65845)
1*65845Sbostic /* Basic, host-specific, and target-specific definitions for GDB.
2*65845Sbostic    Copyright (C) 1986, 1989, 1991 Free Software Foundation, Inc.
3*65845Sbostic 
4*65845Sbostic This file is part of GDB.
5*65845Sbostic 
6*65845Sbostic This program is free software; you can redistribute it and/or modify
7*65845Sbostic it under the terms of the GNU General Public License as published by
8*65845Sbostic the Free Software Foundation; either version 2 of the License, or
9*65845Sbostic (at your option) any later version.
10*65845Sbostic 
11*65845Sbostic This program is distributed in the hope that it will be useful,
12*65845Sbostic but WITHOUT ANY WARRANTY; without even the implied warranty of
13*65845Sbostic MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*65845Sbostic GNU General Public License for more details.
15*65845Sbostic 
16*65845Sbostic You should have received a copy of the GNU General Public License
17*65845Sbostic along with this program; if not, write to the Free Software
18*65845Sbostic Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19*65845Sbostic 
20*65845Sbostic #if !defined (DEFS_H)
21*65845Sbostic #define DEFS_H 1
22*65845Sbostic 
23*65845Sbostic #include <stdio.h>
24*65845Sbostic 
25*65845Sbostic /* First include ansidecl.h so we can use the various macro definitions
26*65845Sbostic    here and in all subsequent file inclusions.  */
27*65845Sbostic 
28*65845Sbostic #include "ansidecl.h"
29*65845Sbostic 
30*65845Sbostic /* An address in the program being debugged.  Host byte order.  */
31*65845Sbostic typedef unsigned int CORE_ADDR;
32*65845Sbostic 
33*65845Sbostic #define min(a, b) ((a) < (b) ? (a) : (b))
34*65845Sbostic #define max(a, b) ((a) > (b) ? (a) : (b))
35*65845Sbostic 
36*65845Sbostic /* The character C++ uses to build identifiers that must be unique from
37*65845Sbostic    the program's identifiers (such as $this and $$vptr).  */
38*65845Sbostic #define CPLUS_MARKER '$'	/* May be overridden to '.' for SysV */
39*65845Sbostic 
40*65845Sbostic #include <errno.h>		/* System call error return status */
41*65845Sbostic 
42*65845Sbostic extern int quit_flag;
43*65845Sbostic extern int immediate_quit;
44*65845Sbostic 
45*65845Sbostic extern void
46*65845Sbostic quit PARAMS ((void));
47*65845Sbostic 
48*65845Sbostic #define QUIT { if (quit_flag) quit (); }
49*65845Sbostic 
50*65845Sbostic /* Command classes are top-level categories into which commands are broken
51*65845Sbostic    down for "help" purposes.
52*65845Sbostic    Notes on classes: class_alias is for alias commands which are not
53*65845Sbostic    abbreviations of the original command.  class-pseudo is for commands
54*65845Sbostic    which are not really commands nor help topics ("stop").  */
55*65845Sbostic 
56*65845Sbostic enum command_class
57*65845Sbostic {
58*65845Sbostic   /* Special args to help_list */
59*65845Sbostic   all_classes = -2, all_commands = -1,
60*65845Sbostic   /* Classes of commands */
61*65845Sbostic   no_class = -1, class_run = 0, class_vars, class_stack,
62*65845Sbostic   class_files, class_support, class_info, class_breakpoint,
63*65845Sbostic   class_alias, class_obscure, class_user, class_maintenance,
64*65845Sbostic   class_pseudo
65*65845Sbostic };
66*65845Sbostic 
67*65845Sbostic /* the cleanup list records things that have to be undone
68*65845Sbostic    if an error happens (descriptors to be closed, memory to be freed, etc.)
69*65845Sbostic    Each link in the chain records a function to call and an
70*65845Sbostic    argument to give it.
71*65845Sbostic 
72*65845Sbostic    Use make_cleanup to add an element to the cleanup chain.
73*65845Sbostic    Use do_cleanups to do all cleanup actions back to a given
74*65845Sbostic    point in the chain.  Use discard_cleanups to remove cleanups
75*65845Sbostic    from the chain back to a given point, not doing them.  */
76*65845Sbostic 
77*65845Sbostic struct cleanup
78*65845Sbostic {
79*65845Sbostic   struct cleanup *next;
80*65845Sbostic   void (*function) PARAMS ((PTR));
81*65845Sbostic   PTR arg;
82*65845Sbostic };
83*65845Sbostic 
84*65845Sbostic /* From blockframe.c */
85*65845Sbostic 
86*65845Sbostic extern int
87*65845Sbostic inside_entry_func PARAMS ((CORE_ADDR));
88*65845Sbostic 
89*65845Sbostic extern int
90*65845Sbostic inside_entry_file PARAMS ((CORE_ADDR addr));
91*65845Sbostic 
92*65845Sbostic extern int
93*65845Sbostic inside_main_func PARAMS ((CORE_ADDR pc));
94*65845Sbostic 
95*65845Sbostic /* From cplus-dem.c */
96*65845Sbostic 
97*65845Sbostic extern char *
98*65845Sbostic cplus_demangle PARAMS ((const char *, int));
99*65845Sbostic 
100*65845Sbostic extern char *
101*65845Sbostic cplus_mangle_opname PARAMS ((char *, int));
102*65845Sbostic 
103*65845Sbostic /* From libmmalloc.a (memory mapped malloc library) */
104*65845Sbostic 
105*65845Sbostic extern PTR
106*65845Sbostic mmalloc_attach PARAMS ((int, PTR));
107*65845Sbostic 
108*65845Sbostic extern PTR
109*65845Sbostic mmalloc_detach PARAMS ((PTR));
110*65845Sbostic 
111*65845Sbostic extern PTR
112*65845Sbostic mmalloc PARAMS ((PTR, long));
113*65845Sbostic 
114*65845Sbostic extern PTR
115*65845Sbostic mrealloc PARAMS ((PTR, PTR, long));
116*65845Sbostic 
117*65845Sbostic extern void
118*65845Sbostic mfree PARAMS ((PTR, PTR));
119*65845Sbostic 
120*65845Sbostic extern int
121*65845Sbostic mmalloc_setkey PARAMS ((PTR, int, PTR));
122*65845Sbostic 
123*65845Sbostic extern PTR
124*65845Sbostic mmalloc_getkey PARAMS ((PTR, int));
125*65845Sbostic 
126*65845Sbostic /* From utils.c */
127*65845Sbostic 
128*65845Sbostic extern char *
129*65845Sbostic demangle_and_match PARAMS ((const char *, const char *, int));
130*65845Sbostic 
131*65845Sbostic extern int
132*65845Sbostic strcmp_iw PARAMS ((const char *, const char *));
133*65845Sbostic 
134*65845Sbostic extern char *
135*65845Sbostic safe_strerror PARAMS ((int));
136*65845Sbostic 
137*65845Sbostic extern char *
138*65845Sbostic safe_strsignal PARAMS ((int));
139*65845Sbostic 
140*65845Sbostic extern void
141*65845Sbostic init_malloc PARAMS ((PTR));
142*65845Sbostic 
143*65845Sbostic extern void
144*65845Sbostic request_quit PARAMS ((int));
145*65845Sbostic 
146*65845Sbostic extern void
147*65845Sbostic do_cleanups PARAMS ((struct cleanup *));
148*65845Sbostic 
149*65845Sbostic extern void
150*65845Sbostic discard_cleanups PARAMS ((struct cleanup *));
151*65845Sbostic 
152*65845Sbostic /* The bare make_cleanup function is one of those rare beasts that
153*65845Sbostic    takes almost any type of function as the first arg and anything that
154*65845Sbostic    will fit in a "void *" as the second arg.
155*65845Sbostic 
156*65845Sbostic    Should be, once all calls and called-functions are cleaned up:
157*65845Sbostic extern struct cleanup *
158*65845Sbostic make_cleanup PARAMS ((void (*function) (PTR), PTR));
159*65845Sbostic 
160*65845Sbostic    Until then, lint and/or various type-checking compiler options will
161*65845Sbostic    complain about make_cleanup calls.  It'd be wrong to just cast things,
162*65845Sbostic    since the type actually passed when the function is called would be
163*65845Sbostic    wrong.  */
164*65845Sbostic 
165*65845Sbostic extern struct cleanup *
166*65845Sbostic make_cleanup ();
167*65845Sbostic 
168*65845Sbostic extern struct cleanup *
169*65845Sbostic save_cleanups PARAMS ((void));
170*65845Sbostic 
171*65845Sbostic extern void
172*65845Sbostic restore_cleanups PARAMS ((struct cleanup *));
173*65845Sbostic 
174*65845Sbostic extern void
175*65845Sbostic free_current_contents PARAMS ((char **));
176*65845Sbostic 
177*65845Sbostic extern void
178*65845Sbostic null_cleanup PARAMS ((char **));
179*65845Sbostic 
180*65845Sbostic extern int
181*65845Sbostic myread PARAMS ((int, char *, int));
182*65845Sbostic 
183*65845Sbostic extern int
184*65845Sbostic query ();
185*65845Sbostic 
186*65845Sbostic extern void
187*65845Sbostic wrap_here PARAMS ((char *));
188*65845Sbostic 
189*65845Sbostic extern void
190*65845Sbostic reinitialize_more_filter PARAMS ((void));
191*65845Sbostic 
192*65845Sbostic extern int
193*65845Sbostic print_insn PARAMS ((CORE_ADDR, FILE *));
194*65845Sbostic 
195*65845Sbostic extern void
196*65845Sbostic fputs_filtered PARAMS ((const char *, FILE *));
197*65845Sbostic 
198*65845Sbostic extern void
199*65845Sbostic puts_filtered PARAMS ((char *));
200*65845Sbostic 
201*65845Sbostic extern void
202*65845Sbostic vfprintf_filtered ();
203*65845Sbostic 
204*65845Sbostic extern void
205*65845Sbostic fprintf_filtered ();
206*65845Sbostic 
207*65845Sbostic extern void
208*65845Sbostic fprintfi_filtered ();
209*65845Sbostic 
210*65845Sbostic extern void
211*65845Sbostic printf_filtered ();
212*65845Sbostic 
213*65845Sbostic extern void
214*65845Sbostic printfi_filtered ();
215*65845Sbostic 
216*65845Sbostic extern void
217*65845Sbostic print_spaces PARAMS ((int, FILE *));
218*65845Sbostic 
219*65845Sbostic extern void
220*65845Sbostic print_spaces_filtered PARAMS ((int, FILE *));
221*65845Sbostic 
222*65845Sbostic extern char *
223*65845Sbostic n_spaces PARAMS ((int));
224*65845Sbostic 
225*65845Sbostic extern void
226*65845Sbostic printchar PARAMS ((int, FILE *, int));
227*65845Sbostic 
228*65845Sbostic extern char *
229*65845Sbostic strdup_demangled PARAMS ((const char *));
230*65845Sbostic 
231*65845Sbostic extern void
232*65845Sbostic fprint_symbol PARAMS ((FILE *, char *));
233*65845Sbostic 
234*65845Sbostic extern void
235*65845Sbostic fputs_demangled PARAMS ((char *, FILE *, int));
236*65845Sbostic 
237*65845Sbostic extern void
238*65845Sbostic perror_with_name PARAMS ((char *));
239*65845Sbostic 
240*65845Sbostic extern void
241*65845Sbostic print_sys_errmsg PARAMS ((char *, int));
242*65845Sbostic 
243*65845Sbostic /* From regex.c */
244*65845Sbostic 
245*65845Sbostic extern char *
246*65845Sbostic re_comp PARAMS ((char *));
247*65845Sbostic 
248*65845Sbostic /* From symfile.c */
249*65845Sbostic 
250*65845Sbostic extern void
251*65845Sbostic symbol_file_command PARAMS ((char *, int));
252*65845Sbostic 
253*65845Sbostic /* From main.c */
254*65845Sbostic 
255*65845Sbostic extern char *
256*65845Sbostic skip_quoted PARAMS ((char *));
257*65845Sbostic 
258*65845Sbostic extern char *
259*65845Sbostic gdb_readline PARAMS ((char *));
260*65845Sbostic 
261*65845Sbostic extern char *
262*65845Sbostic command_line_input PARAMS ((char *, int));
263*65845Sbostic 
264*65845Sbostic extern void
265*65845Sbostic print_prompt PARAMS ((void));
266*65845Sbostic 
267*65845Sbostic extern int
268*65845Sbostic batch_mode PARAMS ((void));
269*65845Sbostic 
270*65845Sbostic extern int
271*65845Sbostic input_from_terminal_p PARAMS ((void));
272*65845Sbostic 
273*65845Sbostic extern int
274*65845Sbostic catch_errors PARAMS ((int (*) (char *), char *, char *));
275*65845Sbostic 
276*65845Sbostic /* From printcmd.c */
277*65845Sbostic 
278*65845Sbostic extern void
279*65845Sbostic set_next_address PARAMS ((CORE_ADDR));
280*65845Sbostic 
281*65845Sbostic extern void
282*65845Sbostic print_address_symbolic PARAMS ((CORE_ADDR, FILE *, int, char *));
283*65845Sbostic 
284*65845Sbostic extern void
285*65845Sbostic print_address PARAMS ((CORE_ADDR, FILE *));
286*65845Sbostic 
287*65845Sbostic /* From source.c */
288*65845Sbostic 
289*65845Sbostic extern int
290*65845Sbostic openp PARAMS ((char *, int, char *, int, int, char **));
291*65845Sbostic 
292*65845Sbostic extern void
293*65845Sbostic mod_path PARAMS ((char *, char **));
294*65845Sbostic 
295*65845Sbostic extern void
296*65845Sbostic directory_command PARAMS ((char *, int));
297*65845Sbostic 
298*65845Sbostic extern void
299*65845Sbostic init_source_path PARAMS ((void));
300*65845Sbostic 
301*65845Sbostic /* From findvar.c */
302*65845Sbostic 
303*65845Sbostic extern int
304*65845Sbostic read_relative_register_raw_bytes PARAMS ((int, char *));
305*65845Sbostic 
306*65845Sbostic /* From readline (but not in any readline .h files).  */
307*65845Sbostic 
308*65845Sbostic extern char *
309*65845Sbostic tilde_expand PARAMS ((char *));
310*65845Sbostic 
311*65845Sbostic /* Structure for saved commands lines
312*65845Sbostic    (for breakpoints, defined commands, etc).  */
313*65845Sbostic 
314*65845Sbostic struct command_line
315*65845Sbostic {
316*65845Sbostic   struct command_line *next;
317*65845Sbostic   char *line;
318*65845Sbostic   int type;                     /* statement type */
319*65845Sbostic #define CL_END 0
320*65845Sbostic #define CL_NORMAL 1
321*65845Sbostic #define CL_WHILE 2
322*65845Sbostic #define CL_IF 3
323*65845Sbostic #define CL_EXITLOOP 4
324*65845Sbostic #define CL_NOP 5
325*65845Sbostic   struct command_line *body;  /* body of loop for while, body of if */
326*65845Sbostic   struct command_line *elsebody; /* body of else part of if */
327*65845Sbostic };
328*65845Sbostic 
329*65845Sbostic extern struct command_line *
330*65845Sbostic read_command_lines PARAMS ((int));
331*65845Sbostic 
332*65845Sbostic extern void
333*65845Sbostic free_command_lines PARAMS ((struct command_line *));
334*65845Sbostic 
335*65845Sbostic /* String containing the current directory (what getwd would return).  */
336*65845Sbostic 
337*65845Sbostic extern char *current_directory;
338*65845Sbostic 
339*65845Sbostic /* Default radixes for input and output.  Only some values supported.  */
340*65845Sbostic extern unsigned input_radix;
341*65845Sbostic extern unsigned output_radix;
342*65845Sbostic 
343*65845Sbostic /* Baud rate specified for communication with serial target systems.  */
344*65845Sbostic extern char *baud_rate;
345*65845Sbostic 
346*65845Sbostic /* Languages represented in the symbol table and elsewhere. */
347*65845Sbostic 
348*65845Sbostic enum language
349*65845Sbostic {
350*65845Sbostic    language_unknown, 		/* Language not known */
351*65845Sbostic    language_auto,		/* Placeholder for automatic setting */
352*65845Sbostic    language_c, 			/* C */
353*65845Sbostic    language_cplus, 		/* C++ */
354*65845Sbostic    language_m2			/* Modula-2 */
355*65845Sbostic };
356*65845Sbostic 
357*65845Sbostic /* Return a format string for printf that will print a number in the local
358*65845Sbostic    (language-specific) hexadecimal format.  Result is static and is
359*65845Sbostic    overwritten by the next call.  local_hex_format_custom takes printf
360*65845Sbostic    options like "08" or "l" (to produce e.g. %08x or %lx).  */
361*65845Sbostic 
362*65845Sbostic #define local_hex_format() (current_language->la_hex_format)
363*65845Sbostic 
364*65845Sbostic extern char *
365*65845Sbostic local_hex_format_custom PARAMS ((char *));	/* language.c */
366*65845Sbostic 
367*65845Sbostic /* Return a string that contains a number formatted in the local
368*65845Sbostic    (language-specific) hexadecimal format.  Result is static and is
369*65845Sbostic    overwritten by the next call.  local_hex_string_custom takes printf
370*65845Sbostic    options like "08" or "l".  */
371*65845Sbostic 
372*65845Sbostic extern char *
373*65845Sbostic local_hex_string PARAMS ((int));		/* language.c */
374*65845Sbostic 
375*65845Sbostic extern char *
376*65845Sbostic local_hex_string_custom PARAMS ((int, char *));	/* language.c */
377*65845Sbostic 
378*65845Sbostic 
379*65845Sbostic /* Host machine definition.  This will be a symlink to one of the
380*65845Sbostic    xm-*.h files, built by the `configure' script.  */
381*65845Sbostic 
382*65845Sbostic #include "xm.h"
383*65845Sbostic 
384*65845Sbostic /* If the xm.h file did not define the mode string used to open the
385*65845Sbostic    files, assume that binary files are opened the same way as text
386*65845Sbostic    files */
387*65845Sbostic #ifndef FOPEN_RB
388*65845Sbostic #include "fopen-same.h"
389*65845Sbostic #endif
390*65845Sbostic 
391*65845Sbostic /*
392*65845Sbostic  * Allow things in gdb to be declared "const".  If compiling ANSI, it
393*65845Sbostic  * just works.  If compiling with gcc but non-ansi, redefine to __const__.
394*65845Sbostic  * If non-ansi, non-gcc, then eliminate "const" entirely, making those
395*65845Sbostic  * objects be read-write rather than read-only.
396*65845Sbostic  */
397*65845Sbostic 
398*65845Sbostic #ifndef const
399*65845Sbostic #ifndef __STDC__
400*65845Sbostic # ifdef __GNUC__
401*65845Sbostic #  define const __const__
402*65845Sbostic # else
403*65845Sbostic #  define const /*nothing*/
404*65845Sbostic # endif /* GNUC */
405*65845Sbostic #endif /* STDC */
406*65845Sbostic #endif /* const */
407*65845Sbostic 
408*65845Sbostic #ifndef volatile
409*65845Sbostic #ifndef __STDC__
410*65845Sbostic # ifdef __GNUC__
411*65845Sbostic #  define volatile __volatile__
412*65845Sbostic # else
413*65845Sbostic #  define volatile /*nothing*/
414*65845Sbostic # endif /* GNUC */
415*65845Sbostic #endif /* STDC */
416*65845Sbostic #endif /* volatile */
417*65845Sbostic 
418*65845Sbostic /* Some compilers (many AT&T SVR4 compilers for instance), do not accept
419*65845Sbostic    declarations of functions that never return (exit for instance) as
420*65845Sbostic    "volatile void".  For such compilers "NORETURN" can be defined away
421*65845Sbostic    to keep them happy */
422*65845Sbostic 
423*65845Sbostic #ifndef NORETURN
424*65845Sbostic # ifdef __lucid
425*65845Sbostic #   define NORETURN /*nothing*/
426*65845Sbostic # else
427*65845Sbostic #   define NORETURN volatile
428*65845Sbostic # endif
429*65845Sbostic #endif
430*65845Sbostic 
431*65845Sbostic /* Defaults for system-wide constants (if not defined by xm.h, we fake it).  */
432*65845Sbostic 
433*65845Sbostic #if !defined (UINT_MAX)
434*65845Sbostic #define UINT_MAX 0xffffffff
435*65845Sbostic #endif
436*65845Sbostic 
437*65845Sbostic #if !defined (LONG_MAX)
438*65845Sbostic #define LONG_MAX 0x7fffffff
439*65845Sbostic #endif
440*65845Sbostic 
441*65845Sbostic #if !defined (INT_MAX)
442*65845Sbostic #define INT_MAX 0x7fffffff
443*65845Sbostic #endif
444*65845Sbostic 
445*65845Sbostic #if !defined (INT_MIN)
446*65845Sbostic /* Two's complement, 32 bit.  */
447*65845Sbostic #define INT_MIN -0x80000000
448*65845Sbostic #endif
449*65845Sbostic 
450*65845Sbostic /* Number of bits in a char or unsigned char for the target machine.
451*65845Sbostic    Just like CHAR_BIT in <limits.h> but describes the target machine.  */
452*65845Sbostic #if !defined (TARGET_CHAR_BIT)
453*65845Sbostic #define TARGET_CHAR_BIT 8
454*65845Sbostic #endif
455*65845Sbostic 
456*65845Sbostic /* Number of bits in a short or unsigned short for the target machine. */
457*65845Sbostic #if !defined (TARGET_SHORT_BIT)
458*65845Sbostic #define TARGET_SHORT_BIT (sizeof (short) * TARGET_CHAR_BIT)
459*65845Sbostic #endif
460*65845Sbostic 
461*65845Sbostic /* Number of bits in an int or unsigned int for the target machine. */
462*65845Sbostic #if !defined (TARGET_INT_BIT)
463*65845Sbostic #define TARGET_INT_BIT (sizeof (int) * TARGET_CHAR_BIT)
464*65845Sbostic #endif
465*65845Sbostic 
466*65845Sbostic /* Number of bits in a long or unsigned long for the target machine. */
467*65845Sbostic #if !defined (TARGET_LONG_BIT)
468*65845Sbostic #define TARGET_LONG_BIT (sizeof (long) * TARGET_CHAR_BIT)
469*65845Sbostic #endif
470*65845Sbostic 
471*65845Sbostic /* Number of bits in a long long or unsigned long long for the target machine. */
472*65845Sbostic #if !defined (TARGET_LONG_LONG_BIT)
473*65845Sbostic #define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT)
474*65845Sbostic #endif
475*65845Sbostic 
476*65845Sbostic /* Number of bits in a float for the target machine. */
477*65845Sbostic #if !defined (TARGET_FLOAT_BIT)
478*65845Sbostic #define TARGET_FLOAT_BIT (sizeof (float) * TARGET_CHAR_BIT)
479*65845Sbostic #endif
480*65845Sbostic 
481*65845Sbostic /* Number of bits in a double for the target machine. */
482*65845Sbostic #if !defined (TARGET_DOUBLE_BIT)
483*65845Sbostic #define TARGET_DOUBLE_BIT (sizeof (double) * TARGET_CHAR_BIT)
484*65845Sbostic #endif
485*65845Sbostic 
486*65845Sbostic /* Number of bits in a long double for the target machine. */
487*65845Sbostic #if !defined (TARGET_LONG_DOUBLE_BIT)
488*65845Sbostic #define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT)
489*65845Sbostic #endif
490*65845Sbostic 
491*65845Sbostic /* Number of bits in a "complex" for the target machine. */
492*65845Sbostic #if !defined (TARGET_COMPLEX_BIT)
493*65845Sbostic #define TARGET_COMPLEX_BIT (2 * TARGET_FLOAT_BIT)
494*65845Sbostic #endif
495*65845Sbostic 
496*65845Sbostic /* Number of bits in a "double complex" for the target machine. */
497*65845Sbostic #if !defined (TARGET_DOUBLE_COMPLEX_BIT)
498*65845Sbostic #define TARGET_DOUBLE_COMPLEX_BIT (2 * TARGET_DOUBLE_BIT)
499*65845Sbostic #endif
500*65845Sbostic 
501*65845Sbostic /* Number of bits in a pointer for the target machine */
502*65845Sbostic #if !defined (TARGET_PTR_BIT)
503*65845Sbostic #define TARGET_PTR_BIT TARGET_INT_BIT
504*65845Sbostic #endif
505*65845Sbostic 
506*65845Sbostic /* Convert a LONGEST to an int.  This is used in contexts (e.g. number
507*65845Sbostic    of arguments to a function, number in a value history, register
508*65845Sbostic    number, etc.) where the value must not be larger than can fit
509*65845Sbostic    in an int.  */
510*65845Sbostic #if !defined (longest_to_int)
511*65845Sbostic #if defined (LONG_LONG)
512*65845Sbostic #define longest_to_int(x) (((x) > INT_MAX || (x) < INT_MIN) \
513*65845Sbostic 			   ? (error ("Value out of range."),0) : (int) (x))
514*65845Sbostic #else /* No LONG_LONG.  */
515*65845Sbostic /* Assume sizeof (int) == sizeof (long).  */
516*65845Sbostic #define longest_to_int(x) ((int) (x))
517*65845Sbostic #endif /* No LONG_LONG.  */
518*65845Sbostic #endif /* No longest_to_int.  */
519*65845Sbostic 
520*65845Sbostic /* This should not be a typedef, because "unsigned LONGEST" needs
521*65845Sbostic    to work. LONG_LONG is defined if the host has "long long".  */
522*65845Sbostic 
523*65845Sbostic #ifndef LONGEST
524*65845Sbostic # ifdef LONG_LONG
525*65845Sbostic #  define LONGEST long long
526*65845Sbostic # else
527*65845Sbostic #  define LONGEST long
528*65845Sbostic # endif
529*65845Sbostic #endif
530*65845Sbostic 
531*65845Sbostic /* Assorted functions we can declare, now that const and volatile are
532*65845Sbostic    defined.  */
533*65845Sbostic 
534*65845Sbostic extern char *
535*65845Sbostic savestring PARAMS ((const char *, int));
536*65845Sbostic 
537*65845Sbostic extern char *
538*65845Sbostic msavestring PARAMS ((void *, const char *, int));
539*65845Sbostic 
540*65845Sbostic extern char *
541*65845Sbostic strsave PARAMS ((const char *));
542*65845Sbostic 
543*65845Sbostic extern char *
544*65845Sbostic mstrsave PARAMS ((void *, const char *));
545*65845Sbostic 
546*65845Sbostic extern char *
547*65845Sbostic concat PARAMS ((char *, ...));
548*65845Sbostic 
549*65845Sbostic extern PTR
550*65845Sbostic xmalloc PARAMS ((long));
551*65845Sbostic 
552*65845Sbostic extern PTR
553*65845Sbostic xrealloc PARAMS ((PTR, long));
554*65845Sbostic 
555*65845Sbostic extern PTR
556*65845Sbostic xmmalloc PARAMS ((PTR, long));
557*65845Sbostic 
558*65845Sbostic extern PTR
559*65845Sbostic xmrealloc PARAMS ((PTR, PTR, long));
560*65845Sbostic 
561*65845Sbostic extern PTR
562*65845Sbostic mmalloc PARAMS ((PTR, long));
563*65845Sbostic 
564*65845Sbostic extern PTR
565*65845Sbostic mrealloc PARAMS ((PTR, PTR, long));
566*65845Sbostic 
567*65845Sbostic extern void
568*65845Sbostic mfree PARAMS ((PTR, PTR));
569*65845Sbostic 
570*65845Sbostic extern int
571*65845Sbostic mmcheck PARAMS ((PTR, void (*) (void)));
572*65845Sbostic 
573*65845Sbostic extern int
574*65845Sbostic mmtrace PARAMS ((void));
575*65845Sbostic 
576*65845Sbostic extern int
577*65845Sbostic parse_escape PARAMS ((char **));
578*65845Sbostic 
579*65845Sbostic extern const char * const reg_names[];
580*65845Sbostic 
581*65845Sbostic extern NORETURN void			/* Does not return to the caller.  */
582*65845Sbostic error ();
583*65845Sbostic 
584*65845Sbostic extern NORETURN void			/* Does not return to the caller.  */
585*65845Sbostic fatal ();
586*65845Sbostic 
587*65845Sbostic extern NORETURN void			/* Not specified as volatile in ... */
588*65845Sbostic exit PARAMS ((int));			/* 4.10.4.3 */
589*65845Sbostic 
590*65845Sbostic extern NORETURN void			/* Does not return to the caller.  */
591*65845Sbostic nomem PARAMS ((long));
592*65845Sbostic 
593*65845Sbostic extern NORETURN void			/* Does not return to the caller.  */
594*65845Sbostic return_to_top_level PARAMS ((void));
595*65845Sbostic 
596*65845Sbostic extern void
597*65845Sbostic warning_setup PARAMS ((void));
598*65845Sbostic 
599*65845Sbostic extern void
600*65845Sbostic warning ();
601*65845Sbostic 
602*65845Sbostic /* Global functions from other, non-gdb GNU thingies (libiberty for
603*65845Sbostic    instance) */
604*65845Sbostic 
605*65845Sbostic extern char *
606*65845Sbostic basename PARAMS ((char *));
607*65845Sbostic 
608*65845Sbostic extern char *
609*65845Sbostic getenv PARAMS ((const char *));
610*65845Sbostic 
611*65845Sbostic extern char **
612*65845Sbostic buildargv PARAMS ((char *));
613*65845Sbostic 
614*65845Sbostic extern void
615*65845Sbostic freeargv PARAMS ((char **));
616*65845Sbostic 
617*65845Sbostic extern char *
618*65845Sbostic strerrno PARAMS ((int));
619*65845Sbostic 
620*65845Sbostic extern char *
621*65845Sbostic strsigno PARAMS ((int));
622*65845Sbostic 
623*65845Sbostic extern int
624*65845Sbostic errno_max PARAMS ((void));
625*65845Sbostic 
626*65845Sbostic extern int
627*65845Sbostic signo_max PARAMS ((void));
628*65845Sbostic 
629*65845Sbostic extern int
630*65845Sbostic strtoerrno PARAMS ((char *));
631*65845Sbostic 
632*65845Sbostic extern int
633*65845Sbostic strtosigno PARAMS ((char *));
634*65845Sbostic 
635*65845Sbostic extern char *
636*65845Sbostic strsignal PARAMS ((int));
637*65845Sbostic 
638*65845Sbostic /* From other system libraries */
639*65845Sbostic 
640*65845Sbostic #ifndef PSIGNAL_IN_SIGNAL_H
641*65845Sbostic extern void
642*65845Sbostic psignal PARAMS ((unsigned, char *));
643*65845Sbostic #endif
644*65845Sbostic 
645*65845Sbostic /* For now, we can't include <stdlib.h> because it conflicts with
646*65845Sbostic    "../include/getopt.h".  (FIXME)
647*65845Sbostic 
648*65845Sbostic    However, if a function is defined in the ANSI C standard and a prototype
649*65845Sbostic    for that function is defined and visible in any header file in an ANSI
650*65845Sbostic    conforming environment, then that prototype must match the definition in
651*65845Sbostic    the ANSI standard.  So we can just duplicate them here without conflict,
652*65845Sbostic    since they must be the same in all conforming ANSI environments.  If
653*65845Sbostic    these cause problems, then the environment is not ANSI conformant. */
654*65845Sbostic 
655*65845Sbostic #ifdef __STDC__
656*65845Sbostic #include <stddef.h>
657*65845Sbostic #endif
658*65845Sbostic 
659*65845Sbostic extern int
660*65845Sbostic fclose PARAMS ((FILE *stream));				/* 4.9.5.1 */
661*65845Sbostic 
662*65845Sbostic extern void
663*65845Sbostic perror PARAMS ((const char *));				/* 4.9.10.4 */
664*65845Sbostic 
665*65845Sbostic extern double
666*65845Sbostic atof PARAMS ((const char *nptr));			/* 4.10.1.1 */
667*65845Sbostic 
668*65845Sbostic extern int
669*65845Sbostic atoi PARAMS ((const char *));				/* 4.10.1.2 */
670*65845Sbostic 
671*65845Sbostic #ifndef MALLOC_INCOMPATIBLE
672*65845Sbostic 
673*65845Sbostic extern PTR
674*65845Sbostic malloc PARAMS ((size_t size));                          /* 4.10.3.3 */
675*65845Sbostic 
676*65845Sbostic extern PTR
677*65845Sbostic realloc PARAMS ((void *ptr, size_t size));              /* 4.10.3.4 */
678*65845Sbostic 
679*65845Sbostic extern void
680*65845Sbostic free PARAMS ((void *));					/* 4.10.3.2 */
681*65845Sbostic 
682*65845Sbostic #endif	/* MALLOC_INCOMPATIBLE */
683*65845Sbostic 
684*65845Sbostic extern void
685*65845Sbostic qsort PARAMS ((void *base, size_t nmemb,		/* 4.10.5.2 */
686*65845Sbostic 	       size_t size,
687*65845Sbostic 	       int (*comp)(const void *, const void *)));
688*65845Sbostic 
689*65845Sbostic #ifndef	MEM_FNS_DECLARED	/* Some non-ANSI use void *, not char *.  */
690*65845Sbostic extern PTR
691*65845Sbostic memcpy PARAMS ((void *, const void *, size_t));		/* 4.11.2.1 */
692*65845Sbostic #endif
693*65845Sbostic 
694*65845Sbostic extern int
695*65845Sbostic memcmp PARAMS ((const void *, const void *, size_t));	/* 4.11.4.1 */
696*65845Sbostic 
697*65845Sbostic extern char *
698*65845Sbostic strchr PARAMS ((const char *, int));			/* 4.11.5.2 */
699*65845Sbostic 
700*65845Sbostic extern char *
701*65845Sbostic strrchr PARAMS ((const char *, int));			/* 4.11.5.5 */
702*65845Sbostic 
703*65845Sbostic extern char *
704*65845Sbostic strstr PARAMS ((const char *, const char *));		/* 4.11.5.7 */
705*65845Sbostic 
706*65845Sbostic extern char *
707*65845Sbostic strtok PARAMS ((char *, const char *));			/* 4.11.5.8 */
708*65845Sbostic 
709*65845Sbostic #ifndef	MEM_FNS_DECLARED	/* Some non-ANSI use void *, not char *.  */
710*65845Sbostic extern PTR
711*65845Sbostic memset PARAMS ((void *, int, size_t));			/* 4.11.6.1 */
712*65845Sbostic #endif
713*65845Sbostic 
714*65845Sbostic extern char *
715*65845Sbostic strerror PARAMS ((int));				/* 4.11.6.2 */
716*65845Sbostic 
717*65845Sbostic /* Various possibilities for alloca.  */
718*65845Sbostic #ifndef alloca
719*65845Sbostic # ifdef notdef /*XXX*/
720*65845Sbostic #  define alloca __builtin_alloca
721*65845Sbostic # else
722*65845Sbostic #  ifdef sparc
723*65845Sbostic #   include <alloca.h>		/* NOTE:  Doesn't declare alloca() */
724*65845Sbostic #  endif
725*65845Sbostic #  ifdef __STDC__
726*65845Sbostic    extern void *alloca (size_t);
727*65845Sbostic #  else /* __STDC__ */
728*65845Sbostic    extern char *alloca ();
729*65845Sbostic #  endif
730*65845Sbostic # endif
731*65845Sbostic #endif
732*65845Sbostic 
733*65845Sbostic /* TARGET_BYTE_ORDER and HOST_BYTE_ORDER must be defined to one of these.  */
734*65845Sbostic 
735*65845Sbostic #if !defined (BIG_ENDIAN)
736*65845Sbostic #define BIG_ENDIAN 4321
737*65845Sbostic #endif
738*65845Sbostic 
739*65845Sbostic #if !defined (LITTLE_ENDIAN)
740*65845Sbostic #define LITTLE_ENDIAN 1234
741*65845Sbostic #endif
742*65845Sbostic 
743*65845Sbostic /* Target-system-dependent parameters for GDB.
744*65845Sbostic 
745*65845Sbostic    The standard thing is to include defs.h.  However, files that are
746*65845Sbostic    specific to a particular target can define TM_FILE_OVERRIDE before
747*65845Sbostic    including defs.h, then can include any particular tm-file they desire.  */
748*65845Sbostic 
749*65845Sbostic /* Target machine definition.  This will be a symlink to one of the
750*65845Sbostic    tm-*.h files, built by the `configure' script.  */
751*65845Sbostic 
752*65845Sbostic #ifndef TM_FILE_OVERRIDE
753*65845Sbostic #include "tm.h"
754*65845Sbostic #endif
755*65845Sbostic 
756*65845Sbostic /* The bit byte-order has to do just with numbering of bits in
757*65845Sbostic    debugging symbols and such.  Conceptually, it's quite separate
758*65845Sbostic    from byte/word byte order.  */
759*65845Sbostic 
760*65845Sbostic #if !defined (BITS_BIG_ENDIAN)
761*65845Sbostic #if TARGET_BYTE_ORDER == BIG_ENDIAN
762*65845Sbostic #define BITS_BIG_ENDIAN 1
763*65845Sbostic #endif /* Big endian.  */
764*65845Sbostic 
765*65845Sbostic #if TARGET_BYTE_ORDER == LITTLE_ENDIAN
766*65845Sbostic #define BITS_BIG_ENDIAN 0
767*65845Sbostic #endif /* Little endian.  */
768*65845Sbostic #endif /* BITS_BIG_ENDIAN not defined.  */
769*65845Sbostic 
770*65845Sbostic /* Swap LEN bytes at BUFFER between target and host byte-order.  */
771*65845Sbostic #if TARGET_BYTE_ORDER == HOST_BYTE_ORDER
772*65845Sbostic #define SWAP_TARGET_AND_HOST(buffer,len)
773*65845Sbostic #else /* Target and host byte order differ.  */
774*65845Sbostic #define SWAP_TARGET_AND_HOST(buffer,len) \
775*65845Sbostic   {	       	       	       	       	       	       	       	       	 \
776*65845Sbostic     char tmp;								 \
777*65845Sbostic     char *p = (char *)(buffer);						 \
778*65845Sbostic     char *q = ((char *)(buffer)) + len - 1;		   		 \
779*65845Sbostic     for (; p < q; p++, q--)				 		 \
780*65845Sbostic       {									 \
781*65845Sbostic         tmp = *q;							 \
782*65845Sbostic         *q = *p;							 \
783*65845Sbostic         *p = tmp;							 \
784*65845Sbostic       }									 \
785*65845Sbostic   }
786*65845Sbostic #endif /* Target and host byte order differ.  */
787*65845Sbostic 
788*65845Sbostic /* On some machines there are bits in addresses which are not really
789*65845Sbostic    part of the address, but are used by the kernel, the hardware, etc.
790*65845Sbostic    for special purposes.  ADDR_BITS_REMOVE takes out any such bits
791*65845Sbostic    so we get a "real" address such as one would find in a symbol
792*65845Sbostic    table.  ADDR_BITS_SET sets those bits the way the system wants
793*65845Sbostic    them.  */
794*65845Sbostic #if !defined (ADDR_BITS_REMOVE)
795*65845Sbostic #define ADDR_BITS_REMOVE(addr) (addr)
796*65845Sbostic #define ADDR_BITS_SET(addr) (addr)
797*65845Sbostic #endif /* No ADDR_BITS_REMOVE.  */
798*65845Sbostic 
799*65845Sbostic /* If this definition isn't overridden by the header files, assume
800*65845Sbostic    that isatty and fileno exist on this system.  */
801*65845Sbostic #ifndef ISATTY
802*65845Sbostic #define ISATTY(FP)    (isatty(fileno(FP)))
803*65845Sbostic #endif
804*65845Sbostic 
805*65845Sbostic /* From valops.c */
806*65845Sbostic 
807*65845Sbostic extern CORE_ADDR
808*65845Sbostic push_bytes PARAMS ((CORE_ADDR, char *, int));
809*65845Sbostic 
810*65845Sbostic /* In some modules, we don't have a definition of REGISTER_TYPE yet, so we
811*65845Sbostic    must avoid prototyping this function for now.  FIXME.  Should be:
812*65845Sbostic extern CORE_ADDR
813*65845Sbostic push_word PARAMS ((CORE_ADDR, REGISTER_TYPE));
814*65845Sbostic  */
815*65845Sbostic extern CORE_ADDR
816*65845Sbostic push_word ();
817*65845Sbostic 
818*65845Sbostic /* Some parts of gdb might be considered optional, in the sense that they
819*65845Sbostic    are not essential for being able to build a working, usable debugger
820*65845Sbostic    for a specific environment.  For example, the maintenance commands
821*65845Sbostic    are there for the benefit of gdb maintainers.  As another example,
822*65845Sbostic    some environments really don't need gdb's that are able to read N
823*65845Sbostic    different object file formats.  In order to make it possible (but
824*65845Sbostic    not necessarily recommended) to build "stripped down" versions of
825*65845Sbostic    gdb, the following defines control selective compilation of those
826*65845Sbostic    parts of gdb which can be safely left out when necessary.  Note that
827*65845Sbostic    the default is to include everything. */
828*65845Sbostic 
829*65845Sbostic #ifndef MAINTENANCE_CMDS
830*65845Sbostic #define MAINTENANCE_CMDS 1
831*65845Sbostic #endif
832*65845Sbostic 
833*65845Sbostic #endif /* !defined (DEFS_H) */
834