* defs.h (enum language): Add language_java.
[deliverable/binutils-gdb.git] / gdb / defs.h
CommitLineData
7d9884b9 1/* Basic, host-specific, and target-specific definitions for GDB.
81afee37 2 Copyright (C) 1986, 1989, 1991, 1992, 1993, 1994, 1995, 1996
6f54efdc 3 Free Software Foundation, Inc.
bd5635a1
RP
4
5This file is part of GDB.
6
a10c0d36 7This program is free software; you can redistribute it and/or modify
bd5635a1 8it under the terms of the GNU General Public License as published by
a10c0d36
JG
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
bd5635a1 11
a10c0d36 12This program is distributed in the hope that it will be useful,
bd5635a1
RP
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
a10c0d36 18along with this program; if not, write to the Free Software
b6d70e15 19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
bd5635a1 20
09722039
SG
21#ifndef DEFS_H
22#define DEFS_H
d747e0af 23
a243a22f 24#include "config.h" /* Generated by configure */
d747e0af 25#include <stdio.h>
81afee37
FF
26#include <errno.h> /* System call error return status */
27
28/* Just in case they're not defined in stdio.h. */
29
30#ifndef SEEK_SET
31#define SEEK_SET 0
32#endif
33#ifndef SEEK_CUR
34#define SEEK_CUR 1
35#endif
d747e0af
MT
36
37/* First include ansidecl.h so we can use the various macro definitions
debd3443 38 here and in all subsequent file inclusions. */
d747e0af
MT
39
40#include "ansidecl.h"
41
45993f61
SC
42#ifdef ANSI_PROTOTYPES
43#include <stdarg.h>
44#else
45#include <varargs.h>
46#endif
47
97e7b66f
DE
48#include "libiberty.h"
49
50/* libiberty.h can't declare this one, but evidently we can. */
51extern char *strsignal PARAMS ((int));
52
c023fbf4
KH
53#include "progress.h"
54
031c4a7e 55#ifndef NO_MMALLOC
86db943c 56#include "mmalloc.h"
031c4a7e 57#endif
86db943c 58
7343d716
JK
59/* For BFD64 and bfd_vma. */
60#include "bfd.h"
61
62/* An address in the program being debugged. Host byte order. Rather
63 than duplicate all the logic in BFD which figures out what type
64 this is (long, long long, etc.) and whether it needs to be 64
65 bits (the host/target interactions are subtle), we just use
66 bfd_vma. */
67
68typedef bfd_vma CORE_ADDR;
bd5635a1 69
28444bf3 70#ifndef min
bd5635a1 71#define min(a, b) ((a) < (b) ? (a) : (b))
28444bf3
DP
72#endif
73#ifndef max
bd5635a1 74#define max(a, b) ((a) > (b) ? (a) : (b))
28444bf3 75#endif
bd5635a1 76
2e4964ad
FF
77/* Gdb does *lots* of string compares. Use macros to speed them up by
78 avoiding function calls if the first characters are not the same. */
79
bd5d07d9 80#define STRCMP(a,b) (*(a) == *(b) ? strcmp ((a), (b)) : (int)*(a) - (int)*(b))
2e4964ad
FF
81#define STREQ(a,b) (*(a) == *(b) ? !strcmp ((a), (b)) : 0)
82#define STREQN(a,b,c) (*(a) == *(b) ? !strncmp ((a), (b), (c)) : 0)
83
dd577ca5 84/* The character GNU C++ uses to build identifiers that must be unique from
bd5635a1
RP
85 the program's identifiers (such as $this and $$vptr). */
86#define CPLUS_MARKER '$' /* May be overridden to '.' for SysV */
87
81afee37
FF
88/* Check if a character is one of the commonly used C++ marker characters. */
89extern int is_cplus_marker PARAMS ((int));
bd5635a1
RP
90
91extern int quit_flag;
92extern int immediate_quit;
51b80b00 93extern int sevenbit_strings;
d747e0af 94
6f54efdc 95extern void quit PARAMS ((void));
bd5635a1 96
28444bf3
DP
97#ifdef QUIT
98/* do twice to force compiler warning */
16a43bf4
DP
99#define QUIT_FIXME "FIXME"
100#define QUIT_FIXME "ignoring redefinition of QUIT"
28444bf3 101#else
c023fbf4
KH
102#define QUIT { \
103 if (quit_flag) quit (); \
104 if (interactive_hook) interactive_hook (); \
105 PROGRESS (1); \
106}
28444bf3 107#endif
bd5635a1 108
e58de8a2
FF
109/* Command classes are top-level categories into which commands are broken
110 down for "help" purposes.
111 Notes on classes: class_alias is for alias commands which are not
112 abbreviations of the original command. class-pseudo is for commands
113 which are not really commands nor help topics ("stop"). */
bd5635a1
RP
114
115enum command_class
116{
117 /* Special args to help_list */
118 all_classes = -2, all_commands = -1,
119 /* Classes of commands */
120 no_class = -1, class_run = 0, class_vars, class_stack,
121 class_files, class_support, class_info, class_breakpoint,
e58de8a2
FF
122 class_alias, class_obscure, class_user, class_maintenance,
123 class_pseudo
bd5635a1
RP
124};
125
bd5d07d9
FF
126/* Languages represented in the symbol table and elsewhere.
127 This should probably be in language.h, but since enum's can't
128 be forward declared to satisfy opaque references before their
129 actual definition, needs to be here. */
130
131enum language
132{
133 language_unknown, /* Language not known */
134 language_auto, /* Placeholder for automatic setting */
135 language_c, /* C */
136 language_cplus, /* C++ */
7a9eb4c4 137 language_java, /* Java */
bd5d07d9 138 language_chill, /* Chill */
e52bfe0c 139 language_fortran, /* Fortran */
754e5da2 140 language_m2, /* Modula-2 */
0e4ca328
PB
141 language_asm, /* Assembly language */
142 language_scm /* Scheme / Guile */
bd5d07d9
FF
143};
144
bd5635a1
RP
145/* the cleanup list records things that have to be undone
146 if an error happens (descriptors to be closed, memory to be freed, etc.)
147 Each link in the chain records a function to call and an
148 argument to give it.
149
150 Use make_cleanup to add an element to the cleanup chain.
151 Use do_cleanups to do all cleanup actions back to a given
152 point in the chain. Use discard_cleanups to remove cleanups
153 from the chain back to a given point, not doing them. */
154
155struct cleanup
156{
157 struct cleanup *next;
d747e0af
MT
158 void (*function) PARAMS ((PTR));
159 PTR arg;
bd5635a1
RP
160};
161
413cba82
JL
162
163/* The ability to declare that a function never returns is useful, but
164 not really required to compile GDB successfully, so the NORETURN and
165 ATTR_NORETURN macros normally expand into nothing. */
166
167/* If compiling with older versions of GCC, a function may be declared
168 "volatile" to indicate that it does not return. */
169
170#ifndef NORETURN
171# if defined(__GNUC__) \
b6d70e15 172 && (__GNUC__ == 1 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
413cba82
JL
173# define NORETURN volatile
174# else
175# define NORETURN /* nothing */
176# endif
177#endif
178
179/* GCC 2.5 and later versions define a function attribute "noreturn",
b6d70e15
SC
180 which is the preferred way to declare that a function never returns.
181 However GCC 2.7 appears to be the first version in which this fully
182 works everywhere we use it. */
413cba82
JL
183
184#ifndef ATTR_NORETURN
b6d70e15 185# if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
413cba82
JL
186# define ATTR_NORETURN __attribute__ ((noreturn))
187# else
188# define ATTR_NORETURN /* nothing */
189# endif
190#endif
191
192#ifndef ATTR_FORMAT
b6d70e15 193# if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 4 && defined (__ANSI_PROTOTYPES)
413cba82
JL
194# define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y)))
195# else
196# define ATTR_FORMAT(type, x, y) /* nothing */
197# endif
198#endif
199
637b1661
SG
200/* Needed for various prototypes */
201
202#ifdef __STDC__
203struct symtab;
204struct breakpoint;
205#endif
206
d747e0af
MT
207/* From blockframe.c */
208
6f54efdc 209extern int inside_entry_func PARAMS ((CORE_ADDR));
d747e0af 210
6f54efdc 211extern int inside_entry_file PARAMS ((CORE_ADDR addr));
d747e0af 212
6f54efdc 213extern int inside_main_func PARAMS ((CORE_ADDR pc));
d747e0af 214
7532cf10
FF
215/* From ch-lang.c, for the moment. (FIXME) */
216
6f54efdc 217extern char *chill_demangle PARAMS ((const char *));
7532cf10 218
d747e0af
MT
219/* From utils.c */
220
b607efe7
FF
221extern void notice_quit PARAMS ((void));
222
6f54efdc 223extern int strcmp_iw PARAMS ((const char *, const char *));
d630b615 224
6f54efdc 225extern char *safe_strerror PARAMS ((int));
e146177e 226
6f54efdc 227extern char *safe_strsignal PARAMS ((int));
e146177e 228
6f54efdc 229extern void init_malloc PARAMS ((void *));
d747e0af 230
6f54efdc 231extern void request_quit PARAMS ((int));
d747e0af 232
6f54efdc 233extern void do_cleanups PARAMS ((struct cleanup *));
16a43bf4 234extern void do_final_cleanups PARAMS ((struct cleanup *));
7a9eb4c4 235extern void do_my_cleanups PARAMS ((struct cleanup **, struct cleanup *));
d747e0af 236
6f54efdc 237extern void discard_cleanups PARAMS ((struct cleanup *));
16a43bf4 238extern void discard_final_cleanups PARAMS ((struct cleanup *));
7a9eb4c4 239extern void discard_my_cleanups PARAMS ((struct cleanup **, struct cleanup *));
d747e0af
MT
240
241/* The bare make_cleanup function is one of those rare beasts that
242 takes almost any type of function as the first arg and anything that
243 will fit in a "void *" as the second arg.
244
245 Should be, once all calls and called-functions are cleaned up:
246extern struct cleanup *
84d59861 247make_cleanup PARAMS ((void (*function) (void *), void *));
d747e0af
MT
248
249 Until then, lint and/or various type-checking compiler options will
250 complain about make_cleanup calls. It'd be wrong to just cast things,
251 since the type actually passed when the function is called would be
252 wrong. */
253
6f54efdc 254extern struct cleanup *make_cleanup ();
16a43bf4
DP
255extern struct cleanup *
256make_final_cleanup PARAMS ((void (*function) (void *), void *));
257extern struct cleanup *
7a9eb4c4 258make_my_cleanup PARAMS ((struct cleanup **, void (*function) (void *), void *));
d747e0af 259
6f54efdc 260extern struct cleanup *save_cleanups PARAMS ((void));
16a43bf4 261extern struct cleanup *save_final_cleanups PARAMS ((void));
7a9eb4c4 262extern struct cleanup *save_my_cleanups PARAMS ((struct cleanup **));
d747e0af 263
6f54efdc 264extern void restore_cleanups PARAMS ((struct cleanup *));
16a43bf4 265extern void restore_final_cleanups PARAMS ((struct cleanup *));
7a9eb4c4 266extern void restore_my_cleanups PARAMS ((struct cleanup **, struct cleanup *));
d747e0af 267
6f54efdc 268extern void free_current_contents PARAMS ((char **));
d747e0af 269
b607efe7 270extern void null_cleanup PARAMS ((PTR));
d747e0af 271
6f54efdc 272extern int myread PARAMS ((int, char *, int));
d747e0af 273
413cba82
JL
274extern int query PARAMS((char *, ...))
275 ATTR_FORMAT(printf, 1, 2);
b607efe7
FF
276
277/* From demangle.c */
278
279extern void set_demangling_style PARAMS ((char *));
280
6c803036 281\f
96f7edbd
JK
282/* Annotation stuff. */
283
6c803036
JK
284extern int annotation_level; /* in stack.c */
285\f
6f54efdc 286extern void begin_line PARAMS ((void));
51b80b00 287
6f54efdc 288extern void wrap_here PARAMS ((char *));
d747e0af 289
6f54efdc 290extern void reinitialize_more_filter PARAMS ((void));
d747e0af 291
04f566a3
JK
292typedef FILE GDB_FILE;
293#define gdb_stdout stdout
294#define gdb_stderr stderr
295
6f54efdc 296extern void gdb_flush PARAMS ((GDB_FILE *));
04f566a3 297
6f54efdc 298extern GDB_FILE *gdb_fopen PARAMS ((char * name, char * mode));
04f566a3 299
6f54efdc 300extern void fputs_filtered PARAMS ((const char *, GDB_FILE *));
04f566a3 301
6f54efdc 302extern void fputs_unfiltered PARAMS ((const char *, GDB_FILE *));
d747e0af 303
8989d4fc 304extern int fputc_unfiltered PARAMS ((int c, GDB_FILE *));
04f566a3 305
8989d4fc 306extern int putchar_unfiltered PARAMS ((int c));
d747e0af 307
81afee37 308extern void puts_filtered PARAMS ((const char *));
d747e0af 309
81afee37 310extern void puts_unfiltered PARAMS ((const char *));
04f566a3 311
81afee37 312extern void vprintf_filtered PARAMS ((const char *, va_list))
413cba82 313 ATTR_FORMAT(printf, 1, 0);
51b80b00 314
81afee37 315extern void vfprintf_filtered PARAMS ((FILE *, const char *, va_list))
413cba82 316 ATTR_FORMAT(printf, 2, 0);
a8e033f2 317
81afee37 318extern void fprintf_filtered PARAMS ((FILE *, const char *, ...))
413cba82 319 ATTR_FORMAT(printf, 2, 3);
d747e0af 320
81afee37 321extern void fprintfi_filtered PARAMS ((int, FILE *, const char *, ...))
413cba82 322 ATTR_FORMAT(printf, 3, 4);
a8e033f2 323
81afee37 324extern void printf_filtered PARAMS ((const char *, ...))
413cba82 325 ATTR_FORMAT(printf, 1, 2);
d747e0af 326
81afee37 327extern void printfi_filtered PARAMS ((int, const char *, ...))
413cba82 328 ATTR_FORMAT(printf, 2, 3);
a8e033f2 329
81afee37 330extern void vprintf_unfiltered PARAMS ((const char *, va_list))
413cba82 331 ATTR_FORMAT(printf, 1, 0);
04f566a3 332
81afee37 333extern void vfprintf_unfiltered PARAMS ((FILE *, const char *, va_list))
413cba82 334 ATTR_FORMAT(printf, 2, 0);
04f566a3 335
81afee37 336extern void fprintf_unfiltered PARAMS ((FILE *, const char *, ...))
413cba82 337 ATTR_FORMAT(printf, 2, 3);
d747e0af 338
81afee37 339extern void printf_unfiltered PARAMS ((const char *, ...))
413cba82 340 ATTR_FORMAT(printf, 1, 2);
04f566a3 341
6f54efdc 342extern void print_spaces PARAMS ((int, GDB_FILE *));
04f566a3 343
6f54efdc 344extern void print_spaces_filtered PARAMS ((int, GDB_FILE *));
d747e0af 345
6f54efdc 346extern char *n_spaces PARAMS ((int));
d747e0af 347
6f54efdc 348extern void gdb_printchar PARAMS ((int, GDB_FILE *, int));
d747e0af 349
833e0d94
JK
350extern void gdb_print_address PARAMS ((void *, GDB_FILE *));
351
28444bf3
DP
352typedef bfd_vma t_addr;
353typedef bfd_vma t_reg;
354extern char* paddr PARAMS ((t_addr addr));
355
356extern char* preg PARAMS ((t_reg reg));
357
16a43bf4
DP
358extern char* paddr_nz PARAMS ((t_addr addr));
359
360extern char* preg_nz PARAMS ((t_reg reg));
361
6f54efdc
SS
362extern void fprintf_symbol_filtered PARAMS ((GDB_FILE *, char *,
363 enum language, int));
d747e0af 364
6f54efdc 365extern void perror_with_name PARAMS ((char *));
d747e0af 366
6f54efdc 367extern void print_sys_errmsg PARAMS ((char *, int));
d747e0af 368
1bef45ea
JK
369/* From regex.c or libc. BSD 4.4 declares this with the argument type as
370 "const char *" in unistd.h, so we can't declare the argument
371 as "char *". */
d747e0af 372
6f54efdc 373extern char *re_comp PARAMS ((const char *));
d747e0af
MT
374
375/* From symfile.c */
376
6f54efdc 377extern void symbol_file_command PARAMS ((char *, int));
d747e0af 378
eba08643 379/* From top.c */
d747e0af 380
6f54efdc 381extern char *skip_quoted PARAMS ((char *));
d630b615 382
6f54efdc 383extern char *gdb_readline PARAMS ((char *));
d747e0af 384
6f54efdc 385extern char *command_line_input PARAMS ((char *, int, char *));
d747e0af 386
6f54efdc 387extern void print_prompt PARAMS ((void));
d747e0af 388
6f54efdc 389extern int input_from_terminal_p PARAMS ((void));
d747e0af 390
eba08643
C
391extern int info_verbose;
392
bd5635a1 393/* From printcmd.c */
d747e0af 394
6f54efdc 395extern void set_next_address PARAMS ((CORE_ADDR));
d747e0af 396
6f54efdc
SS
397extern void print_address_symbolic PARAMS ((CORE_ADDR, GDB_FILE *, int,
398 char *));
d747e0af 399
6f54efdc 400extern void print_address_numeric PARAMS ((CORE_ADDR, int, GDB_FILE *));
833e0d94 401
6f54efdc 402extern void print_address PARAMS ((CORE_ADDR, GDB_FILE *));
bd5635a1 403
e1ce8aa5 404/* From source.c */
d747e0af 405
6f54efdc 406extern int openp PARAMS ((char *, int, char *, int, int, char **));
d747e0af 407
6f54efdc 408extern void mod_path PARAMS ((char *, char **));
d747e0af 409
6f54efdc 410extern void directory_command PARAMS ((char *, int));
d747e0af 411
6f54efdc 412extern void init_source_path PARAMS ((void));
d747e0af 413
637b1661
SG
414extern char *symtab_to_filename PARAMS ((struct symtab *));
415
d747e0af
MT
416/* From findvar.c */
417
6f54efdc 418extern int read_relative_register_raw_bytes PARAMS ((int, char *));
e1ce8aa5 419
bd5635a1 420/* From readline (but not in any readline .h files). */
d747e0af 421
6f54efdc 422extern char *tilde_expand PARAMS ((char *));
bd5635a1 423
78751d4f
PS
424/* Control types for commands */
425
426enum misc_command_type
427{
428 ok_command,
429 end_command,
430 else_command,
431 nop_command
432};
433
434enum command_control_type
435{
436 simple_control,
437 break_control,
438 continue_control,
439 while_control,
440 if_control,
441 invalid_control
442};
443
bd5635a1
RP
444/* Structure for saved commands lines
445 (for breakpoints, defined commands, etc). */
446
447struct command_line
448{
449 struct command_line *next;
450 char *line;
78751d4f
PS
451 enum command_control_type control_type;
452 int body_count;
453 struct command_line **body_list;
bd5635a1
RP
454};
455
91550191 456extern struct command_line *read_command_lines PARAMS ((char *, int));
d747e0af 457
6f54efdc 458extern void free_command_lines PARAMS ((struct command_line **));
bd5635a1
RP
459
460/* String containing the current directory (what getwd would return). */
461
d747e0af 462extern char *current_directory;
bd5635a1
RP
463
464/* Default radixes for input and output. Only some values supported. */
465extern unsigned input_radix;
466extern unsigned output_radix;
467
a8a69e63
FF
468/* Possibilities for prettyprint parameters to routines which print
469 things. Like enum language, this should be in value.h, but needs
470 to be here for the same reason. FIXME: If we can eliminate this
471 as an arg to LA_VAL_PRINT, then we can probably move it back to
472 value.h. */
473
474enum val_prettyprint
475{
476 Val_no_prettyprint = 0,
477 Val_prettyprint,
478 /* Use the default setting which the user has specified. */
479 Val_pretty_default
480};
481
0a5d35ed
SG
482\f
483/* Host machine definition. This will be a symlink to one of the
484 xm-*.h files, built by the `configure' script. */
485
486#include "xm.h"
487
e58de8a2
FF
488/* Native machine support. This will be a symlink to one of the
489 nm-*.h files, built by the `configure' script. */
490
491#include "nm.h"
492
c023fbf4
KH
493/* Target machine definition. This will be a symlink to one of the
494 tm-*.h files, built by the `configure' script. */
495
496#include "tm.h"
497
e146177e
SEF
498/* If the xm.h file did not define the mode string used to open the
499 files, assume that binary files are opened the same way as text
500 files */
501#ifndef FOPEN_RB
502#include "fopen-same.h"
503#endif
504
b51843d8
FF
505/* Microsoft C can't deal with const pointers */
506
507#ifdef _MSC_VER
508#define CONST_PTR
509#else
510#define CONST_PTR const
511#endif
512
0a5d35ed 513/*
b51843d8
FF
514 * Allow things in gdb to be declared "volatile". If compiling ANSI, it
515 * just works. If compiling with gcc but non-ansi, redefine to __volatile__.
516 * If non-ansi, non-gcc, then eliminate "volatile" entirely, making those
0a5d35ed
SG
517 * objects be read-write rather than read-only.
518 */
519
0a5d35ed
SG
520#ifndef volatile
521#ifndef __STDC__
522# ifdef __GNUC__
523# define volatile __volatile__
524# else
525# define volatile /*nothing*/
526# endif /* GNUC */
527#endif /* STDC */
528#endif /* volatile */
529
3f550b59
FF
530/* Defaults for system-wide constants (if not defined by xm.h, we fake it).
531 FIXME: Assumes 2's complement arithmetic */
0a5d35ed 532
bd5635a1 533#if !defined (UINT_MAX)
38dc5e12 534#define UINT_MAX ((unsigned int)(~0)) /* 0xFFFFFFFF for 32-bits */
bd5635a1
RP
535#endif
536
e1ce8aa5 537#if !defined (INT_MAX)
dd577ca5 538#define INT_MAX ((int)(UINT_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
e1ce8aa5
JK
539#endif
540
541#if !defined (INT_MIN)
3f550b59 542#define INT_MIN ((int)((int) ~0 ^ INT_MAX)) /* 0x80000000 for 32-bits */
38dc5e12
SG
543#endif
544
545#if !defined (ULONG_MAX)
546#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */
547#endif
548
549#if !defined (LONG_MAX)
550#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
e1ce8aa5
JK
551#endif
552
7a9eb4c4
PB
553#ifndef LONGEST
554
7343d716
JK
555#ifdef BFD64
556
557/* This is to make sure that LONGEST is at least as big as CORE_ADDR. */
558
70126bf9 559#define LONGEST BFD_HOST_64_BIT
16a43bf4 560#define ULONGEST BFD_HOST_U_64_BIT
7343d716
JK
561
562#else /* No BFD64 */
563
7efb57c3
FF
564# ifdef CC_HAS_LONG_LONG
565# define LONGEST long long
16a43bf4 566# define ULONGEST unsigned long long
7efb57c3 567# else
7a9eb4c4
PB
568/* BFD_HOST_64_BIT is defined for some hosts that don't have long long
569 (e.g. i386-windows) so try it. */
570# ifdef BFD_HOST_64_BIT
571# define LONGEST BFD_HOST_64_BIT
572# define ULONGEST BFD_HOST_U_64_BIT
573# else
574# define LONGEST long
575# define ULONGEST unsigned long
576# endif
7efb57c3 577# endif
7efb57c3 578
7343d716
JK
579#endif /* No BFD64 */
580
7a9eb4c4
PB
581#endif /* ! LONGEST */
582
7efb57c3
FF
583/* Convert a LONGEST to an int. This is used in contexts (e.g. number of
584 arguments to a function, number in a value history, register number, etc.)
585 where the value must not be larger than can fit in an int. */
586
fb0f4231 587extern int longest_to_int PARAMS ((LONGEST));
d747e0af 588
0a5d35ed
SG
589/* Assorted functions we can declare, now that const and volatile are
590 defined. */
d747e0af 591
6f54efdc 592extern char *savestring PARAMS ((const char *, int));
d747e0af 593
6f54efdc 594extern char *msavestring PARAMS ((void *, const char *, int));
318bf84f 595
6f54efdc 596extern char *strsave PARAMS ((const char *));
d747e0af 597
6f54efdc 598extern char *mstrsave PARAMS ((void *, const char *));
318bf84f 599
cad9cd60 600#ifdef _MSC_VER /* FIXME; was long, but this causes compile errors in msvc if already defined */
28444bf3
DP
601extern PTR xmmalloc PARAMS ((PTR, size_t));
602
603extern PTR xmrealloc PARAMS ((PTR, PTR, size_t));
604#else
6f54efdc 605extern PTR xmmalloc PARAMS ((PTR, long));
318bf84f 606
6f54efdc 607extern PTR xmrealloc PARAMS ((PTR, PTR, long));
28444bf3 608#endif
318bf84f 609
6f54efdc 610extern int parse_escape PARAMS ((char **));
d747e0af 611
86db943c 612extern char *reg_names[];
d747e0af 613
833e0d94
JK
614/* Message to be printed before the error message, when an error occurs. */
615
616extern char *error_pre_print;
617
8989d4fc
JK
618/* Message to be printed before the error message, when an error occurs. */
619
620extern char *quit_pre_print;
621
833e0d94
JK
622/* Message to be printed before the warning message, when a warning occurs. */
623
624extern char *warning_pre_print;
625
85c613aa 626extern NORETURN void error PARAMS((char *, ...)) ATTR_NORETURN;
a0cf4681
JK
627
628extern void error_begin PARAMS ((void));
d747e0af 629
85c613aa 630extern NORETURN void fatal PARAMS((char *, ...)) ATTR_NORETURN;
d747e0af 631
6f54efdc 632extern NORETURN void nomem PARAMS ((long)) ATTR_NORETURN;
318bf84f 633
2fcdae93
PS
634/* Reasons for calling return_to_top_level. */
635enum return_reason {
636 /* User interrupt. */
637 RETURN_QUIT,
638
639 /* Any other error. */
640 RETURN_ERROR
641};
642
643#define RETURN_MASK_QUIT (1 << (int)RETURN_QUIT)
644#define RETURN_MASK_ERROR (1 << (int)RETURN_ERROR)
645#define RETURN_MASK_ALL (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
646typedef int return_mask;
647
6f54efdc
SS
648extern NORETURN void
649return_to_top_level PARAMS ((enum return_reason)) ATTR_NORETURN;
2fcdae93 650
6f54efdc
SS
651extern int
652catch_errors PARAMS ((int (*) (char *), void *, char *, return_mask));
d747e0af 653
8989d4fc 654extern void warning_begin PARAMS ((void));
d747e0af 655
413cba82
JL
656extern void warning PARAMS ((char *, ...))
657 ATTR_FORMAT(printf, 1, 2);
d747e0af 658
97e7b66f
DE
659/* Global functions from other, non-gdb GNU thingies.
660 Libiberty thingies are no longer declared here. We include libiberty.h
661 above, instead. */
d747e0af 662
6b009ef6 663#ifndef GETENV_PROVIDED
6f54efdc 664extern char *getenv PARAMS ((const char *));
6b009ef6 665#endif
d747e0af 666
e146177e
SEF
667/* From other system libraries */
668
b51843d8 669#ifdef HAVE_STDDEF_H
d747e0af 670#include <stddef.h>
b51843d8
FF
671#endif
672
673#ifdef HAVE_STDLIB_H
28444bf3
DP
674#if defined(_MSC_VER) && !defined(__cplusplus)
675/* msvc defines these in stdlib.h for c code */
676#undef min
677#undef max
678#endif
e3be225e 679#include <stdlib.h>
0a5d35ed 680#endif
28444bf3
DP
681#ifndef min
682#define min(a, b) ((a) < (b) ? (a) : (b))
683#endif
684#ifndef max
685#define max(a, b) ((a) > (b) ? (a) : (b))
686#endif
d747e0af 687
6b009ef6
SC
688
689/* We take the address of fclose later, but some stdio's forget
690 to declare this. We can't always declare it since there's
691 no way to declare the parameters without upsetting some compiler
692 somewhere. */
693
694#ifndef FCLOSE_PROVIDED
b607efe7 695extern int fclose PARAMS ((FILE *));
6b009ef6 696#endif
e146177e 697
8989d4fc 698#ifndef atof
b607efe7 699extern double atof PARAMS ((const char *)); /* X3.159-1989 4.10.1.1 */
8989d4fc 700#endif
51b57ded 701
d747e0af 702#ifndef MALLOC_INCOMPATIBLE
318bf84f 703
b51843d8 704#ifdef NEED_DECLARATION_MALLOC
e3be225e 705extern PTR malloc ();
b51843d8 706#endif
d747e0af 707
b51843d8 708#ifdef NEED_DECLARATION_REALLOC
e3be225e 709extern PTR realloc ();
b51843d8 710#endif
318bf84f 711
b51843d8 712#ifdef NEED_DECLARATION_FREE
e3be225e 713extern void free ();
b51843d8 714#endif
d747e0af 715
e3be225e 716#endif /* MALLOC_INCOMPATIBLE */
d747e0af 717
0a5d35ed
SG
718/* Various possibilities for alloca. */
719#ifndef alloca
720# ifdef __GNUC__
721# define alloca __builtin_alloca
7343d716 722# else /* Not GNU C */
0a5d35ed 723# ifdef sparc
22fd4704 724# include <alloca.h> /* NOTE: Doesn't declare alloca() */
e676a15f 725# endif
7343d716
JK
726
727/* We need to be careful not to declare this in a way which conflicts with
728 bison. Bison never declares it as char *, but under various circumstances
729 (like __hpux) we need to use void *. */
730# if defined (__STDC__) || defined (__hpux)
731 extern void *alloca ();
732# else /* Don't use void *. */
0f552c5f 733 extern char *alloca ();
7343d716
JK
734# endif /* Don't use void *. */
735# endif /* Not GNU C */
736#endif /* alloca not defined */
e2aab031 737
479f0f18 738/* HOST_BYTE_ORDER must be defined to one of these. */
a10c0d36 739
d8efbc66
FF
740#ifdef HAVE_ENDIAN_H
741#include <endian.h>
742#endif
743
0a5d35ed
SG
744#if !defined (BIG_ENDIAN)
745#define BIG_ENDIAN 4321
746#endif
a10c0d36 747
0a5d35ed
SG
748#if !defined (LITTLE_ENDIAN)
749#define LITTLE_ENDIAN 1234
750#endif
a10c0d36 751
2fcdae93 752/* Target-system-dependent parameters for GDB. */
7d9884b9 753
479f0f18
SG
754#ifdef TARGET_BYTE_ORDER_SELECTABLE
755/* The target endianness is selectable at runtime. Define
756 TARGET_BYTE_ORDER to be a variable. The user can use the `set
757 endian' command to change it. */
758#undef TARGET_BYTE_ORDER
759#define TARGET_BYTE_ORDER target_byte_order
760extern int target_byte_order;
761#endif
762
763extern void set_endian_from_file PARAMS ((bfd *));
764
04f566a3
JK
765/* Number of bits in a char or unsigned char for the target machine.
766 Just like CHAR_BIT in <limits.h> but describes the target machine. */
767#if !defined (TARGET_CHAR_BIT)
768#define TARGET_CHAR_BIT 8
769#endif
770
771/* Number of bits in a short or unsigned short for the target machine. */
772#if !defined (TARGET_SHORT_BIT)
773#define TARGET_SHORT_BIT (2 * TARGET_CHAR_BIT)
774#endif
775
776/* Number of bits in an int or unsigned int for the target machine. */
777#if !defined (TARGET_INT_BIT)
778#define TARGET_INT_BIT (4 * TARGET_CHAR_BIT)
779#endif
780
781/* Number of bits in a long or unsigned long for the target machine. */
782#if !defined (TARGET_LONG_BIT)
783#define TARGET_LONG_BIT (4 * TARGET_CHAR_BIT)
784#endif
785
786/* Number of bits in a long long or unsigned long long for the target machine. */
787#if !defined (TARGET_LONG_LONG_BIT)
788#define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT)
789#endif
790
791/* Number of bits in a float for the target machine. */
792#if !defined (TARGET_FLOAT_BIT)
793#define TARGET_FLOAT_BIT (4 * TARGET_CHAR_BIT)
794#endif
795
796/* Number of bits in a double for the target machine. */
797#if !defined (TARGET_DOUBLE_BIT)
798#define TARGET_DOUBLE_BIT (8 * TARGET_CHAR_BIT)
799#endif
800
801/* Number of bits in a long double for the target machine. */
802#if !defined (TARGET_LONG_DOUBLE_BIT)
803#define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT)
804#endif
805
04f566a3
JK
806/* Number of bits in a pointer for the target machine */
807#if !defined (TARGET_PTR_BIT)
808#define TARGET_PTR_BIT TARGET_INT_BIT
809#endif
810
811/* If we picked up a copy of CHAR_BIT from a configuration file
812 (which may get it by including <limits.h>) then use it to set
813 the number of bits in a host char. If not, use the same size
814 as the target. */
815
816#if defined (CHAR_BIT)
817#define HOST_CHAR_BIT CHAR_BIT
818#else
819#define HOST_CHAR_BIT TARGET_CHAR_BIT
820#endif
821
7d9884b9
JG
822/* The bit byte-order has to do just with numbering of bits in
823 debugging symbols and such. Conceptually, it's quite separate
824 from byte/word byte order. */
825
826#if !defined (BITS_BIG_ENDIAN)
479f0f18
SG
827#ifndef TARGET_BYTE_ORDER_SELECTABLE
828
7d9884b9
JG
829#if TARGET_BYTE_ORDER == BIG_ENDIAN
830#define BITS_BIG_ENDIAN 1
831#endif /* Big endian. */
832
833#if TARGET_BYTE_ORDER == LITTLE_ENDIAN
834#define BITS_BIG_ENDIAN 0
835#endif /* Little endian. */
479f0f18
SG
836
837#else /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
838
839#define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BIG_ENDIAN)
840
841#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */
7d9884b9
JG
842#endif /* BITS_BIG_ENDIAN not defined. */
843
e3c16900 844/* In findvar.c. */
e3c16900 845
6f54efdc
SS
846extern LONGEST extract_signed_integer PARAMS ((void *, int));
847
16a43bf4 848extern ULONGEST extract_unsigned_integer PARAMS ((void *, int));
6f54efdc 849
a243a22f
SG
850extern int extract_long_unsigned_integer PARAMS ((void *, int, LONGEST *));
851
6f54efdc
SS
852extern CORE_ADDR extract_address PARAMS ((void *, int));
853
854extern void store_signed_integer PARAMS ((void *, int, LONGEST));
855
16a43bf4 856extern void store_unsigned_integer PARAMS ((void *, int, ULONGEST));
6f54efdc
SS
857
858extern void store_address PARAMS ((void *, int, CORE_ADDR));
859
a243a22f
SG
860/* Setup definitions for host and target floating point formats. We need to
861 consider the format for `float', `double', and `long double' for both target
862 and host. We need to do this so that we know what kind of conversions need
863 to be done when converting target numbers to and from the hosts DOUBLEST
864 data type. */
865
866/* This is used to indicate that we don't know the format of the floating point
867 number. Typically, this is useful for native ports, where the actual format
868 is irrelevant, since no conversions will be taking place. */
869
870extern const struct floatformat floatformat_unknown;
871
872#if HOST_BYTE_ORDER == BIG_ENDIAN
873# ifndef HOST_FLOAT_FORMAT
874# define HOST_FLOAT_FORMAT &floatformat_ieee_single_big
875# endif
876# ifndef HOST_DOUBLE_FORMAT
877# define HOST_DOUBLE_FORMAT &floatformat_ieee_double_big
878# endif
879#else /* LITTLE_ENDIAN */
880# ifndef HOST_FLOAT_FORMAT
881# define HOST_FLOAT_FORMAT &floatformat_ieee_single_little
882# endif
883# ifndef HOST_DOUBLE_FORMAT
884# define HOST_DOUBLE_FORMAT &floatformat_ieee_double_little
885# endif
886#endif
887
888#ifndef HOST_LONG_DOUBLE_FORMAT
889#define HOST_LONG_DOUBLE_FORMAT &floatformat_unknown
890#endif
891
892#ifndef TARGET_BYTE_ORDER_SELECTABLE
893# if TARGET_BYTE_ORDER == BIG_ENDIAN
894# ifndef TARGET_FLOAT_FORMAT
895# define TARGET_FLOAT_FORMAT &floatformat_ieee_single_big
896# endif
897# ifndef TARGET_DOUBLE_FORMAT
898# define TARGET_DOUBLE_FORMAT &floatformat_ieee_double_big
899# endif
900# else /* LITTLE_ENDIAN */
901# ifndef TARGET_FLOAT_FORMAT
902# define TARGET_FLOAT_FORMAT &floatformat_ieee_single_little
903# endif
904# ifndef TARGET_DOUBLE_FORMAT
905# define TARGET_DOUBLE_FORMAT &floatformat_ieee_double_little
906# endif
907# endif
a243a22f
SG
908#else /* TARGET_BYTE_ORDER_SELECTABLE */
909# ifndef TARGET_FLOAT_FORMAT
c6fbd98b
SG
910# define TARGET_FLOAT_FORMAT (target_byte_order == BIG_ENDIAN \
911 ? &floatformat_ieee_single_big \
912 : &floatformat_ieee_single_little)
a243a22f
SG
913# endif
914# ifndef TARGET_DOUBLE_FORMAT
c6fbd98b
SG
915# define TARGET_DOUBLE_FORMAT (target_byte_order == BIG_ENDIAN \
916 ? &floatformat_ieee_double_big \
917 : &floatformat_ieee_double_little)
a243a22f
SG
918# endif
919#endif
920
c6fbd98b
SG
921#ifndef TARGET_LONG_DOUBLE_FORMAT
922# define TARGET_LONG_DOUBLE_FORMAT &floatformat_unknown
923#endif
924
a243a22f
SG
925/* Use `long double' if the host compiler supports it. (Note that this is not
926 necessarily any longer than `double'. On SunOS/gcc, it's the same as
927 double.) This is necessary because GDB internally converts all floating
928 point values to the widest type supported by the host.
929
930 There are problems however, when the target `long double' is longer than the
931 host's `long double'. In general, we'll probably reduce the precision of
932 any such values and print a warning. */
933
934#ifdef HAVE_LONG_DOUBLE
935typedef long double DOUBLEST;
a243a22f
SG
936#else
937typedef double DOUBLEST;
938#endif
939
91550191
SG
940extern void floatformat_to_doublest PARAMS ((const struct floatformat *,
941 char *, DOUBLEST *));
942extern void floatformat_from_doublest PARAMS ((const struct floatformat *,
943 DOUBLEST *, char *));
a243a22f 944extern DOUBLEST extract_floating PARAMS ((void *, int));
04f566a3 945
a243a22f 946extern void store_floating PARAMS ((void *, int, DOUBLEST));
e3c16900 947\f
7d9884b9
JG
948/* On some machines there are bits in addresses which are not really
949 part of the address, but are used by the kernel, the hardware, etc.
950 for special purposes. ADDR_BITS_REMOVE takes out any such bits
951 so we get a "real" address such as one would find in a symbol
04f566a3 952 table. This is used only for addresses of instructions, and even then
e3c16900
JK
953 I'm not sure it's used in all contexts. It exists to deal with there
954 being a few stray bits in the PC which would mislead us, not as some sort
04f566a3
JK
955 of generic thing to handle alignment or segmentation (it's possible it
956 should be in TARGET_READ_PC instead). */
7d9884b9
JG
957#if !defined (ADDR_BITS_REMOVE)
958#define ADDR_BITS_REMOVE(addr) (addr)
7d9884b9
JG
959#endif /* No ADDR_BITS_REMOVE. */
960
d747e0af
MT
961/* From valops.c */
962
6f54efdc 963extern CORE_ADDR push_bytes PARAMS ((CORE_ADDR, char *, int));
d747e0af 964
16a43bf4 965extern CORE_ADDR push_word PARAMS ((CORE_ADDR, ULONGEST));
d747e0af 966
0239d9b3
FF
967/* Some parts of gdb might be considered optional, in the sense that they
968 are not essential for being able to build a working, usable debugger
969 for a specific environment. For example, the maintenance commands
970 are there for the benefit of gdb maintainers. As another example,
971 some environments really don't need gdb's that are able to read N
972 different object file formats. In order to make it possible (but
973 not necessarily recommended) to build "stripped down" versions of
974 gdb, the following defines control selective compilation of those
975 parts of gdb which can be safely left out when necessary. Note that
976 the default is to include everything. */
977
978#ifndef MAINTENANCE_CMDS
979#define MAINTENANCE_CMDS 1
980#endif
981
45993f61
SC
982#ifdef MAINTENANCE_CMDS
983extern int watchdog;
984#endif
985
09722039
SG
986#include "dis-asm.h" /* Get defs for disassemble_info */
987
18b46e7c
SS
988extern int dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr,
989 int len, disassemble_info *info));
990
991extern void dis_asm_memory_error PARAMS ((int status, bfd_vma memaddr,
992 disassemble_info *info));
993
994extern void dis_asm_print_address PARAMS ((bfd_vma addr,
995 disassemble_info *info));
996
997extern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*));
91550191 998extern disassemble_info tm_print_insn_info;
18b46e7c
SS
999
1000/* Hooks for alternate command interfaces. */
1001
09722039
SG
1002#ifdef __STDC__
1003struct target_waitstatus;
1004struct cmd_list_element;
1005#endif
1006
8164ec2e
SG
1007extern void (*init_ui_hook) PARAMS ((void));
1008extern void (*command_loop_hook) PARAMS ((void));
18b46e7c
SS
1009extern void (*fputs_unfiltered_hook) PARAMS ((const char *linebuffer,
1010 FILE *stream));
1011extern void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s,
1012 int line, int stopline,
1013 int noerror));
91550191 1014extern int (*query_hook) PARAMS ((const char *, va_list));
8164ec2e
SG
1015extern void (*flush_hook) PARAMS ((FILE *stream));
1016extern void (*create_breakpoint_hook) PARAMS ((struct breakpoint *b));
1017extern void (*delete_breakpoint_hook) PARAMS ((struct breakpoint *bpt));
326ae3e2 1018extern void (*modify_breakpoint_hook) PARAMS ((struct breakpoint *bpt));
b6d70e15 1019extern void (*target_output_hook) PARAMS ((char *));
637b1661 1020extern void (*interactive_hook) PARAMS ((void));
16041d53 1021extern void (*registers_changed_hook) PARAMS ((void));
91550191
SG
1022extern void (*readline_begin_hook) PARAMS ((char *, ...));
1023extern char * (*readline_hook) PARAMS ((char *));
1024extern void (*readline_end_hook) PARAMS ((void));
479f0f18
SG
1025
1026extern int (*target_wait_hook) PARAMS ((int pid,
1027 struct target_waitstatus *status));
1028
1029extern void (*call_command_hook) PARAMS ((struct cmd_list_element *c,
1030 char *cmd, int from_tty));
1031
b607efe7 1032extern NORETURN void (*error_hook) PARAMS ((void)) ATTR_NORETURN;
45993f61
SC
1033
1034
1035
754e5da2
SG
1036/* Inhibit window interface if non-zero. */
1037
c5197511 1038extern int use_windows;
754e5da2 1039
45993f61
SC
1040/* Symbolic definitions of filename-related things. */
1041/* FIXME, this doesn't work very well if host and executable
1042 filesystems conventions are different. */
1043
1044#ifndef DIRNAME_SEPARATOR
1045#define DIRNAME_SEPARATOR ':'
1046#endif
1047
1048#ifndef SLASH_P
9e77e83d 1049#if defined(__GO32__)||defined(_WIN32)
b6d70e15
SC
1050#define SLASH_P(X) ((X)=='\\')
1051#else
45993f61
SC
1052#define SLASH_P(X) ((X)=='/')
1053#endif
b6d70e15 1054#endif
45993f61
SC
1055
1056#ifndef SLASH_CHAR
9e77e83d 1057#if defined(__GO32__)||defined(_WIN32)
b6d70e15
SC
1058#define SLASH_CHAR '\\'
1059#else
45993f61
SC
1060#define SLASH_CHAR '/'
1061#endif
b6d70e15 1062#endif
45993f61
SC
1063
1064#ifndef SLASH_STRING
9e77e83d 1065#if defined(__GO32__)||defined(_WIN32)
b6d70e15
SC
1066#define SLASH_STRING "\\"
1067#else
45993f61
SC
1068#define SLASH_STRING "/"
1069#endif
b6d70e15 1070#endif
45993f61
SC
1071
1072#ifndef ROOTED_P
1073#define ROOTED_P(X) (SLASH_P((X)[0]))
1074#endif
1075
16a43bf4
DP
1076/* On some systems, PIDGET is defined to extract the inferior pid from
1077 an internal pid that has the thread id and pid in seperate bit
1078 fields. If not defined, then just use the entire internal pid as
1079 the actual pid. */
1080
1081#ifndef PIDGET
1082#define PIDGET(pid) (pid)
1083#endif
1084
09722039 1085#endif /* #ifndef DEFS_H */
This page took 0.330914 seconds and 4 git commands to generate.