defs.h revision 19370
119370Spst/* Basic, host-specific, and target-specific definitions for GDB. 219370Spst Copyright (C) 1986, 1989, 1991, 1992, 1993, 1994, 1995, 1996 319370Spst Free Software Foundation, Inc. 419370Spst 519370SpstThis file is part of GDB. 619370Spst 719370SpstThis program is free software; you can redistribute it and/or modify 819370Spstit under the terms of the GNU General Public License as published by 919370Spstthe Free Software Foundation; either version 2 of the License, or 1019370Spst(at your option) any later version. 1119370Spst 1219370SpstThis program is distributed in the hope that it will be useful, 1319370Spstbut WITHOUT ANY WARRANTY; without even the implied warranty of 1419370SpstMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1519370SpstGNU General Public License for more details. 1619370Spst 1719370SpstYou should have received a copy of the GNU General Public License 1819370Spstalong with this program; if not, write to the Free Software 1919370SpstFoundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 2019370Spst 2119370Spst#ifndef DEFS_H 2219370Spst#define DEFS_H 2319370Spst 2419370Spst#include "config.h" /* Generated by configure */ 2519370Spst#include <stdio.h> 2619370Spst#include <errno.h> /* System call error return status */ 2719370Spst 2819370Spst/* Just in case they're not defined in stdio.h. */ 2919370Spst 3019370Spst#ifndef SEEK_SET 3119370Spst#define SEEK_SET 0 3219370Spst#endif 3319370Spst#ifndef SEEK_CUR 3419370Spst#define SEEK_CUR 1 3519370Spst#endif 3619370Spst 3719370Spst/* First include ansidecl.h so we can use the various macro definitions 3819370Spst here and in all subsequent file inclusions. */ 3919370Spst 4019370Spst#include "ansidecl.h" 4119370Spst 4219370Spst#ifdef ANSI_PROTOTYPES 4319370Spst#include <stdarg.h> 4419370Spst#else 4519370Spst#include <varargs.h> 4619370Spst#endif 4719370Spst 4819370Spst#include "libiberty.h" 4919370Spst 5019370Spst/* libiberty.h can't declare this one, but evidently we can. */ 5119370Spstextern char *strsignal PARAMS ((int)); 5219370Spst 5319370Spst#include "progress.h" 5419370Spst 5519370Spst#ifndef NO_MMALLOC 5619370Spst#include "mmalloc.h" 5719370Spst#endif 5819370Spst 5919370Spst/* For BFD64 and bfd_vma. */ 6019370Spst#include "bfd.h" 6119370Spst 6219370Spst/* An address in the program being debugged. Host byte order. Rather 6319370Spst than duplicate all the logic in BFD which figures out what type 6419370Spst this is (long, long long, etc.) and whether it needs to be 64 6519370Spst bits (the host/target interactions are subtle), we just use 6619370Spst bfd_vma. */ 6719370Spst 6819370Spsttypedef bfd_vma CORE_ADDR; 6919370Spst 7019370Spst#define min(a, b) ((a) < (b) ? (a) : (b)) 7119370Spst#define max(a, b) ((a) > (b) ? (a) : (b)) 7219370Spst 7319370Spst/* Gdb does *lots* of string compares. Use macros to speed them up by 7419370Spst avoiding function calls if the first characters are not the same. */ 7519370Spst 7619370Spst#define STRCMP(a,b) (*(a) == *(b) ? strcmp ((a), (b)) : (int)*(a) - (int)*(b)) 7719370Spst#define STREQ(a,b) (*(a) == *(b) ? !strcmp ((a), (b)) : 0) 7819370Spst#define STREQN(a,b,c) (*(a) == *(b) ? !strncmp ((a), (b), (c)) : 0) 7919370Spst 8019370Spst/* The character GNU C++ uses to build identifiers that must be unique from 8119370Spst the program's identifiers (such as $this and $$vptr). */ 8219370Spst#define CPLUS_MARKER '$' /* May be overridden to '.' for SysV */ 8319370Spst 8419370Spst/* Check if a character is one of the commonly used C++ marker characters. */ 8519370Spstextern int is_cplus_marker PARAMS ((int)); 8619370Spst 8719370Spstextern int quit_flag; 8819370Spstextern int immediate_quit; 8919370Spstextern int sevenbit_strings; 9019370Spst 9119370Spstextern void quit PARAMS ((void)); 9219370Spst 9319370Spst#define QUIT { \ 9419370Spst if (quit_flag) quit (); \ 9519370Spst if (interactive_hook) interactive_hook (); \ 9619370Spst PROGRESS (1); \ 9719370Spst} 9819370Spst 9919370Spst/* Command classes are top-level categories into which commands are broken 10019370Spst down for "help" purposes. 10119370Spst Notes on classes: class_alias is for alias commands which are not 10219370Spst abbreviations of the original command. class-pseudo is for commands 10319370Spst which are not really commands nor help topics ("stop"). */ 10419370Spst 10519370Spstenum command_class 10619370Spst{ 10719370Spst /* Special args to help_list */ 10819370Spst all_classes = -2, all_commands = -1, 10919370Spst /* Classes of commands */ 11019370Spst no_class = -1, class_run = 0, class_vars, class_stack, 11119370Spst class_files, class_support, class_info, class_breakpoint, 11219370Spst class_alias, class_obscure, class_user, class_maintenance, 11319370Spst class_pseudo 11419370Spst}; 11519370Spst 11619370Spst/* Languages represented in the symbol table and elsewhere. 11719370Spst This should probably be in language.h, but since enum's can't 11819370Spst be forward declared to satisfy opaque references before their 11919370Spst actual definition, needs to be here. */ 12019370Spst 12119370Spstenum language 12219370Spst{ 12319370Spst language_unknown, /* Language not known */ 12419370Spst language_auto, /* Placeholder for automatic setting */ 12519370Spst language_c, /* C */ 12619370Spst language_cplus, /* C++ */ 12719370Spst language_chill, /* Chill */ 12819370Spst language_fortran, /* Fortran */ 12919370Spst language_m2, /* Modula-2 */ 13019370Spst language_asm, /* Assembly language */ 13119370Spst language_scm /* Scheme / Guile */ 13219370Spst}; 13319370Spst 13419370Spst/* the cleanup list records things that have to be undone 13519370Spst if an error happens (descriptors to be closed, memory to be freed, etc.) 13619370Spst Each link in the chain records a function to call and an 13719370Spst argument to give it. 13819370Spst 13919370Spst Use make_cleanup to add an element to the cleanup chain. 14019370Spst Use do_cleanups to do all cleanup actions back to a given 14119370Spst point in the chain. Use discard_cleanups to remove cleanups 14219370Spst from the chain back to a given point, not doing them. */ 14319370Spst 14419370Spststruct cleanup 14519370Spst{ 14619370Spst struct cleanup *next; 14719370Spst void (*function) PARAMS ((PTR)); 14819370Spst PTR arg; 14919370Spst}; 15019370Spst 15119370Spst 15219370Spst/* The ability to declare that a function never returns is useful, but 15319370Spst not really required to compile GDB successfully, so the NORETURN and 15419370Spst ATTR_NORETURN macros normally expand into nothing. */ 15519370Spst 15619370Spst/* If compiling with older versions of GCC, a function may be declared 15719370Spst "volatile" to indicate that it does not return. */ 15819370Spst 15919370Spst#ifndef NORETURN 16019370Spst# if defined(__GNUC__) \ 16119370Spst && (__GNUC__ == 1 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)) 16219370Spst# define NORETURN volatile 16319370Spst# else 16419370Spst# define NORETURN /* nothing */ 16519370Spst# endif 16619370Spst#endif 16719370Spst 16819370Spst/* GCC 2.5 and later versions define a function attribute "noreturn", 16919370Spst which is the preferred way to declare that a function never returns. 17019370Spst However GCC 2.7 appears to be the first version in which this fully 17119370Spst works everywhere we use it. */ 17219370Spst 17319370Spst#ifndef ATTR_NORETURN 17419370Spst# if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 7 17519370Spst# define ATTR_NORETURN __attribute__ ((noreturn)) 17619370Spst# else 17719370Spst# define ATTR_NORETURN /* nothing */ 17819370Spst# endif 17919370Spst#endif 18019370Spst 18119370Spst#ifndef ATTR_FORMAT 18219370Spst# if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 4 && defined (__ANSI_PROTOTYPES) 18319370Spst# define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y))) 18419370Spst# else 18519370Spst# define ATTR_FORMAT(type, x, y) /* nothing */ 18619370Spst# endif 18719370Spst#endif 18819370Spst 18919370Spst/* Needed for various prototypes */ 19019370Spst 19119370Spst#ifdef __STDC__ 19219370Spststruct symtab; 19319370Spststruct breakpoint; 19419370Spst#endif 19519370Spst 19619370Spst/* From blockframe.c */ 19719370Spst 19819370Spstextern int inside_entry_func PARAMS ((CORE_ADDR)); 19919370Spst 20019370Spstextern int inside_entry_file PARAMS ((CORE_ADDR addr)); 20119370Spst 20219370Spstextern int inside_main_func PARAMS ((CORE_ADDR pc)); 20319370Spst 20419370Spst/* From ch-lang.c, for the moment. (FIXME) */ 20519370Spst 20619370Spstextern char *chill_demangle PARAMS ((const char *)); 20719370Spst 20819370Spst/* From utils.c */ 20919370Spst 21019370Spstextern int strcmp_iw PARAMS ((const char *, const char *)); 21119370Spst 21219370Spstextern char *safe_strerror PARAMS ((int)); 21319370Spst 21419370Spstextern char *safe_strsignal PARAMS ((int)); 21519370Spst 21619370Spstextern void init_malloc PARAMS ((void *)); 21719370Spst 21819370Spstextern void request_quit PARAMS ((int)); 21919370Spst 22019370Spstextern void do_cleanups PARAMS ((struct cleanup *)); 22119370Spst 22219370Spstextern void discard_cleanups PARAMS ((struct cleanup *)); 22319370Spst 22419370Spst/* The bare make_cleanup function is one of those rare beasts that 22519370Spst takes almost any type of function as the first arg and anything that 22619370Spst will fit in a "void *" as the second arg. 22719370Spst 22819370Spst Should be, once all calls and called-functions are cleaned up: 22919370Spstextern struct cleanup * 23019370Spstmake_cleanup PARAMS ((void (*function) (void *), void *)); 23119370Spst 23219370Spst Until then, lint and/or various type-checking compiler options will 23319370Spst complain about make_cleanup calls. It'd be wrong to just cast things, 23419370Spst since the type actually passed when the function is called would be 23519370Spst wrong. */ 23619370Spst 23719370Spstextern struct cleanup *make_cleanup (); 23819370Spst 23919370Spstextern struct cleanup *save_cleanups PARAMS ((void)); 24019370Spst 24119370Spstextern void restore_cleanups PARAMS ((struct cleanup *)); 24219370Spst 24319370Spstextern void free_current_contents PARAMS ((char **)); 24419370Spst 24519370Spstextern void null_cleanup PARAMS ((char **)); 24619370Spst 24719370Spstextern int myread PARAMS ((int, char *, int)); 24819370Spst 24919370Spstextern int query PARAMS((char *, ...)) 25019370Spst ATTR_FORMAT(printf, 1, 2); 25119370Spst 25219370Spst/* Annotation stuff. */ 25319370Spst 25419370Spstextern int annotation_level; /* in stack.c */ 25519370Spst 25619370Spstextern void begin_line PARAMS ((void)); 25719370Spst 25819370Spstextern void wrap_here PARAMS ((char *)); 25919370Spst 26019370Spstextern void reinitialize_more_filter PARAMS ((void)); 26119370Spst 26219370Spsttypedef FILE GDB_FILE; 26319370Spst#define gdb_stdout stdout 26419370Spst#define gdb_stderr stderr 26519370Spst 26619370Spstextern void gdb_flush PARAMS ((GDB_FILE *)); 26719370Spst 26819370Spstextern GDB_FILE *gdb_fopen PARAMS ((char * name, char * mode)); 26919370Spst 27019370Spstextern void fputs_filtered PARAMS ((const char *, GDB_FILE *)); 27119370Spst 27219370Spstextern void fputs_unfiltered PARAMS ((const char *, GDB_FILE *)); 27319370Spst 27419370Spstextern int fputc_unfiltered PARAMS ((int c, GDB_FILE *)); 27519370Spst 27619370Spstextern int putchar_unfiltered PARAMS ((int c)); 27719370Spst 27819370Spstextern void puts_filtered PARAMS ((const char *)); 27919370Spst 28019370Spstextern void puts_unfiltered PARAMS ((const char *)); 28119370Spst 28219370Spstextern void vprintf_filtered PARAMS ((const char *, va_list)) 28319370Spst ATTR_FORMAT(printf, 1, 0); 28419370Spst 28519370Spstextern void vfprintf_filtered PARAMS ((FILE *, const char *, va_list)) 28619370Spst ATTR_FORMAT(printf, 2, 0); 28719370Spst 28819370Spstextern void fprintf_filtered PARAMS ((FILE *, const char *, ...)) 28919370Spst ATTR_FORMAT(printf, 2, 3); 29019370Spst 29119370Spstextern void fprintfi_filtered PARAMS ((int, FILE *, const char *, ...)) 29219370Spst ATTR_FORMAT(printf, 3, 4); 29319370Spst 29419370Spstextern void printf_filtered PARAMS ((const char *, ...)) 29519370Spst ATTR_FORMAT(printf, 1, 2); 29619370Spst 29719370Spstextern void printfi_filtered PARAMS ((int, const char *, ...)) 29819370Spst ATTR_FORMAT(printf, 2, 3); 29919370Spst 30019370Spstextern void vprintf_unfiltered PARAMS ((const char *, va_list)) 30119370Spst ATTR_FORMAT(printf, 1, 0); 30219370Spst 30319370Spstextern void vfprintf_unfiltered PARAMS ((FILE *, const char *, va_list)) 30419370Spst ATTR_FORMAT(printf, 2, 0); 30519370Spst 30619370Spstextern void fprintf_unfiltered PARAMS ((FILE *, const char *, ...)) 30719370Spst ATTR_FORMAT(printf, 2, 3); 30819370Spst 30919370Spstextern void printf_unfiltered PARAMS ((const char *, ...)) 31019370Spst ATTR_FORMAT(printf, 1, 2); 31119370Spst 31219370Spstextern void print_spaces PARAMS ((int, GDB_FILE *)); 31319370Spst 31419370Spstextern void print_spaces_filtered PARAMS ((int, GDB_FILE *)); 31519370Spst 31619370Spstextern char *n_spaces PARAMS ((int)); 31719370Spst 31819370Spstextern void gdb_printchar PARAMS ((int, GDB_FILE *, int)); 31919370Spst 32019370Spstextern void gdb_print_address PARAMS ((void *, GDB_FILE *)); 32119370Spst 32219370Spstextern void fprintf_symbol_filtered PARAMS ((GDB_FILE *, char *, 32319370Spst enum language, int)); 32419370Spst 32519370Spstextern void perror_with_name PARAMS ((char *)); 32619370Spst 32719370Spstextern void print_sys_errmsg PARAMS ((char *, int)); 32819370Spst 32919370Spst/* From regex.c or libc. BSD 4.4 declares this with the argument type as 33019370Spst "const char *" in unistd.h, so we can't declare the argument 33119370Spst as "char *". */ 33219370Spst 33319370Spstextern char *re_comp PARAMS ((const char *)); 33419370Spst 33519370Spst/* From symfile.c */ 33619370Spst 33719370Spstextern void symbol_file_command PARAMS ((char *, int)); 33819370Spst 33919370Spst/* From top.c */ 34019370Spst 34119370Spstextern char *skip_quoted PARAMS ((char *)); 34219370Spst 34319370Spstextern char *gdb_readline PARAMS ((char *)); 34419370Spst 34519370Spstextern char *command_line_input PARAMS ((char *, int, char *)); 34619370Spst 34719370Spstextern void print_prompt PARAMS ((void)); 34819370Spst 34919370Spstextern int input_from_terminal_p PARAMS ((void)); 35019370Spst 35119370Spstextern int info_verbose; 35219370Spst 35319370Spst/* From printcmd.c */ 35419370Spst 35519370Spstextern void set_next_address PARAMS ((CORE_ADDR)); 35619370Spst 35719370Spstextern void print_address_symbolic PARAMS ((CORE_ADDR, GDB_FILE *, int, 35819370Spst char *)); 35919370Spst 36019370Spstextern void print_address_numeric PARAMS ((CORE_ADDR, int, GDB_FILE *)); 36119370Spst 36219370Spstextern void print_address PARAMS ((CORE_ADDR, GDB_FILE *)); 36319370Spst 36419370Spst/* From source.c */ 36519370Spst 36619370Spstextern int openp PARAMS ((char *, int, char *, int, int, char **)); 36719370Spst 36819370Spstextern void mod_path PARAMS ((char *, char **)); 36919370Spst 37019370Spstextern void directory_command PARAMS ((char *, int)); 37119370Spst 37219370Spstextern void init_source_path PARAMS ((void)); 37319370Spst 37419370Spstextern char *symtab_to_filename PARAMS ((struct symtab *)); 37519370Spst 37619370Spst/* From findvar.c */ 37719370Spst 37819370Spstextern int read_relative_register_raw_bytes PARAMS ((int, char *)); 37919370Spst 38019370Spst/* From readline (but not in any readline .h files). */ 38119370Spst 38219370Spstextern char *tilde_expand PARAMS ((char *)); 38319370Spst 38419370Spst/* Control types for commands */ 38519370Spst 38619370Spstenum misc_command_type 38719370Spst{ 38819370Spst ok_command, 38919370Spst end_command, 39019370Spst else_command, 39119370Spst nop_command 39219370Spst}; 39319370Spst 39419370Spstenum command_control_type 39519370Spst{ 39619370Spst simple_control, 39719370Spst break_control, 39819370Spst continue_control, 39919370Spst while_control, 40019370Spst if_control, 40119370Spst invalid_control 40219370Spst}; 40319370Spst 40419370Spst/* Structure for saved commands lines 40519370Spst (for breakpoints, defined commands, etc). */ 40619370Spst 40719370Spststruct command_line 40819370Spst{ 40919370Spst struct command_line *next; 41019370Spst char *line; 41119370Spst enum command_control_type control_type; 41219370Spst int body_count; 41319370Spst struct command_line **body_list; 41419370Spst}; 41519370Spst 41619370Spstextern struct command_line *read_command_lines PARAMS ((void)); 41719370Spst 41819370Spstextern void free_command_lines PARAMS ((struct command_line **)); 41919370Spst 42019370Spst/* String containing the current directory (what getwd would return). */ 42119370Spst 42219370Spstextern char *current_directory; 42319370Spst 42419370Spst/* Default radixes for input and output. Only some values supported. */ 42519370Spstextern unsigned input_radix; 42619370Spstextern unsigned output_radix; 42719370Spst 42819370Spst/* Possibilities for prettyprint parameters to routines which print 42919370Spst things. Like enum language, this should be in value.h, but needs 43019370Spst to be here for the same reason. FIXME: If we can eliminate this 43119370Spst as an arg to LA_VAL_PRINT, then we can probably move it back to 43219370Spst value.h. */ 43319370Spst 43419370Spstenum val_prettyprint 43519370Spst{ 43619370Spst Val_no_prettyprint = 0, 43719370Spst Val_prettyprint, 43819370Spst /* Use the default setting which the user has specified. */ 43919370Spst Val_pretty_default 44019370Spst}; 44119370Spst 44219370Spst 44319370Spst/* Host machine definition. This will be a symlink to one of the 44419370Spst xm-*.h files, built by the `configure' script. */ 44519370Spst 44619370Spst#include "xm.h" 44719370Spst 44819370Spst/* Native machine support. This will be a symlink to one of the 44919370Spst nm-*.h files, built by the `configure' script. */ 45019370Spst 45119370Spst#include "nm.h" 45219370Spst 45319370Spst/* Target machine definition. This will be a symlink to one of the 45419370Spst tm-*.h files, built by the `configure' script. */ 45519370Spst 45619370Spst#include "tm.h" 45719370Spst 45819370Spst/* If the xm.h file did not define the mode string used to open the 45919370Spst files, assume that binary files are opened the same way as text 46019370Spst files */ 46119370Spst#ifndef FOPEN_RB 46219370Spst#include "fopen-same.h" 46319370Spst#endif 46419370Spst 46519370Spst/* 46619370Spst * Allow things in gdb to be declared "const". If compiling ANSI, it 46719370Spst * just works. If compiling with gcc but non-ansi, redefine to __const__. 46819370Spst * If non-ansi, non-gcc, then eliminate "const" entirely, making those 46919370Spst * objects be read-write rather than read-only. 47019370Spst */ 47119370Spst 47219370Spst#ifndef const 47319370Spst#ifndef __STDC__ 47419370Spst# ifdef __GNUC__ 47519370Spst# define const __const__ 47619370Spst# else 47719370Spst# define const /*nothing*/ 47819370Spst# endif /* GNUC */ 47919370Spst#endif /* STDC */ 48019370Spst#endif /* const */ 48119370Spst 48219370Spst#ifndef volatile 48319370Spst#ifndef __STDC__ 48419370Spst# ifdef __GNUC__ 48519370Spst# define volatile __volatile__ 48619370Spst# else 48719370Spst# define volatile /*nothing*/ 48819370Spst# endif /* GNUC */ 48919370Spst#endif /* STDC */ 49019370Spst#endif /* volatile */ 49119370Spst 49219370Spst/* Defaults for system-wide constants (if not defined by xm.h, we fake it). */ 49319370Spst 49419370Spst#if !defined (UINT_MAX) 49519370Spst#define UINT_MAX ((unsigned int)(~0)) /* 0xFFFFFFFF for 32-bits */ 49619370Spst#endif 49719370Spst 49819370Spst#if !defined (INT_MAX) 49919370Spst#define INT_MAX ((int)(UINT_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */ 50019370Spst#endif 50119370Spst 50219370Spst#if !defined (INT_MIN) 50319370Spst#define INT_MIN (-INT_MAX - 1) /* 0x80000000 for 32-bits */ 50419370Spst#endif 50519370Spst 50619370Spst#if !defined (ULONG_MAX) 50719370Spst#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */ 50819370Spst#endif 50919370Spst 51019370Spst#if !defined (LONG_MAX) 51119370Spst#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */ 51219370Spst#endif 51319370Spst 51419370Spst#ifdef BFD64 51519370Spst 51619370Spst/* This is to make sure that LONGEST is at least as big as CORE_ADDR. */ 51719370Spst 51819370Spst#define LONGEST BFD_HOST_64_BIT 51919370Spst 52019370Spst#else /* No BFD64 */ 52119370Spst 52219370Spst/* If all compilers for this host support "long long" and we want to 52319370Spst use it for LONGEST (the performance hit is about 10% on a testsuite 52419370Spst run based on one DECstation test), then the xm.h file can define 52519370Spst CC_HAS_LONG_LONG. 52619370Spst 52719370Spst Using GCC 1.39 on BSDI with long long causes about 700 new 52819370Spst testsuite failures. Using long long for LONGEST on the DECstation 52919370Spst causes 3 new FAILs in the testsuite and many heuristic fencepost 53019370Spst warnings. These are not investigated, but a first guess would be 53119370Spst that the BSDI problems are GCC bugs in long long support and the 53219370Spst latter are GDB bugs. */ 53319370Spst 53419370Spst#ifndef CC_HAS_LONG_LONG 53519370Spst# if defined (__GNUC__) && defined (FORCE_LONG_LONG) 53619370Spst# define CC_HAS_LONG_LONG 1 53719370Spst# endif 53819370Spst#endif 53919370Spst 54019370Spst/* LONGEST should not be a typedef, because "unsigned LONGEST" needs to work. 54119370Spst CC_HAS_LONG_LONG is defined if the host compiler supports "long long" 54219370Spst variables and we wish to make use of that support. */ 54319370Spst 54419370Spst#ifndef LONGEST 54519370Spst# ifdef CC_HAS_LONG_LONG 54619370Spst# define LONGEST long long 54719370Spst# else 54819370Spst# define LONGEST long 54919370Spst# endif 55019370Spst#endif 55119370Spst 55219370Spst#endif /* No BFD64 */ 55319370Spst 55419370Spst/* Convert a LONGEST to an int. This is used in contexts (e.g. number of 55519370Spst arguments to a function, number in a value history, register number, etc.) 55619370Spst where the value must not be larger than can fit in an int. */ 55719370Spst 55819370Spstextern int longest_to_int PARAMS ((LONGEST)); 55919370Spst 56019370Spst/* Assorted functions we can declare, now that const and volatile are 56119370Spst defined. */ 56219370Spst 56319370Spstextern char *savestring PARAMS ((const char *, int)); 56419370Spst 56519370Spstextern char *msavestring PARAMS ((void *, const char *, int)); 56619370Spst 56719370Spstextern char *strsave PARAMS ((const char *)); 56819370Spst 56919370Spstextern char *mstrsave PARAMS ((void *, const char *)); 57019370Spst 57119370Spstextern PTR xmmalloc PARAMS ((PTR, long)); 57219370Spst 57319370Spstextern PTR xmrealloc PARAMS ((PTR, PTR, long)); 57419370Spst 57519370Spstextern int parse_escape PARAMS ((char **)); 57619370Spst 57719370Spstextern char *reg_names[]; 57819370Spst 57919370Spst/* Message to be printed before the error message, when an error occurs. */ 58019370Spst 58119370Spstextern char *error_pre_print; 58219370Spst 58319370Spst/* Message to be printed before the error message, when an error occurs. */ 58419370Spst 58519370Spstextern char *quit_pre_print; 58619370Spst 58719370Spst/* Message to be printed before the warning message, when a warning occurs. */ 58819370Spst 58919370Spstextern char *warning_pre_print; 59019370Spst 59119370Spstextern NORETURN void error PARAMS((char *, ...)) ATTR_NORETURN; 59219370Spst 59319370Spstextern void error_begin PARAMS ((void)); 59419370Spst 59519370Spstextern NORETURN void fatal PARAMS((char *, ...)) ATTR_NORETURN; 59619370Spst 59719370Spstextern NORETURN void nomem PARAMS ((long)) ATTR_NORETURN; 59819370Spst 59919370Spst/* Reasons for calling return_to_top_level. */ 60019370Spstenum return_reason { 60119370Spst /* User interrupt. */ 60219370Spst RETURN_QUIT, 60319370Spst 60419370Spst /* Any other error. */ 60519370Spst RETURN_ERROR 60619370Spst}; 60719370Spst 60819370Spst#define RETURN_MASK_QUIT (1 << (int)RETURN_QUIT) 60919370Spst#define RETURN_MASK_ERROR (1 << (int)RETURN_ERROR) 61019370Spst#define RETURN_MASK_ALL (RETURN_MASK_QUIT | RETURN_MASK_ERROR) 61119370Spsttypedef int return_mask; 61219370Spst 61319370Spstextern NORETURN void 61419370Spstreturn_to_top_level PARAMS ((enum return_reason)) ATTR_NORETURN; 61519370Spst 61619370Spstextern int 61719370Spstcatch_errors PARAMS ((int (*) (char *), void *, char *, return_mask)); 61819370Spst 61919370Spstextern void warning_begin PARAMS ((void)); 62019370Spst 62119370Spstextern void warning PARAMS ((char *, ...)) 62219370Spst ATTR_FORMAT(printf, 1, 2); 62319370Spst 62419370Spst/* Global functions from other, non-gdb GNU thingies. 62519370Spst Libiberty thingies are no longer declared here. We include libiberty.h 62619370Spst above, instead. */ 62719370Spst 62819370Spst#ifndef GETENV_PROVIDED 62919370Spstextern char *getenv PARAMS ((const char *)); 63019370Spst#endif 63119370Spst 63219370Spst/* From other system libraries */ 63319370Spst 63419370Spst#ifdef __STDC__ 63519370Spst#include <stddef.h> 63619370Spst#include <stdlib.h> 63719370Spst#endif 63819370Spst 63919370Spst 64019370Spst/* We take the address of fclose later, but some stdio's forget 64119370Spst to declare this. We can't always declare it since there's 64219370Spst no way to declare the parameters without upsetting some compiler 64319370Spst somewhere. */ 64419370Spst 64519370Spst#ifndef FCLOSE_PROVIDED 64619370Spstextern int fclose (); 64719370Spst#endif 64819370Spst 64919370Spst#ifndef atof 65019370Spstextern double atof (); 65119370Spst#endif 65219370Spst 65319370Spst#ifndef MALLOC_INCOMPATIBLE 65419370Spst 65519370Spstextern PTR malloc (); 65619370Spst 65719370Spstextern PTR realloc (); 65819370Spst 65919370Spstextern void free (); 66019370Spst 66119370Spst#endif /* MALLOC_INCOMPATIBLE */ 66219370Spst 66319370Spst#ifndef __WIN32__ 66419370Spst 66519370Spst#ifndef strchr 66619370Spstextern char *strchr (); 66719370Spst#endif 66819370Spst 66919370Spst#ifndef strrchr 67019370Spstextern char *strrchr (); 67119370Spst#endif 67219370Spst 67319370Spst#ifndef strstr 67419370Spstextern char *strstr (); 67519370Spst#endif 67619370Spst 67719370Spst#ifndef strtok 67819370Spstextern char *strtok (); 67919370Spst#endif 68019370Spst 68119370Spst#ifndef strerror 68219370Spstextern char *strerror (); 68319370Spst#endif 68419370Spst 68519370Spst#endif /* !__WIN32__ */ 68619370Spst 68719370Spst/* Various possibilities for alloca. */ 68819370Spst#ifndef alloca 68919370Spst# ifdef __GNUC__ 69019370Spst# define alloca __builtin_alloca 69119370Spst# else /* Not GNU C */ 69219370Spst# ifdef sparc 69319370Spst# include <alloca.h> /* NOTE: Doesn't declare alloca() */ 69419370Spst# endif 69519370Spst 69619370Spst/* We need to be careful not to declare this in a way which conflicts with 69719370Spst bison. Bison never declares it as char *, but under various circumstances 69819370Spst (like __hpux) we need to use void *. */ 69919370Spst# if defined (__STDC__) || defined (__hpux) 70019370Spst extern void *alloca (); 70119370Spst# else /* Don't use void *. */ 70219370Spst extern char *alloca (); 70319370Spst# endif /* Don't use void *. */ 70419370Spst# endif /* Not GNU C */ 70519370Spst#endif /* alloca not defined */ 70619370Spst 70719370Spst/* HOST_BYTE_ORDER must be defined to one of these. */ 70819370Spst 70919370Spst#ifdef HAVE_ENDIAN_H 71019370Spst#include <endian.h> 71119370Spst#endif 71219370Spst 71319370Spst#if !defined (BIG_ENDIAN) 71419370Spst#define BIG_ENDIAN 4321 71519370Spst#endif 71619370Spst 71719370Spst#if !defined (LITTLE_ENDIAN) 71819370Spst#define LITTLE_ENDIAN 1234 71919370Spst#endif 72019370Spst 72119370Spst/* Target-system-dependent parameters for GDB. */ 72219370Spst 72319370Spst#ifdef TARGET_BYTE_ORDER_SELECTABLE 72419370Spst/* The target endianness is selectable at runtime. Define 72519370Spst TARGET_BYTE_ORDER to be a variable. The user can use the `set 72619370Spst endian' command to change it. */ 72719370Spst#undef TARGET_BYTE_ORDER 72819370Spst#define TARGET_BYTE_ORDER target_byte_order 72919370Spstextern int target_byte_order; 73019370Spst#endif 73119370Spst 73219370Spstextern void set_endian_from_file PARAMS ((bfd *)); 73319370Spst 73419370Spst/* Number of bits in a char or unsigned char for the target machine. 73519370Spst Just like CHAR_BIT in <limits.h> but describes the target machine. */ 73619370Spst#if !defined (TARGET_CHAR_BIT) 73719370Spst#define TARGET_CHAR_BIT 8 73819370Spst#endif 73919370Spst 74019370Spst/* Number of bits in a short or unsigned short for the target machine. */ 74119370Spst#if !defined (TARGET_SHORT_BIT) 74219370Spst#define TARGET_SHORT_BIT (2 * TARGET_CHAR_BIT) 74319370Spst#endif 74419370Spst 74519370Spst/* Number of bits in an int or unsigned int for the target machine. */ 74619370Spst#if !defined (TARGET_INT_BIT) 74719370Spst#define TARGET_INT_BIT (4 * TARGET_CHAR_BIT) 74819370Spst#endif 74919370Spst 75019370Spst/* Number of bits in a long or unsigned long for the target machine. */ 75119370Spst#if !defined (TARGET_LONG_BIT) 75219370Spst#define TARGET_LONG_BIT (4 * TARGET_CHAR_BIT) 75319370Spst#endif 75419370Spst 75519370Spst/* Number of bits in a long long or unsigned long long for the target machine. */ 75619370Spst#if !defined (TARGET_LONG_LONG_BIT) 75719370Spst#define TARGET_LONG_LONG_BIT (2 * TARGET_LONG_BIT) 75819370Spst#endif 75919370Spst 76019370Spst/* Number of bits in a float for the target machine. */ 76119370Spst#if !defined (TARGET_FLOAT_BIT) 76219370Spst#define TARGET_FLOAT_BIT (4 * TARGET_CHAR_BIT) 76319370Spst#endif 76419370Spst 76519370Spst/* Number of bits in a double for the target machine. */ 76619370Spst#if !defined (TARGET_DOUBLE_BIT) 76719370Spst#define TARGET_DOUBLE_BIT (8 * TARGET_CHAR_BIT) 76819370Spst#endif 76919370Spst 77019370Spst/* Number of bits in a long double for the target machine. */ 77119370Spst#if !defined (TARGET_LONG_DOUBLE_BIT) 77219370Spst#define TARGET_LONG_DOUBLE_BIT (2 * TARGET_DOUBLE_BIT) 77319370Spst#endif 77419370Spst 77519370Spst/* Number of bits in a pointer for the target machine */ 77619370Spst#if !defined (TARGET_PTR_BIT) 77719370Spst#define TARGET_PTR_BIT TARGET_INT_BIT 77819370Spst#endif 77919370Spst 78019370Spst/* If we picked up a copy of CHAR_BIT from a configuration file 78119370Spst (which may get it by including <limits.h>) then use it to set 78219370Spst the number of bits in a host char. If not, use the same size 78319370Spst as the target. */ 78419370Spst 78519370Spst#if defined (CHAR_BIT) 78619370Spst#define HOST_CHAR_BIT CHAR_BIT 78719370Spst#else 78819370Spst#define HOST_CHAR_BIT TARGET_CHAR_BIT 78919370Spst#endif 79019370Spst 79119370Spst/* The bit byte-order has to do just with numbering of bits in 79219370Spst debugging symbols and such. Conceptually, it's quite separate 79319370Spst from byte/word byte order. */ 79419370Spst 79519370Spst#if !defined (BITS_BIG_ENDIAN) 79619370Spst#ifndef TARGET_BYTE_ORDER_SELECTABLE 79719370Spst 79819370Spst#if TARGET_BYTE_ORDER == BIG_ENDIAN 79919370Spst#define BITS_BIG_ENDIAN 1 80019370Spst#endif /* Big endian. */ 80119370Spst 80219370Spst#if TARGET_BYTE_ORDER == LITTLE_ENDIAN 80319370Spst#define BITS_BIG_ENDIAN 0 80419370Spst#endif /* Little endian. */ 80519370Spst 80619370Spst#else /* defined (TARGET_BYTE_ORDER_SELECTABLE) */ 80719370Spst 80819370Spst#define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BIG_ENDIAN) 80919370Spst 81019370Spst#endif /* defined (TARGET_BYTE_ORDER_SELECTABLE) */ 81119370Spst#endif /* BITS_BIG_ENDIAN not defined. */ 81219370Spst 81319370Spst/* In findvar.c. */ 81419370Spst 81519370Spstextern LONGEST extract_signed_integer PARAMS ((void *, int)); 81619370Spst 81719370Spstextern unsigned LONGEST extract_unsigned_integer PARAMS ((void *, int)); 81819370Spst 81919370Spstextern int extract_long_unsigned_integer PARAMS ((void *, int, LONGEST *)); 82019370Spst 82119370Spstextern CORE_ADDR extract_address PARAMS ((void *, int)); 82219370Spst 82319370Spstextern void store_signed_integer PARAMS ((void *, int, LONGEST)); 82419370Spst 82519370Spstextern void store_unsigned_integer PARAMS ((void *, int, unsigned LONGEST)); 82619370Spst 82719370Spstextern void store_address PARAMS ((void *, int, CORE_ADDR)); 82819370Spst 82919370Spst/* Use `long double' if the host compiler supports it. (Note that this is not 83019370Spst necessarily any longer than `double'. On SunOS/gcc, it's the same as 83119370Spst double.) This is necessary because GDB internally converts all floating 83219370Spst point values to the widest type supported by the host. 83319370Spst 83419370Spst There are problems however, when the target `long double' is longer than the 83519370Spst host's `long double'. In general, we'll probably reduce the precision of 83619370Spst any such values and print a warning. */ 83719370Spst 83819370Spst 83919370Spst#ifdef HAVE_LONG_DOUBLE 84019370Spsttypedef long double DOUBLEST; 84119370Spst#else 84219370Spsttypedef double DOUBLEST; 84319370Spst#endif 84419370Spst 84519370Spstextern DOUBLEST extract_floating PARAMS ((void *, int)); 84619370Spst 84719370Spstextern void store_floating PARAMS ((void *, int, DOUBLEST)); 84819370Spst 84919370Spst/* On some machines there are bits in addresses which are not really 85019370Spst part of the address, but are used by the kernel, the hardware, etc. 85119370Spst for special purposes. ADDR_BITS_REMOVE takes out any such bits 85219370Spst so we get a "real" address such as one would find in a symbol 85319370Spst table. This is used only for addresses of instructions, and even then 85419370Spst I'm not sure it's used in all contexts. It exists to deal with there 85519370Spst being a few stray bits in the PC which would mislead us, not as some sort 85619370Spst of generic thing to handle alignment or segmentation (it's possible it 85719370Spst should be in TARGET_READ_PC instead). */ 85819370Spst#if !defined (ADDR_BITS_REMOVE) 85919370Spst#define ADDR_BITS_REMOVE(addr) (addr) 86019370Spst#endif /* No ADDR_BITS_REMOVE. */ 86119370Spst 86219370Spst/* From valops.c */ 86319370Spst 86419370Spstextern CORE_ADDR push_bytes PARAMS ((CORE_ADDR, char *, int)); 86519370Spst 86619370Spstextern CORE_ADDR push_word PARAMS ((CORE_ADDR, unsigned LONGEST)); 86719370Spst 86819370Spst/* Some parts of gdb might be considered optional, in the sense that they 86919370Spst are not essential for being able to build a working, usable debugger 87019370Spst for a specific environment. For example, the maintenance commands 87119370Spst are there for the benefit of gdb maintainers. As another example, 87219370Spst some environments really don't need gdb's that are able to read N 87319370Spst different object file formats. In order to make it possible (but 87419370Spst not necessarily recommended) to build "stripped down" versions of 87519370Spst gdb, the following defines control selective compilation of those 87619370Spst parts of gdb which can be safely left out when necessary. Note that 87719370Spst the default is to include everything. */ 87819370Spst 87919370Spst#ifndef MAINTENANCE_CMDS 88019370Spst#define MAINTENANCE_CMDS 1 88119370Spst#endif 88219370Spst 88319370Spst#ifdef MAINTENANCE_CMDS 88419370Spstextern int watchdog; 88519370Spst#endif 88619370Spst 88719370Spst#include "dis-asm.h" /* Get defs for disassemble_info */ 88819370Spst 88919370Spstextern int dis_asm_read_memory PARAMS ((bfd_vma memaddr, bfd_byte *myaddr, 89019370Spst int len, disassemble_info *info)); 89119370Spst 89219370Spstextern void dis_asm_memory_error PARAMS ((int status, bfd_vma memaddr, 89319370Spst disassemble_info *info)); 89419370Spst 89519370Spstextern void dis_asm_print_address PARAMS ((bfd_vma addr, 89619370Spst disassemble_info *info)); 89719370Spst 89819370Spstextern int (*tm_print_insn) PARAMS ((bfd_vma, disassemble_info*)); 89919370Spst 90019370Spst/* Hooks for alternate command interfaces. */ 90119370Spst 90219370Spst#ifdef __STDC__ 90319370Spststruct target_waitstatus; 90419370Spststruct cmd_list_element; 90519370Spst#endif 90619370Spst 90719370Spstextern void (*init_ui_hook) PARAMS ((void)); 90819370Spstextern void (*command_loop_hook) PARAMS ((void)); 90919370Spstextern void (*fputs_unfiltered_hook) PARAMS ((const char *linebuffer, 91019370Spst FILE *stream)); 91119370Spstextern void (*print_frame_info_listing_hook) PARAMS ((struct symtab *s, 91219370Spst int line, int stopline, 91319370Spst int noerror)); 91419370Spstextern int (*query_hook) PARAMS (()); 91519370Spstextern void (*flush_hook) PARAMS ((FILE *stream)); 91619370Spstextern void (*create_breakpoint_hook) PARAMS ((struct breakpoint *b)); 91719370Spstextern void (*delete_breakpoint_hook) PARAMS ((struct breakpoint *bpt)); 91819370Spstextern void (*modify_breakpoint_hook) PARAMS ((struct breakpoint *bpt)); 91919370Spstextern void (*target_output_hook) PARAMS ((char *)); 92019370Spstextern void (*interactive_hook) PARAMS ((void)); 92119370Spstextern void (*registers_changed_hook) PARAMS ((void)); 92219370Spst 92319370Spstextern int (*target_wait_hook) PARAMS ((int pid, 92419370Spst struct target_waitstatus *status)); 92519370Spst 92619370Spstextern void (*call_command_hook) PARAMS ((struct cmd_list_element *c, 92719370Spst char *cmd, int from_tty)); 92819370Spst 92919370Spstextern NORETURN void (*error_hook) PARAMS (()) ATTR_NORETURN; 93019370Spst 93119370Spst 93219370Spst 93319370Spst/* Inhibit window interface if non-zero. */ 93419370Spst 93519370Spstextern int use_windows; 93619370Spst 93719370Spst/* Symbolic definitions of filename-related things. */ 93819370Spst/* FIXME, this doesn't work very well if host and executable 93919370Spst filesystems conventions are different. */ 94019370Spst 94119370Spst#ifndef DIRNAME_SEPARATOR 94219370Spst#define DIRNAME_SEPARATOR ':' 94319370Spst#endif 94419370Spst 94519370Spst#ifndef SLASH_P 94619370Spst#if defined(__GO32__)||defined(__WIN32__) 94719370Spst#define SLASH_P(X) ((X)=='\\') 94819370Spst#else 94919370Spst#define SLASH_P(X) ((X)=='/') 95019370Spst#endif 95119370Spst#endif 95219370Spst 95319370Spst#ifndef SLASH_CHAR 95419370Spst#if defined(__GO32__)||defined(__WIN32__) 95519370Spst#define SLASH_CHAR '\\' 95619370Spst#else 95719370Spst#define SLASH_CHAR '/' 95819370Spst#endif 95919370Spst#endif 96019370Spst 96119370Spst#ifndef SLASH_STRING 96219370Spst#if defined(__GO32__)||defined(__WIN32__) 96319370Spst#define SLASH_STRING "\\" 96419370Spst#else 96519370Spst#define SLASH_STRING "/" 96619370Spst#endif 96719370Spst#endif 96819370Spst 96919370Spst#ifndef ROOTED_P 97019370Spst#define ROOTED_P(X) (SLASH_P((X)[0])) 97119370Spst#endif 97219370Spst 97319370Spst#endif /* #ifndef DEFS_H */ 974