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