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