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.
6 This file is part of GDB.
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.
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.
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. */
26 #include "config.h" /* Generated by configure */
28 #include <errno.h> /* System call error return status */
34 # include <sys/types.h> /* for size_t */
37 /* Just in case they're not defined in stdio.h. */
46 /* First include ansidecl.h so we can use the various macro definitions
47 here and in all subsequent file inclusions. */
51 #ifdef ANSI_PROTOTYPES
57 #include "libiberty.h"
59 /* libiberty.h can't declare this one, but evidently we can. */
60 extern char *strsignal
PARAMS ((int));
68 /* For BFD64 and bfd_vma. */
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
77 typedef bfd_vma CORE_ADDR
;
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
));
84 #define min(a, b) ((a) < (b) ? (a) : (b))
87 #define max(a, b) ((a) > (b) ? (a) : (b))
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. */
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)
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 */
101 /* Check if a character is one of the commonly used C++ marker characters. */
102 extern int is_cplus_marker
PARAMS ((int));
104 /* use tui interface if non-zero */
105 extern int tui_version
;
108 /* all invocations of TUIDO should have two sets of parens */
109 #define TUIDO(x) tuiDo x
114 /* enable xdb commands if set */
115 extern int xdb_commands
;
117 /* enable dbx commands if set */
118 extern int dbx_commands
;
120 extern int quit_flag
;
121 extern int immediate_quit
;
122 extern int sevenbit_strings
;
124 extern void quit
PARAMS ((void));
127 /* do twice to force compiler warning */
128 #define QUIT_FIXME "FIXME"
129 #define QUIT_FIXME "ignoring redefinition of QUIT"
132 if (quit_flag) quit (); \
133 if (interactive_hook) interactive_hook (); \
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"). */
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
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. */
162 language_unknown
, /* Language not known */
163 language_auto
, /* Placeholder for automatic setting */
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 */
178 unspecified_precision
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
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. */
193 struct cleanup
*next
;
194 void (*function
) PARAMS ((PTR
));
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. */
203 /* If compiling with older versions of GCC, a function may be declared
204 "volatile" to indicate that it does not return. */
207 # if defined(__GNUC__) \
208 && (__GNUC__ == 1 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
209 # define NORETURN volatile
211 # define NORETURN /* nothing */
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. */
220 #ifndef ATTR_NORETURN
221 # if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 7
222 # define ATTR_NORETURN __attribute__ ((noreturn))
224 # define ATTR_NORETURN /* nothing */
229 # if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 4 && defined (__ANSI_PROTOTYPES)
230 # define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y)))
232 # define ATTR_FORMAT(type, x, y) /* nothing */
236 /* Needed for various prototypes */
243 /* From blockframe.c */
245 extern int inside_entry_func
PARAMS ((CORE_ADDR
));
247 extern int inside_entry_file
PARAMS ((CORE_ADDR addr
));
249 extern int inside_main_func
PARAMS ((CORE_ADDR pc
));
251 /* From ch-lang.c, for the moment. (FIXME) */
253 extern char *chill_demangle
PARAMS ((const char *));
257 extern void initialize_utils
PARAMS ((void));
259 extern void notice_quit
PARAMS ((void));
261 extern int strcmp_iw
PARAMS ((const char *, const char *));
263 extern int subset_compare
PARAMS ((char *, char *));
265 extern char *safe_strerror
PARAMS ((int));
267 extern char *safe_strsignal
PARAMS ((int));
269 extern void init_malloc
PARAMS ((void *));
271 extern void request_quit
PARAMS ((int));
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
*));
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
*));
283 typedef void (*make_cleanup_func
) PARAMS ((void *));
285 extern struct cleanup
*make_cleanup
PARAMS ((make_cleanup_func
, void *));
287 extern struct cleanup
*make_cleanup_freeargv
PARAMS ((char **));
289 extern struct cleanup
*make_final_cleanup
PARAMS ((make_cleanup_func
, void *));
291 extern struct cleanup
*make_my_cleanup
PARAMS ((struct cleanup
**,
292 make_cleanup_func
, void *));
294 extern struct cleanup
*make_run_cleanup
PARAMS ((make_cleanup_func
, void *));
296 extern struct cleanup
*make_exec_cleanup
PARAMS ((make_cleanup_func
, void *));
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
**));
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
*));
306 extern void free_current_contents
PARAMS ((char **));
308 extern void null_cleanup
PARAMS ((PTR
));
310 extern int myread
PARAMS ((int, char *, int));
312 extern int query
PARAMS((char *, ...))
313 ATTR_FORMAT(printf
, 1, 2);
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
));
321 extern void init_page_info
PARAMS ((void));
323 /* From demangle.c */
325 extern void set_demangling_style
PARAMS ((char *));
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
;
333 typedef unsigned char *(breakpoint_from_pc_fn
) PARAMS ((CORE_ADDR
*pcptr
, int *lenptr
));
337 /* Annotation stuff. */
339 extern int annotation_level
; /* in stack.c */
341 extern void begin_line
PARAMS ((void));
343 extern void wrap_here
PARAMS ((char *));
345 extern void reinitialize_more_filter
PARAMS ((void));
358 enum streamtype ts_streamtype
;
365 typedef struct gdb_file GDB_FILE
; /* deprecated */
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
;
384 #include "tuiCommand.h"
387 #include "tuiLayout.h"
391 /* Create a new gdb_file with the specified methods. */
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
));
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
));
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
));
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
));
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
));
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));
411 extern struct gdb_file
*gdb_file_new
PARAMS ((void));
413 extern void gdb_file_delete
PARAMS ((struct gdb_file
*stream
));
415 extern void gdb_file_rewind
PARAMS ((struct gdb_file
*stream
));
417 /* NOTE: copies left to right */
418 extern void gdb_file_put
PARAMS ((struct gdb_file
*src
, struct gdb_file
*dest
));
420 extern void *gdb_file_data
PARAMS ((struct gdb_file
*file
));
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 *));
428 /* deprecated - use gdb_file_delete */
429 extern void gdb_fclose
PARAMS ((GDB_FILE
**));
431 extern void gdb_flush
PARAMS ((GDB_FILE
*));
433 extern GDB_FILE
*gdb_fopen
PARAMS ((char * name
, char * mode
));
435 extern void fputs_filtered
PARAMS ((const char *, GDB_FILE
*));
437 extern void fputs_unfiltered
PARAMS ((const char *, GDB_FILE
*));
439 extern int fputc_filtered
PARAMS ((int c
, GDB_FILE
*));
441 extern int fputc_unfiltered
PARAMS ((int c
, GDB_FILE
*));
443 extern int putchar_unfiltered
PARAMS ((int c
));
445 extern void puts_filtered
PARAMS ((const char *));
447 extern void puts_unfiltered
PARAMS ((const char *));
449 extern void puts_debug
PARAMS ((char *prefix
, char *string
, char *suffix
));
451 extern void vprintf_filtered
PARAMS ((const char *, va_list))
452 ATTR_FORMAT(printf
, 1, 0);
454 extern void vfprintf_filtered
PARAMS ((GDB_FILE
*, const char *, va_list))
455 ATTR_FORMAT(printf
, 2, 0);
457 extern void fprintf_filtered
PARAMS ((GDB_FILE
*, const char *, ...))
458 ATTR_FORMAT(printf
, 2, 3);
460 extern void fprintfi_filtered
PARAMS ((int, GDB_FILE
*, const char *, ...))
461 ATTR_FORMAT(printf
, 3, 4);
463 extern void printf_filtered
PARAMS ((const char *, ...))
464 ATTR_FORMAT(printf
, 1, 2);
466 extern void printfi_filtered
PARAMS ((int, const char *, ...))
467 ATTR_FORMAT(printf
, 2, 3);
469 extern void vprintf_unfiltered
PARAMS ((const char *, va_list))
470 ATTR_FORMAT(printf
, 1, 0);
472 extern void vfprintf_unfiltered
PARAMS ((GDB_FILE
*, const char *, va_list))
473 ATTR_FORMAT(printf
, 2, 0);
475 extern void fprintf_unfiltered
PARAMS ((GDB_FILE
*, const char *, ...))
476 ATTR_FORMAT(printf
, 2, 3);
478 extern void printf_unfiltered
PARAMS ((const char *, ...))
479 ATTR_FORMAT(printf
, 1, 2);
481 extern int gdb_file_isatty
PARAMS ((GDB_FILE
*));
483 /* #if defined (TUI) */
484 extern GDB_FILE
*gdb_file_init_astring
PARAMS ((int));
487 extern void gdb_file_deallocate
PARAMS ((GDB_FILE
**));
489 /* #if defined (TUI) */
490 extern char *gdb_file_get_strbuf
PARAMS ((GDB_FILE
*));
493 /* #if defined (TUI) */
494 extern void gdb_file_adjust_strbuf
PARAMS ((int, GDB_FILE
*));
497 extern void print_spaces
PARAMS ((int, GDB_FILE
*));
499 extern void print_spaces_filtered
PARAMS ((int, GDB_FILE
*));
501 extern char *n_spaces
PARAMS ((int));
503 extern void fputstr_filtered
PARAMS ((const char *str
, int quotr
, GDB_FILE
*stream
));
505 extern void fputstr_unfiltered
PARAMS ((const char *str
, int quotr
, GDB_FILE
*stream
));
507 extern void fputstrn_unfiltered
PARAMS ((const char *str
, int n
, int quotr
, GDB_FILE
*stream
));
509 extern void gdb_print_address
PARAMS ((void *, GDB_FILE
*));
511 typedef bfd_vma t_addr
;
512 typedef bfd_vma t_reg
;
513 extern char* paddr
PARAMS ((t_addr addr
));
515 extern char* preg
PARAMS ((t_reg reg
));
517 extern char* paddr_nz
PARAMS ((t_addr addr
));
519 extern char* preg_nz
PARAMS ((t_reg reg
));
521 extern void fprintf_symbol_filtered
PARAMS ((GDB_FILE
*, char *,
522 enum language
, int));
524 extern NORETURN
void perror_with_name
PARAMS ((char *)) ATTR_NORETURN
;
526 extern void print_sys_errmsg
PARAMS ((char *, int));
528 /* From regex.c or libc. BSD 4.4 declares this with the argument type as
529 "const char *" in unistd.h, so we can't declare the argument
532 extern char *re_comp
PARAMS ((const char *));
536 extern void symbol_file_command
PARAMS ((char *, int));
540 extern char *skip_quoted
PARAMS ((char *));
542 extern char *gdb_readline
PARAMS ((char *));
544 extern char *command_line_input
PARAMS ((char *, int, char *));
546 extern void print_prompt
PARAMS ((void));
548 extern int input_from_terminal_p
PARAMS ((void));
550 extern int info_verbose
;
552 /* From printcmd.c */
554 extern void set_next_address
PARAMS ((CORE_ADDR
));
556 extern void print_address_symbolic
PARAMS ((CORE_ADDR
, GDB_FILE
*, int,
559 extern void print_address_numeric
PARAMS ((CORE_ADDR
, int, GDB_FILE
*));
561 extern void print_address
PARAMS ((CORE_ADDR
, GDB_FILE
*));
565 extern int openp
PARAMS ((char *, int, char *, int, int, char **));
567 extern int source_full_path_of
PARAMS ((char *, char **));
569 extern void mod_path
PARAMS ((char *, char **));
571 extern void directory_command
PARAMS ((char *, int));
573 extern void init_source_path
PARAMS ((void));
575 extern char *symtab_to_filename
PARAMS ((struct symtab
*));
579 extern int read_relative_register_raw_bytes
PARAMS ((int, char *));
585 void default_get_saved_register
PARAMS ((char *raw_buffer
, int *optimized
,
587 struct frame_info
*frame
, int regnum
,
588 enum lval_type
*lval
));
590 /* From readline (but not in any readline .h files). */
592 extern char *tilde_expand
PARAMS ((char *));
594 /* Control types for commands */
596 enum misc_command_type
604 enum command_control_type
614 /* Structure for saved commands lines
615 (for breakpoints, defined commands, etc). */
619 struct command_line
*next
;
621 enum command_control_type control_type
;
623 struct command_line
**body_list
;
626 extern struct command_line
*read_command_lines
PARAMS ((char *, int));
628 extern void free_command_lines
PARAMS ((struct command_line
**));
630 /* To continue the execution commands when running gdb asynchronously.
631 A continuation structure contains a pointer to a function to be called
632 to finish the command, once the target has stopped. Such mechanism is
633 used bt the finish and until commands, and in the remote protocol
634 when opening an extended-remote connection. */
636 struct continuation_arg
638 struct continuation_arg
*next
;
644 void (*continuation_hook
) PARAMS ((struct continuation_arg
*));
645 struct continuation_arg
*arg_list
;
646 struct continuation
*next
;
651 extern struct continuation
*cmd_continuation
;
654 void add_continuation
PARAMS ((void (*) PARAMS ((struct continuation_arg
*)),
655 struct continuation_arg
*));
656 void do_all_continuations
PARAMS ((void));
658 /* String containing the current directory (what getwd would return). */
660 extern char *current_directory
;
662 /* Default radixes for input and output. Only some values supported. */
663 extern unsigned input_radix
;
664 extern unsigned output_radix
;
666 /* Possibilities for prettyprint parameters to routines which print
667 things. Like enum language, this should be in value.h, but needs
668 to be here for the same reason. FIXME: If we can eliminate this
669 as an arg to LA_VAL_PRINT, then we can probably move it back to
674 Val_no_prettyprint
= 0,
676 /* Use the default setting which the user has specified. */
681 /* Host machine definition. This will be a symlink to one of the
682 xm-*.h files, built by the `configure' script. */
686 /* Native machine support. This will be a symlink to one of the
687 nm-*.h files, built by the `configure' script. */
691 /* Target machine definition. This will be a symlink to one of the
692 tm-*.h files, built by the `configure' script. */
696 /* If the xm.h file did not define the mode string used to open the
697 files, assume that binary files are opened the same way as text
700 #include "fopen-same.h"
703 /* Microsoft C can't deal with const pointers */
708 #define CONST_PTR const
712 * Allow things in gdb to be declared "volatile". If compiling ANSI, it
713 * just works. If compiling with gcc but non-ansi, redefine to __volatile__.
714 * If non-ansi, non-gcc, then eliminate "volatile" entirely, making those
715 * objects be read-write rather than read-only.
721 # define volatile __volatile__
723 # define volatile /*nothing*/
726 #endif /* volatile */
728 /* Defaults for system-wide constants (if not defined by xm.h, we fake it).
729 FIXME: Assumes 2's complement arithmetic */
731 #if !defined (UINT_MAX)
732 #define UINT_MAX ((unsigned int)(~0)) /* 0xFFFFFFFF for 32-bits */
735 #if !defined (INT_MAX)
736 #define INT_MAX ((int)(UINT_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
739 #if !defined (INT_MIN)
740 #define INT_MIN ((int)((int) ~0 ^ INT_MAX)) /* 0x80000000 for 32-bits */
743 #if !defined (ULONG_MAX)
744 #define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */
747 #if !defined (LONG_MAX)
748 #define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */
755 /* This is to make sure that LONGEST is at least as big as CORE_ADDR. */
757 #define LONGEST BFD_HOST_64_BIT
758 #define ULONGEST BFD_HOST_U_64_BIT
762 # ifdef CC_HAS_LONG_LONG
763 # define LONGEST long long
764 # define ULONGEST unsigned long long
766 /* BFD_HOST_64_BIT is defined for some hosts that don't have long long
767 (e.g. i386-windows) so try it. */
768 # ifdef BFD_HOST_64_BIT
769 # define LONGEST BFD_HOST_64_BIT
770 # define ULONGEST BFD_HOST_U_64_BIT
772 # define LONGEST long
773 # define ULONGEST unsigned long
777 #endif /* No BFD64 */
779 #endif /* ! LONGEST */
781 /* Convert a LONGEST to an int. This is used in contexts (e.g. number of
782 arguments to a function, number in a value history, register number, etc.)
783 where the value must not be larger than can fit in an int. */
785 extern int longest_to_int
PARAMS ((LONGEST
));
787 /* Assorted functions we can declare, now that const and volatile are
790 extern char *savestring
PARAMS ((const char *, int));
792 extern char *msavestring
PARAMS ((void *, const char *, int));
794 extern char *strsave
PARAMS ((const char *));
796 extern char *mstrsave
PARAMS ((void *, const char *));
798 #ifdef _MSC_VER /* FIXME; was long, but this causes compile errors in msvc if already defined */
799 extern PTR xmmalloc
PARAMS ((PTR
, size_t));
801 extern PTR xmrealloc
PARAMS ((PTR
, PTR
, size_t));
803 extern PTR xmmalloc
PARAMS ((PTR
, long));
805 extern PTR xmrealloc
PARAMS ((PTR
, PTR
, long));
808 extern int parse_escape
PARAMS ((char **));
810 /* Message to be printed before the error message, when an error occurs. */
812 extern char *error_pre_print
;
814 /* Message to be printed before the error message, when an error occurs. */
816 extern char *quit_pre_print
;
818 /* Message to be printed before the warning message, when a warning occurs. */
820 extern char *warning_pre_print
;
822 extern NORETURN
void error
PARAMS((const char *, ...)) ATTR_NORETURN
;
824 extern void error_begin
PARAMS ((void));
826 extern NORETURN
void fatal
PARAMS((char *, ...)) ATTR_NORETURN
;
828 extern NORETURN
void nomem
PARAMS ((long)) ATTR_NORETURN
;
830 /* Reasons for calling return_to_top_level. */
832 /* User interrupt. */
835 /* Any other error. */
839 #define ALL_CLEANUPS ((struct cleanup *)0)
841 #define RETURN_MASK_QUIT (1 << (int)RETURN_QUIT)
842 #define RETURN_MASK_ERROR (1 << (int)RETURN_ERROR)
843 #define RETURN_MASK_ALL (RETURN_MASK_QUIT | RETURN_MASK_ERROR)
844 typedef int return_mask
;
847 return_to_top_level
PARAMS ((enum return_reason
)) ATTR_NORETURN
;
849 typedef int (catch_errors_ftype
) PARAMS ((PTR
));
850 extern int catch_errors
PARAMS ((catch_errors_ftype
*, PTR
, char *, return_mask
));
852 extern void warning_begin
PARAMS ((void));
854 extern void warning
PARAMS ((const char *, ...))
855 ATTR_FORMAT(printf
, 1, 2);
857 /* Global functions from other, non-gdb GNU thingies.
858 Libiberty thingies are no longer declared here. We include libiberty.h
861 #ifndef GETENV_PROVIDED
862 extern char *getenv
PARAMS ((const char *));
865 /* From other system libraries */
872 #if defined(_MSC_VER) && !defined(__cplusplus)
873 /* msvc defines these in stdlib.h for c code */
880 #define min(a, b) ((a) < (b) ? (a) : (b))
883 #define max(a, b) ((a) > (b) ? (a) : (b))
887 /* We take the address of fclose later, but some stdio's forget
888 to declare this. We can't always declare it since there's
889 no way to declare the parameters without upsetting some compiler
892 #ifndef FCLOSE_PROVIDED
893 extern int fclose
PARAMS ((FILE *));
897 extern double atof
PARAMS ((const char *)); /* X3.159-1989 4.10.1.1 */
900 #ifndef MALLOC_INCOMPATIBLE
902 #ifdef NEED_DECLARATION_MALLOC
903 extern PTR
malloc ();
906 #ifdef NEED_DECLARATION_REALLOC
907 extern PTR
realloc ();
910 #ifdef NEED_DECLARATION_FREE
914 #endif /* MALLOC_INCOMPATIBLE */
916 /* Various possibilities for alloca. */
919 # define alloca __builtin_alloca
920 # else /* Not GNU C */
921 # ifdef HAVE_ALLOCA_H
928 /* We need to be careful not to declare this in a way which conflicts with
929 bison. Bison never declares it as char *, but under various circumstances
930 (like __hpux) we need to use void *. */
931 # if defined (__STDC__) || defined (__hpux)
932 extern void *alloca ();
933 # else /* Don't use void *. */
934 extern char *alloca ();
935 # endif /* Don't use void *. */
936 # endif /* Not _AIX */
937 # endif /* Not HAVE_ALLOCA_H */
938 # endif /* Not GNU C */
939 #endif /* alloca not defined */
941 /* HOST_BYTE_ORDER must be defined to one of these. */
947 #if !defined (BIG_ENDIAN)
948 #define BIG_ENDIAN 4321
951 #if !defined (LITTLE_ENDIAN)
952 #define LITTLE_ENDIAN 1234
955 /* Dynamic target-system-dependent parameters for GDB. */
958 /* Static target-system-dependent parameters for GDB. */
960 /* Number of bits in a char or unsigned char for the target machine.
961 Just like CHAR_BIT in <limits.h> but describes the target machine. */
962 #if !defined (TARGET_CHAR_BIT)
963 #define TARGET_CHAR_BIT 8
966 /* Number of bits in a short or unsigned short for the target machine. */
967 #if !defined (TARGET_SHORT_BIT)
968 #define TARGET_SHORT_BIT (2 * TARGET_CHAR_BIT)
971 /* Number of bits in an int or unsigned int for the target machine. */
972 #if !defined (TARGET_INT_BIT)
973 #define TARGET_INT_BIT (4 * TARGET_CHAR_BIT)
976 /* Number of bits in a long or unsigned long for the target machine. */
977 #if !defined (TARGET_LONG_BIT)
978 #define TARGET_LONG_BIT (4 * TARGET_CHAR_BIT)
981 /* Number of bits in a long long or unsigned long long for the target machine. */
982 #if !defined (TARGET_LONG_LONG_BIT)
983 #define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT)
986 /* Number of bits in a float for the target machine. */
987 #if !defined (TARGET_FLOAT_BIT)
988 #define TARGET_FLOAT_BIT (4 * TARGET_CHAR_BIT)
991 /* Number of bits in a double for the target machine. */
992 #if !defined (TARGET_DOUBLE_BIT)
993 #define TARGET_DOUBLE_BIT (8 * TARGET_CHAR_BIT)
996 /* Number of bits in a long double for the target machine. */
997 #if !defined (TARGET_LONG_DOUBLE_BIT)
998 #define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT)
1001 /* Number of bits in a pointer for the target machine */
1002 #if !defined (TARGET_PTR_BIT)
1003 #define TARGET_PTR_BIT TARGET_INT_BIT
1006 /* If we picked up a copy of CHAR_BIT from a configuration file
1007 (which may get it by including <limits.h>) then use it to set
1008 the number of bits in a host char. If not, use the same size
1011 #if defined (CHAR_BIT)
1012 #define HOST_CHAR_BIT CHAR_BIT
1014 #define HOST_CHAR_BIT TARGET_CHAR_BIT
1017 /* The bit byte-order has to do just with numbering of bits in
1018 debugging symbols and such. Conceptually, it's quite separate
1019 from byte/word byte order. */
1021 #if !defined (BITS_BIG_ENDIAN)
1022 #define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BIG_ENDIAN)
1027 extern LONGEST extract_signed_integer
PARAMS ((void *, int));
1029 extern ULONGEST extract_unsigned_integer
PARAMS ((void *, int));
1031 extern int extract_long_unsigned_integer
PARAMS ((void *, int, LONGEST
*));
1033 extern CORE_ADDR extract_address
PARAMS ((void *, int));
1035 extern void store_signed_integer
PARAMS ((PTR
, int, LONGEST
));
1037 extern void store_unsigned_integer
PARAMS ((PTR
, int, ULONGEST
));
1039 extern void store_address
PARAMS ((PTR
, int, LONGEST
));
1041 /* Setup definitions for host and target floating point formats. We need to
1042 consider the format for `float', `double', and `long double' for both target
1043 and host. We need to do this so that we know what kind of conversions need
1044 to be done when converting target numbers to and from the hosts DOUBLEST
1047 /* This is used to indicate that we don't know the format of the floating point
1048 number. Typically, this is useful for native ports, where the actual format
1049 is irrelevant, since no conversions will be taking place. */
1051 extern const struct floatformat floatformat_unknown
;
1053 #if HOST_BYTE_ORDER == BIG_ENDIAN
1054 # ifndef HOST_FLOAT_FORMAT
1055 # define HOST_FLOAT_FORMAT &floatformat_ieee_single_big
1057 # ifndef HOST_DOUBLE_FORMAT
1058 # define HOST_DOUBLE_FORMAT &floatformat_ieee_double_big
1060 #else /* LITTLE_ENDIAN */
1061 # ifndef HOST_FLOAT_FORMAT
1062 # define HOST_FLOAT_FORMAT &floatformat_ieee_single_little
1064 # ifndef HOST_DOUBLE_FORMAT
1065 # define HOST_DOUBLE_FORMAT &floatformat_ieee_double_little
1069 #ifndef HOST_LONG_DOUBLE_FORMAT
1070 #define HOST_LONG_DOUBLE_FORMAT &floatformat_unknown
1073 #ifndef TARGET_FLOAT_FORMAT
1074 #define TARGET_FLOAT_FORMAT (TARGET_BYTE_ORDER == BIG_ENDIAN \
1075 ? &floatformat_ieee_single_big \
1076 : &floatformat_ieee_single_little)
1078 #ifndef TARGET_DOUBLE_FORMAT
1079 #define TARGET_DOUBLE_FORMAT (TARGET_BYTE_ORDER == BIG_ENDIAN \
1080 ? &floatformat_ieee_double_big \
1081 : &floatformat_ieee_double_little)
1084 #ifndef TARGET_LONG_DOUBLE_FORMAT
1085 # define TARGET_LONG_DOUBLE_FORMAT &floatformat_unknown
1088 /* Use `long double' if the host compiler supports it. (Note that this is not
1089 necessarily any longer than `double'. On SunOS/gcc, it's the same as
1090 double.) This is necessary because GDB internally converts all floating
1091 point values to the widest type supported by the host.
1093 There are problems however, when the target `long double' is longer than the
1094 host's `long double'. In general, we'll probably reduce the precision of
1095 any such values and print a warning. */
1097 #ifdef HAVE_LONG_DOUBLE
1098 typedef long double DOUBLEST
;
1100 typedef double DOUBLEST
;
1103 extern void floatformat_to_doublest
PARAMS ((const struct floatformat
*,
1104 char *, DOUBLEST
*));
1105 extern void floatformat_from_doublest
PARAMS ((const struct floatformat
*,
1106 DOUBLEST
*, char *));
1107 extern DOUBLEST extract_floating
PARAMS ((void *, int));
1109 extern void store_floating
PARAMS ((void *, int, DOUBLEST
));
1111 /* On some machines there are bits in addresses which are not really
1112 part of the address, but are used by the kernel, the hardware, etc.
1113 for special purposes. ADDR_BITS_REMOVE takes out any such bits
1114 so we get a "real" address such as one would find in a symbol
1115 table. This is used only for addresses of instructions, and even then
1116 I'm not sure it's used in all contexts. It exists to deal with there
1117 being a few stray bits in the PC which would mislead us, not as some sort
1118 of generic thing to handle alignment or segmentation (it's possible it
1119 should be in TARGET_READ_PC instead). */
1120 #if !defined (ADDR_BITS_REMOVE)
1121 #define ADDR_BITS_REMOVE(addr) (addr)
1122 #endif /* No ADDR_BITS_REMOVE. */
1126 extern CORE_ADDR push_bytes
PARAMS ((CORE_ADDR
, char *, int));
1128 extern CORE_ADDR push_word
PARAMS ((CORE_ADDR
, ULONGEST
));
1130 extern int watchdog
;
1132 /* Hooks for alternate command interfaces. */
1134 struct target_waitstatus
;
1135 struct cmd_list_element
;
1138 /* Should the asynchronous variant of the interpreter (using the
1139 event-loop) be enabled? */
1142 extern void (*init_ui_hook
) PARAMS ((char *argv0
));
1143 extern void (*command_loop_hook
) PARAMS ((void));
1144 extern void (*fputs_unfiltered_hook
) PARAMS ((const char *linebuffer
,
1146 extern void (*print_frame_info_listing_hook
) PARAMS ((struct symtab
*s
,
1147 int line
, int stopline
,
1149 extern struct frame_info
*parse_frame_specification
PARAMS ((char *frame_exp
));
1150 extern int (*query_hook
) PARAMS ((const char *, va_list));
1151 extern void (*warning_hook
) PARAMS ((const char *, va_list));
1152 extern void (*flush_hook
) PARAMS ((GDB_FILE
*stream
));
1153 extern void (*create_breakpoint_hook
) PARAMS ((struct breakpoint
*b
));
1154 extern void (*delete_breakpoint_hook
) PARAMS ((struct breakpoint
*bpt
));
1155 extern void (*modify_breakpoint_hook
) PARAMS ((struct breakpoint
*bpt
));
1156 extern void (*interactive_hook
) PARAMS ((void));
1157 extern void (*registers_changed_hook
) PARAMS ((void));
1158 extern void (*readline_begin_hook
) PARAMS ((char *, ...));
1159 extern char * (*readline_hook
) PARAMS ((char *));
1160 extern void (*readline_end_hook
) PARAMS ((void));
1161 extern void (*register_changed_hook
) PARAMS ((int regno
));
1162 extern void (*memory_changed_hook
) PARAMS ((CORE_ADDR addr
, int len
));
1163 extern void (*context_hook
) PARAMS ((int));
1164 extern int (*target_wait_hook
) PARAMS ((int pid
,
1165 struct target_waitstatus
*status
));
1167 extern void (*call_command_hook
) PARAMS ((struct cmd_list_element
*c
,
1168 char *cmd
, int from_tty
));
1170 extern NORETURN
void (*error_hook
) PARAMS ((void)) ATTR_NORETURN
;
1172 extern void (*error_begin_hook
) PARAMS ((void));
1175 /* Inhibit window interface if non-zero. */
1177 extern int use_windows
;
1179 /* Symbolic definitions of filename-related things. */
1180 /* FIXME, this doesn't work very well if host and executable
1181 filesystems conventions are different. */
1183 #ifndef DIRNAME_SEPARATOR
1184 #define DIRNAME_SEPARATOR ':'
1188 #if defined(__GO32__)||defined(_WIN32)
1189 #define SLASH_P(X) ((X)=='\\')
1191 #define SLASH_P(X) ((X)=='/')
1196 #if defined(__GO32__)||defined(_WIN32)
1197 #define SLASH_CHAR '\\'
1199 #define SLASH_CHAR '/'
1203 #ifndef SLASH_STRING
1204 #if defined(__GO32__)||defined(_WIN32)
1205 #define SLASH_STRING "\\"
1207 #define SLASH_STRING "/"
1212 #define ROOTED_P(X) (SLASH_P((X)[0]))
1215 /* On some systems, PIDGET is defined to extract the inferior pid from
1216 an internal pid that has the thread id and pid in seperate bit
1217 fields. If not defined, then just use the entire internal pid as
1221 #define PIDGET(pid) (pid)
1224 /* If under Cygwin, provide backwards compatibility with older
1225 Cygwin compilers that don't define the current cpp define. */
1232 #endif /* #ifndef DEFS_H */