import gdb-1999-05-25 snapshot
[deliverable/binutils-gdb.git] / gdb / defs.h
CommitLineData
c906108c 1/* Basic, host-specific, and target-specific definitions for GDB.
7a292a7a 2 Copyright (C) 1986, 89, 91, 92, 93, 94, 95, 96, 1998
c906108c
SS
3 Free Software Foundation, Inc.
4
5This file is part of GDB.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, 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. */
58extern 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
75typedef bfd_vma CORE_ADDR;
76
392a587b
JM
77extern int core_addr_lessthan PARAMS ((CORE_ADDR lhs, CORE_ADDR rhs));
78extern int core_addr_greaterthan PARAMS ((CORE_ADDR lhs, CORE_ADDR rhs));
79
80
c906108c
SS
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. */
100extern int is_cplus_marker PARAMS ((int));
101
102/* use tui interface if non-zero */
103extern 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 */
113extern int xdb_commands;
114
115/* enable dbx commands if set */
116extern int dbx_commands;
117
118extern int quit_flag;
119extern int immediate_quit;
120extern int sevenbit_strings;
121
122extern 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
142enum 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
158enum 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
172enum 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
189struct 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__
237struct symtab;
238struct breakpoint;
239#endif
240
241/* From blockframe.c */
242
243extern int inside_entry_func PARAMS ((CORE_ADDR));
244
245extern int inside_entry_file PARAMS ((CORE_ADDR addr));
246
247extern int inside_main_func PARAMS ((CORE_ADDR pc));
248
249/* From ch-lang.c, for the moment. (FIXME) */
250
251extern char *chill_demangle PARAMS ((const char *));
252
253/* From utils.c */
254
392a587b
JM
255extern void initialize_utils PARAMS ((void));
256
c906108c
SS
257extern void notice_quit PARAMS ((void));
258
259extern int strcmp_iw PARAMS ((const char *, const char *));
260
7a292a7a
SS
261extern int subset_compare PARAMS ((char *, char *));
262
c906108c
SS
263extern char *safe_strerror PARAMS ((int));
264
265extern char *safe_strsignal PARAMS ((int));
266
267extern void init_malloc PARAMS ((void *));
268
269extern void request_quit PARAMS ((int));
270
271extern void do_cleanups PARAMS ((struct cleanup *));
272extern void do_final_cleanups PARAMS ((struct cleanup *));
273extern void do_my_cleanups PARAMS ((struct cleanup **, struct cleanup *));
274extern void do_run_cleanups PARAMS ((struct cleanup *));
275
276extern void discard_cleanups PARAMS ((struct cleanup *));
277extern void discard_final_cleanups PARAMS ((struct cleanup *));
278extern void discard_my_cleanups PARAMS ((struct cleanup **, struct cleanup *));
279
280typedef void (*make_cleanup_func) PARAMS ((void *));
281
282extern struct cleanup *make_cleanup PARAMS ((make_cleanup_func, void *));
283
7a292a7a
SS
284extern struct cleanup *make_cleanup_freeargv PARAMS ((char **));
285
c906108c
SS
286extern struct cleanup *make_final_cleanup PARAMS ((make_cleanup_func, void *));
287
288extern struct cleanup *make_my_cleanup PARAMS ((struct cleanup **,
289 make_cleanup_func, void *));
290
291extern struct cleanup *make_run_cleanup PARAMS ((make_cleanup_func, void *));
292
293extern struct cleanup *save_cleanups PARAMS ((void));
294extern struct cleanup *save_final_cleanups PARAMS ((void));
295extern struct cleanup *save_my_cleanups PARAMS ((struct cleanup **));
296
297extern void restore_cleanups PARAMS ((struct cleanup *));
298extern void restore_final_cleanups PARAMS ((struct cleanup *));
299extern void restore_my_cleanups PARAMS ((struct cleanup **, struct cleanup *));
300
301extern void free_current_contents PARAMS ((char **));
302
303extern void null_cleanup PARAMS ((PTR));
304
305extern int myread PARAMS ((int, char *, int));
306
307extern int query PARAMS((char *, ...))
308 ATTR_FORMAT(printf, 1, 2);
309
310#if !defined (USE_MMALLOC)
311extern PTR mmalloc PARAMS ((PTR, size_t));
312extern PTR mrealloc PARAMS ((PTR, PTR, size_t));
313extern void mfree PARAMS ((PTR, PTR));
314#endif
315
392a587b
JM
316extern void init_page_info PARAMS ((void));
317
c906108c
SS
318/* From demangle.c */
319
320extern void set_demangling_style PARAMS ((char *));
321
322/* From tm.h */
323
324struct type;
325typedef int (use_struct_convention_fn) PARAMS ((int gcc_p, struct type *value_type));
326extern use_struct_convention_fn generic_use_struct_convention;
327
328typedef unsigned char *(breakpoint_from_pc_fn) PARAMS ((CORE_ADDR *pcptr, int *lenptr));
329
330
331\f
332/* Annotation stuff. */
333
334extern int annotation_level; /* in stack.c */
335\f
336extern void begin_line PARAMS ((void));
337
338extern void wrap_here PARAMS ((char *));
339
340extern void reinitialize_more_filter PARAMS ((void));
341
342/* new */
343enum streamtype
344{
345 afile,
346 astring
347};
348
349/* new */
350typedef struct tui_stream
351{
352 enum streamtype ts_streamtype;
353 FILE *ts_filestream;
354 char *ts_strbuf;
355 int ts_buflen;
356} GDB_FILE;
357
358extern GDB_FILE *gdb_stdout;
359extern GDB_FILE *gdb_stderr;
360
361#if 0
362typedef FILE GDB_FILE;
363#define gdb_stdout stdout
364#define gdb_stderr stderr
365#endif
366
367#if defined(TUI)
368#include "tui.h"
369#include "tuiCommand.h"
370#include "tuiData.h"
371#include "tuiIO.h"
372#include "tuiLayout.h"
373#include "tuiWin.h"
374#endif
375
376extern void gdb_fclose PARAMS ((GDB_FILE **));
377
378extern void gdb_flush PARAMS ((GDB_FILE *));
379
380extern GDB_FILE *gdb_fopen PARAMS ((char * name, char * mode));
381
382extern void fputs_filtered PARAMS ((const char *, GDB_FILE *));
383
384extern void fputs_unfiltered PARAMS ((const char *, GDB_FILE *));
385
386extern int fputc_filtered PARAMS ((int c, GDB_FILE *));
387
388extern int fputc_unfiltered PARAMS ((int c, GDB_FILE *));
389
390extern int putchar_unfiltered PARAMS ((int c));
391
392extern void puts_filtered PARAMS ((const char *));
393
394extern void puts_unfiltered PARAMS ((const char *));
395
396extern void puts_debug PARAMS ((char *prefix, char *string, char *suffix));
397
398extern void vprintf_filtered PARAMS ((const char *, va_list))
399 ATTR_FORMAT(printf, 1, 0);
400
401extern void vfprintf_filtered PARAMS ((GDB_FILE *, const char *, va_list))
402 ATTR_FORMAT(printf, 2, 0);
403
404extern void fprintf_filtered PARAMS ((GDB_FILE *, const char *, ...))
405 ATTR_FORMAT(printf, 2, 3);
406
407extern void fprintfi_filtered PARAMS ((int, GDB_FILE *, const char *, ...))
408 ATTR_FORMAT(printf, 3, 4);
409
410extern void printf_filtered PARAMS ((const char *, ...))
411 ATTR_FORMAT(printf, 1, 2);
412
413extern void printfi_filtered PARAMS ((int, const char *, ...))
414 ATTR_FORMAT(printf, 2, 3);
415
416extern void vprintf_unfiltered PARAMS ((const char *, va_list))
417 ATTR_FORMAT(printf, 1, 0);
418
419extern void vfprintf_unfiltered PARAMS ((GDB_FILE *, const char *, va_list))
420 ATTR_FORMAT(printf, 2, 0);
421
422extern void fprintf_unfiltered PARAMS ((GDB_FILE *, const char *, ...))
423 ATTR_FORMAT(printf, 2, 3);
424
425extern void printf_unfiltered PARAMS ((const char *, ...))
426 ATTR_FORMAT(printf, 1, 2);
427
428extern int gdb_file_isatty PARAMS ((GDB_FILE *));
429
430extern GDB_FILE *gdb_file_init_astring PARAMS ((int));
431
432extern void gdb_file_deallocate PARAMS ((GDB_FILE **));
433
434extern char *gdb_file_get_strbuf PARAMS ((GDB_FILE *));
435
436extern void gdb_file_adjust_strbuf PARAMS ((int, GDB_FILE *));
437
438extern void print_spaces PARAMS ((int, GDB_FILE *));
439
440extern void print_spaces_filtered PARAMS ((int, GDB_FILE *));
441
442extern char *n_spaces PARAMS ((int));
443
444extern void gdb_printchar PARAMS ((int, GDB_FILE *, int));
445
446extern void gdb_print_address PARAMS ((void *, GDB_FILE *));
447
448typedef bfd_vma t_addr;
449typedef bfd_vma t_reg;
450extern char* paddr PARAMS ((t_addr addr));
451
452extern char* preg PARAMS ((t_reg reg));
453
454extern char* paddr_nz PARAMS ((t_addr addr));
455
456extern char* preg_nz PARAMS ((t_reg reg));
457
458extern void fprintf_symbol_filtered PARAMS ((GDB_FILE *, char *,
459 enum language, int));
460
461extern NORETURN void perror_with_name PARAMS ((char *)) ATTR_NORETURN;
462
463extern void print_sys_errmsg PARAMS ((char *, int));
464
465/* From regex.c or libc. BSD 4.4 declares this with the argument type as
466 "const char *" in unistd.h, so we can't declare the argument
467 as "char *". */
468
469extern char *re_comp PARAMS ((const char *));
470
471/* From symfile.c */
472
473extern void symbol_file_command PARAMS ((char *, int));
474
475/* From top.c */
476
477extern char *skip_quoted PARAMS ((char *));
478
479extern char *gdb_readline PARAMS ((char *));
480
481extern char *command_line_input PARAMS ((char *, int, char *));
482
483extern void print_prompt PARAMS ((void));
484
485extern int input_from_terminal_p PARAMS ((void));
486
487extern int info_verbose;
488
489/* From printcmd.c */
490
491extern void set_next_address PARAMS ((CORE_ADDR));
492
493extern void print_address_symbolic PARAMS ((CORE_ADDR, GDB_FILE *, int,
494 char *));
495
496extern void print_address_numeric PARAMS ((CORE_ADDR, int, GDB_FILE *));
497
498extern void print_address PARAMS ((CORE_ADDR, GDB_FILE *));
499
500/* From source.c */
501
502extern int openp PARAMS ((char *, int, char *, int, int, char **));
503
504extern int source_full_path_of PARAMS ((char *, char **));
505
506extern void mod_path PARAMS ((char *, char **));
507
508extern void directory_command PARAMS ((char *, int));
509
510extern void init_source_path PARAMS ((void));
511
512extern char *symtab_to_filename PARAMS ((struct symtab *));
513
514/* From findvar.c */
515
516extern int read_relative_register_raw_bytes PARAMS ((int, char *));
517
392a587b
JM
518#if __STDC__
519enum lval_type;
520struct frame_info;
521#endif
522void default_get_saved_register PARAMS ((char *raw_buffer, int *optimized,
523 CORE_ADDR *addrp,
524 struct frame_info *frame, int regnum,
525 enum lval_type *lval));
526
c906108c
SS
527/* From readline (but not in any readline .h files). */
528
529extern char *tilde_expand PARAMS ((char *));
530
531/* Control types for commands */
532
533enum misc_command_type
534{
535 ok_command,
536 end_command,
537 else_command,
538 nop_command
539};
540
541enum command_control_type
542{
543 simple_control,
544 break_control,
545 continue_control,
546 while_control,
547 if_control,
548 invalid_control
549};
550
551/* Structure for saved commands lines
552 (for breakpoints, defined commands, etc). */
553
554struct command_line
555{
556 struct command_line *next;
557 char *line;
558 enum command_control_type control_type;
559 int body_count;
560 struct command_line **body_list;
561};
562
563extern struct command_line *read_command_lines PARAMS ((char *, int));
564
565extern void free_command_lines PARAMS ((struct command_line **));
566
567/* String containing the current directory (what getwd would return). */
568
569extern char *current_directory;
570
571/* Default radixes for input and output. Only some values supported. */
572extern unsigned input_radix;
573extern unsigned output_radix;
574
575/* Possibilities for prettyprint parameters to routines which print
576 things. Like enum language, this should be in value.h, but needs
577 to be here for the same reason. FIXME: If we can eliminate this
578 as an arg to LA_VAL_PRINT, then we can probably move it back to
579 value.h. */
580
581enum val_prettyprint
582{
583 Val_no_prettyprint = 0,
584 Val_prettyprint,
585 /* Use the default setting which the user has specified. */
586 Val_pretty_default
587};
588
589\f
590/* Host machine definition. This will be a symlink to one of the
591 xm-*.h files, built by the `configure' script. */
592
593#include "xm.h"
594
595/* Native machine support. This will be a symlink to one of the
596 nm-*.h files, built by the `configure' script. */
597
598#include "nm.h"
599
600/* Target machine definition. This will be a symlink to one of the
601 tm-*.h files, built by the `configure' script. */
602
603#include "tm.h"
604
605/* If the xm.h file did not define the mode string used to open the
606 files, assume that binary files are opened the same way as text
607 files */
608#ifndef FOPEN_RB
609#include "fopen-same.h"
610#endif
611
612/* Microsoft C can't deal with const pointers */
613
614#ifdef _MSC_VER
615#define CONST_PTR
616#else
617#define CONST_PTR const
618#endif
619
620/*
621 * Allow things in gdb to be declared "volatile". If compiling ANSI, it
622 * just works. If compiling with gcc but non-ansi, redefine to __volatile__.
623 * If non-ansi, non-gcc, then eliminate "volatile" entirely, making those
624 * objects be read-write rather than read-only.
625 */
626
627#ifndef volatile
628#ifndef __STDC__
629# ifdef __GNUC__
630# define volatile __volatile__
631# else
632# define volatile /*nothing*/
633# endif /* GNUC */
634#endif /* STDC */
635#endif /* volatile */
636
637/* Defaults for system-wide constants (if not defined by xm.h, we fake it).
638 FIXME: Assumes 2's complement arithmetic */
639
640#if !defined (UINT_MAX)
641#define UINT_MAX ((unsigned int)(~0)) /* 0xFFFFFFFF for 32-bits */
642#endif
643
644#if !defined (INT_MAX)
645#define INT_MAX ((int)(UINT_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
646#endif
647
648#if !defined (INT_MIN)
649#define INT_MIN ((int)((int) ~0 ^ INT_MAX)) /* 0x80000000 for 32-bits */
650#endif
651
652#if !defined (ULONG_MAX)
653#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */
654#endif
655
656#if !defined (LONG_MAX)
657#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
658#endif
659
660#ifndef LONGEST
661
662#ifdef BFD64
663
664/* This is to make sure that LONGEST is at least as big as CORE_ADDR. */
665
666#define LONGEST BFD_HOST_64_BIT
667#define ULONGEST BFD_HOST_U_64_BIT
668
669#else /* No BFD64 */
670
671# ifdef CC_HAS_LONG_LONG
672# define LONGEST long long
673# define ULONGEST unsigned long long
674# else
675/* BFD_HOST_64_BIT is defined for some hosts that don't have long long
676 (e.g. i386-windows) so try it. */
677# ifdef BFD_HOST_64_BIT
678# define LONGEST BFD_HOST_64_BIT
679# define ULONGEST BFD_HOST_U_64_BIT
680# else
681# define LONGEST long
682# define ULONGEST unsigned long
683# endif
684# endif
685
686#endif /* No BFD64 */
687
688#endif /* ! LONGEST */
689
690/* Convert a LONGEST to an int. This is used in contexts (e.g. number of
691 arguments to a function, number in a value history, register number, etc.)
692 where the value must not be larger than can fit in an int. */
693
694extern int longest_to_int PARAMS ((LONGEST));
695
696/* Assorted functions we can declare, now that const and volatile are
697 defined. */
698
699extern char *savestring PARAMS ((const char *, int));
700
701extern char *msavestring PARAMS ((void *, const char *, int));
702
703extern char *strsave PARAMS ((const char *));
704
705extern char *mstrsave PARAMS ((void *, const char *));
706
707#ifdef _MSC_VER /* FIXME; was long, but this causes compile errors in msvc if already defined */
708extern PTR xmmalloc PARAMS ((PTR, size_t));
709
710extern PTR xmrealloc PARAMS ((PTR, PTR, size_t));
711#else
712extern PTR xmmalloc PARAMS ((PTR, long));
713
714extern PTR xmrealloc PARAMS ((PTR, PTR, long));
715#endif
716
717extern int parse_escape PARAMS ((char **));
718
719/* compat - handle old targets that just define REGISTER_NAMES */
720#ifndef REGISTER_NAME
721extern char *gdb_register_names[];
722#define REGISTER_NAME(i) gdb_register_names[i]
723#endif
724
725/* Message to be printed before the error message, when an error occurs. */
726
727extern char *error_pre_print;
728
729/* Message to be printed before the error message, when an error occurs. */
730
731extern char *quit_pre_print;
732
733/* Message to be printed before the warning message, when a warning occurs. */
734
735extern char *warning_pre_print;
736
737extern NORETURN void error PARAMS((const char *, ...)) ATTR_NORETURN;
738
739extern void error_begin PARAMS ((void));
740
741extern NORETURN void fatal PARAMS((char *, ...)) ATTR_NORETURN;
742
743extern NORETURN void nomem PARAMS ((long)) ATTR_NORETURN;
744
745/* Reasons for calling return_to_top_level. */
746enum return_reason {
747 /* User interrupt. */
748 RETURN_QUIT,
749
750 /* Any other error. */
751 RETURN_ERROR
752};
753
754#define RETURN_MASK_QUIT (1 << (int)RETURN_QUIT)
755#define RETURN_MASK_ERROR (1 << (int)RETURN_ERROR)
756#define RETURN_MASK_ALL (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
757typedef int return_mask;
758
759extern NORETURN void
760return_to_top_level PARAMS ((enum return_reason)) ATTR_NORETURN;
761
762typedef int (catch_errors_ftype) PARAMS ((PTR));
763extern int catch_errors PARAMS ((catch_errors_ftype *, PTR, char *, return_mask));
764
765extern void warning_begin PARAMS ((void));
766
767extern void warning PARAMS ((const char *, ...))
768 ATTR_FORMAT(printf, 1, 2);
769
770/* Global functions from other, non-gdb GNU thingies.
771 Libiberty thingies are no longer declared here. We include libiberty.h
772 above, instead. */
773
774#ifndef GETENV_PROVIDED
775extern char *getenv PARAMS ((const char *));
776#endif
777
778/* From other system libraries */
779
780#ifdef HAVE_STDDEF_H
781#include <stddef.h>
782#endif
783
784#ifdef HAVE_STDLIB_H
785#if defined(_MSC_VER) && !defined(__cplusplus)
786/* msvc defines these in stdlib.h for c code */
787#undef min
788#undef max
789#endif
790#include <stdlib.h>
791#endif
792#ifndef min
793#define min(a, b) ((a) < (b) ? (a) : (b))
794#endif
795#ifndef max
796#define max(a, b) ((a) > (b) ? (a) : (b))
797#endif
798
799
800/* We take the address of fclose later, but some stdio's forget
801 to declare this. We can't always declare it since there's
802 no way to declare the parameters without upsetting some compiler
803 somewhere. */
804
805#ifndef FCLOSE_PROVIDED
806extern int fclose PARAMS ((FILE *));
807#endif
808
809#ifndef atof
810extern double atof PARAMS ((const char *)); /* X3.159-1989 4.10.1.1 */
811#endif
812
813#ifndef MALLOC_INCOMPATIBLE
814
815#ifdef NEED_DECLARATION_MALLOC
816extern PTR malloc ();
817#endif
818
819#ifdef NEED_DECLARATION_REALLOC
820extern PTR realloc ();
821#endif
822
823#ifdef NEED_DECLARATION_FREE
824extern void free ();
825#endif
826
827#endif /* MALLOC_INCOMPATIBLE */
828
829/* Various possibilities for alloca. */
830#ifndef alloca
831# ifdef __GNUC__
832# define alloca __builtin_alloca
833# else /* Not GNU C */
834# ifdef HAVE_ALLOCA_H
835# include <alloca.h>
836# else
837# ifdef _AIX
838 #pragma alloca
839# else
840
841/* We need to be careful not to declare this in a way which conflicts with
842 bison. Bison never declares it as char *, but under various circumstances
843 (like __hpux) we need to use void *. */
844# if defined (__STDC__) || defined (__hpux)
845 extern void *alloca ();
846# else /* Don't use void *. */
847 extern char *alloca ();
848# endif /* Don't use void *. */
849# endif /* Not _AIX */
850# endif /* Not HAVE_ALLOCA_H */
851# endif /* Not GNU C */
852#endif /* alloca not defined */
853
854/* HOST_BYTE_ORDER must be defined to one of these. */
855
856#ifdef HAVE_ENDIAN_H
857#include <endian.h>
858#endif
859
860#if !defined (BIG_ENDIAN)
861#define BIG_ENDIAN 4321
862#endif
863
864#if !defined (LITTLE_ENDIAN)
865#define LITTLE_ENDIAN 1234
866#endif
867
868/* Dynamic target-system-dependent parameters for GDB. */
869#include "gdbarch.h"
870
871/* Static target-system-dependent parameters for GDB. */
872
873/* Number of bits in a char or unsigned char for the target machine.
874 Just like CHAR_BIT in <limits.h> but describes the target machine. */
875#if !defined (TARGET_CHAR_BIT)
876#define TARGET_CHAR_BIT 8
877#endif
878
879/* Number of bits in a short or unsigned short for the target machine. */
880#if !defined (TARGET_SHORT_BIT)
881#define TARGET_SHORT_BIT (2 * TARGET_CHAR_BIT)
882#endif
883
884/* Number of bits in an int or unsigned int for the target machine. */
885#if !defined (TARGET_INT_BIT)
886#define TARGET_INT_BIT (4 * TARGET_CHAR_BIT)
887#endif
888
889/* Number of bits in a long or unsigned long for the target machine. */
890#if !defined (TARGET_LONG_BIT)
891#define TARGET_LONG_BIT (4 * TARGET_CHAR_BIT)
892#endif
893
894/* Number of bits in a long long or unsigned long long for the target machine. */
895#if !defined (TARGET_LONG_LONG_BIT)
896#define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT)
897#endif
898
899/* Number of bits in a float for the target machine. */
900#if !defined (TARGET_FLOAT_BIT)
901#define TARGET_FLOAT_BIT (4 * TARGET_CHAR_BIT)
902#endif
903
904/* Number of bits in a double for the target machine. */
905#if !defined (TARGET_DOUBLE_BIT)
906#define TARGET_DOUBLE_BIT (8 * TARGET_CHAR_BIT)
907#endif
908
909/* Number of bits in a long double for the target machine. */
910#if !defined (TARGET_LONG_DOUBLE_BIT)
911#define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT)
912#endif
913
914/* Number of bits in a pointer for the target machine */
915#if !defined (TARGET_PTR_BIT)
916#define TARGET_PTR_BIT TARGET_INT_BIT
917#endif
918
919/* If we picked up a copy of CHAR_BIT from a configuration file
920 (which may get it by including <limits.h>) then use it to set
921 the number of bits in a host char. If not, use the same size
922 as the target. */
923
924#if defined (CHAR_BIT)
925#define HOST_CHAR_BIT CHAR_BIT
926#else
927#define HOST_CHAR_BIT TARGET_CHAR_BIT
928#endif
929
930/* The bit byte-order has to do just with numbering of bits in
931 debugging symbols and such. Conceptually, it's quite separate
932 from byte/word byte order. */
933
934#if !defined (BITS_BIG_ENDIAN)
935#define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BIG_ENDIAN)
936#endif
937
938/* In findvar.c. */
939
940extern LONGEST extract_signed_integer PARAMS ((void *, int));
941
942extern ULONGEST extract_unsigned_integer PARAMS ((void *, int));
943
944extern int extract_long_unsigned_integer PARAMS ((void *, int, LONGEST *));
945
946extern CORE_ADDR extract_address PARAMS ((void *, int));
947
948extern void store_signed_integer PARAMS ((PTR, int, LONGEST));
949
950extern void store_unsigned_integer PARAMS ((PTR, int, ULONGEST));
951
952extern void store_address PARAMS ((PTR, int, LONGEST));
953
954/* Setup definitions for host and target floating point formats. We need to
955 consider the format for `float', `double', and `long double' for both target
956 and host. We need to do this so that we know what kind of conversions need
957 to be done when converting target numbers to and from the hosts DOUBLEST
958 data type. */
959
960/* This is used to indicate that we don't know the format of the floating point
961 number. Typically, this is useful for native ports, where the actual format
962 is irrelevant, since no conversions will be taking place. */
963
964extern const struct floatformat floatformat_unknown;
965
966#if HOST_BYTE_ORDER == BIG_ENDIAN
967# ifndef HOST_FLOAT_FORMAT
968# define HOST_FLOAT_FORMAT &floatformat_ieee_single_big
969# endif
970# ifndef HOST_DOUBLE_FORMAT
971# define HOST_DOUBLE_FORMAT &floatformat_ieee_double_big
972# endif
973#else /* LITTLE_ENDIAN */
974# ifndef HOST_FLOAT_FORMAT
975# define HOST_FLOAT_FORMAT &floatformat_ieee_single_little
976# endif
977# ifndef HOST_DOUBLE_FORMAT
978# define HOST_DOUBLE_FORMAT &floatformat_ieee_double_little
979# endif
980#endif
981
982#ifndef HOST_LONG_DOUBLE_FORMAT
983#define HOST_LONG_DOUBLE_FORMAT &floatformat_unknown
984#endif
985
986#ifndef TARGET_FLOAT_FORMAT
987#define TARGET_FLOAT_FORMAT (TARGET_BYTE_ORDER == BIG_ENDIAN \
988 ? &floatformat_ieee_single_big \
989 : &floatformat_ieee_single_little)
990#endif
991#ifndef TARGET_DOUBLE_FORMAT
992#define TARGET_DOUBLE_FORMAT (TARGET_BYTE_ORDER == BIG_ENDIAN \
993 ? &floatformat_ieee_double_big \
994 : &floatformat_ieee_double_little)
995#endif
996
997#ifndef TARGET_LONG_DOUBLE_FORMAT
998# define TARGET_LONG_DOUBLE_FORMAT &floatformat_unknown
999#endif
1000
1001/* Use `long double' if the host compiler supports it. (Note that this is not
1002 necessarily any longer than `double'. On SunOS/gcc, it's the same as
1003 double.) This is necessary because GDB internally converts all floating
1004 point values to the widest type supported by the host.
1005
1006 There are problems however, when the target `long double' is longer than the
1007 host's `long double'. In general, we'll probably reduce the precision of
1008 any such values and print a warning. */
1009
1010#ifdef HAVE_LONG_DOUBLE
1011typedef long double DOUBLEST;
1012#else
1013typedef double DOUBLEST;
1014#endif
1015
1016extern void floatformat_to_doublest PARAMS ((const struct floatformat *,
1017 char *, DOUBLEST *));
1018extern void floatformat_from_doublest PARAMS ((const struct floatformat *,
1019 DOUBLEST *, char *));
1020extern DOUBLEST extract_floating PARAMS ((void *, int));
1021
1022extern void store_floating PARAMS ((void *, int, DOUBLEST));
1023\f
1024/* On some machines there are bits in addresses which are not really
1025 part of the address, but are used by the kernel, the hardware, etc.
1026 for special purposes. ADDR_BITS_REMOVE takes out any such bits
1027 so we get a "real" address such as one would find in a symbol
1028 table. This is used only for addresses of instructions, and even then
1029 I'm not sure it's used in all contexts. It exists to deal with there
1030 being a few stray bits in the PC which would mislead us, not as some sort
1031 of generic thing to handle alignment or segmentation (it's possible it
cd0fc7c3 1032 should be in TARGET_READ_PC instead). */
c906108c
SS
1033#if !defined (ADDR_BITS_REMOVE)
1034#define ADDR_BITS_REMOVE(addr) (addr)
1035#endif /* No ADDR_BITS_REMOVE. */
1036
1037/* From valops.c */
1038
1039extern CORE_ADDR push_bytes PARAMS ((CORE_ADDR, char *, int));
1040
1041extern CORE_ADDR push_word PARAMS ((CORE_ADDR, ULONGEST));
1042
c906108c 1043extern int watchdog;
c906108c
SS
1044
1045/* Hooks for alternate command interfaces. */
1046
1047#ifdef __STDC__
1048struct target_waitstatus;
1049struct cmd_list_element;
1050#endif
1051
cd0fc7c3 1052extern void (*async_hook) PARAMS ((void));
c906108c
SS
1053extern void (*init_ui_hook) PARAMS ((char *argv0));
1054extern void (*command_loop_hook) PARAMS ((void));
1055extern void (*fputs_unfiltered_hook) PARAMS ((const char *linebuffer,
1056 GDB_FILE *stream));
1057extern void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s,
1058 int line, int stopline,
1059 int noerror));
1060extern struct frame_info *parse_frame_specification PARAMS ((char *frame_exp));
1061extern int (*query_hook) PARAMS ((const char *, va_list));
1062extern void (*warning_hook) PARAMS ((const char *, va_list));
1063extern void (*flush_hook) PARAMS ((GDB_FILE *stream));
1064extern void (*create_breakpoint_hook) PARAMS ((struct breakpoint *b));
1065extern void (*delete_breakpoint_hook) PARAMS ((struct breakpoint *bpt));
1066extern void (*modify_breakpoint_hook) PARAMS ((struct breakpoint *bpt));
1067extern void (*target_output_hook) PARAMS ((char *));
1068extern void (*interactive_hook) PARAMS ((void));
1069extern void (*registers_changed_hook) PARAMS ((void));
1070extern void (*readline_begin_hook) PARAMS ((char *, ...));
1071extern char * (*readline_hook) PARAMS ((char *));
1072extern void (*readline_end_hook) PARAMS ((void));
1073extern void (*register_changed_hook) PARAMS ((int regno));
1074extern void (*memory_changed_hook) PARAMS ((CORE_ADDR addr, int len));
1075extern void (*context_hook) PARAMS ((int));
1076extern int (*target_wait_hook) PARAMS ((int pid,
1077 struct target_waitstatus *status));
1078
1079extern void (*call_command_hook) PARAMS ((struct cmd_list_element *c,
1080 char *cmd, int from_tty));
1081
1082extern NORETURN void (*error_hook) PARAMS ((void)) ATTR_NORETURN;
1083
1084extern void (*error_begin_hook) PARAMS ((void));
1085
1086
1087/* Inhibit window interface if non-zero. */
1088
1089extern int use_windows;
1090
1091/* Symbolic definitions of filename-related things. */
1092/* FIXME, this doesn't work very well if host and executable
1093 filesystems conventions are different. */
1094
1095#ifndef DIRNAME_SEPARATOR
1096#define DIRNAME_SEPARATOR ':'
1097#endif
1098
1099#ifndef SLASH_P
1100#if defined(__GO32__)||defined(_WIN32)
1101#define SLASH_P(X) ((X)=='\\')
1102#else
1103#define SLASH_P(X) ((X)=='/')
1104#endif
1105#endif
1106
1107#ifndef SLASH_CHAR
1108#if defined(__GO32__)||defined(_WIN32)
1109#define SLASH_CHAR '\\'
1110#else
1111#define SLASH_CHAR '/'
1112#endif
1113#endif
1114
1115#ifndef SLASH_STRING
1116#if defined(__GO32__)||defined(_WIN32)
1117#define SLASH_STRING "\\"
1118#else
1119#define SLASH_STRING "/"
1120#endif
1121#endif
1122
1123#ifndef ROOTED_P
1124#define ROOTED_P(X) (SLASH_P((X)[0]))
1125#endif
1126
1127/* On some systems, PIDGET is defined to extract the inferior pid from
1128 an internal pid that has the thread id and pid in seperate bit
1129 fields. If not defined, then just use the entire internal pid as
1130 the actual pid. */
1131
1132#ifndef PIDGET
1133#define PIDGET(pid) (pid)
1134#endif
1135
1136/* If under Cygwin, provide backwards compatibility with older
1137 Cygwin compilers that don't define the current cpp define. */
1138#ifdef __CYGWIN32__
1139#ifndef __CYGWIN__
1140#define __CYGWIN__
1141#endif
1142#endif
1143
1144#endif /* #ifndef DEFS_H */
This page took 0.101593 seconds and 4 git commands to generate.