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