198948Sobrien/* *INDENT-OFF* */ /* ATTR_FORMAT confuses indent, avoid running it for now */ 219370Spst/* Basic, host-specific, and target-specific definitions for GDB. 398948Sobrien Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 4130809Smarcel 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 519370Spst Free Software Foundation, Inc. 619370Spst 798948Sobrien This file is part of GDB. 819370Spst 998948Sobrien This program is free software; you can redistribute it and/or modify 1098948Sobrien it under the terms of the GNU General Public License as published by 1198948Sobrien the Free Software Foundation; either version 2 of the License, or 1298948Sobrien (at your option) any later version. 1319370Spst 1498948Sobrien This program is distributed in the hope that it will be useful, 1598948Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1698948Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1798948Sobrien GNU General Public License for more details. 1819370Spst 1998948Sobrien You should have received a copy of the GNU General Public License 2098948Sobrien along with this program; if not, write to the Free Software 2198948Sobrien Foundation, Inc., 59 Temple Place - Suite 330, 2298948Sobrien Boston, MA 02111-1307, USA. */ 2319370Spst 2419370Spst#ifndef DEFS_H 2519370Spst#define DEFS_H 2619370Spst 27130809Smarcel#include "config.h" /* Generated by configure. */ 28130809Smarcel 2919370Spst#include <stdio.h> 30130809Smarcel#include <errno.h> /* System call error return status. */ 3146283Sdfr#include <limits.h> 3219370Spst 3346283Sdfr#ifdef HAVE_STDDEF_H 3498948Sobrien#include <stddef.h> 3546283Sdfr#else 36130809Smarcel#include <sys/types.h> /* For size_t. */ 3746283Sdfr#endif 3846283Sdfr 3998948Sobrien#ifdef HAVE_UNISTD_H 4098948Sobrien#include <unistd.h> 4198948Sobrien#endif 4298948Sobrien 43130809Smarcel/* First include ansidecl.h so we can use the various macro definitions 44130809Smarcel here and in all subsequent file inclusions. */ 4519370Spst 46130809Smarcel#include "ansidecl.h" 47130809Smarcel 48130809Smarcel#include "gdb_locale.h" 49130809Smarcel 50130809Smarcel/* For ``enum target_signal''. */ 51130809Smarcel#include "gdb/signals.h" 52130809Smarcel 53130809Smarcel/* Just in case they're not defined in stdio.h. */ 54130809Smarcel 5519370Spst#ifndef SEEK_SET 5619370Spst#define SEEK_SET 0 5719370Spst#endif 5819370Spst#ifndef SEEK_CUR 5919370Spst#define SEEK_CUR 1 6019370Spst#endif 6119370Spst 62130809Smarcel#include <stdarg.h> /* For va_list. */ 6319370Spst 6419370Spst#include "libiberty.h" 6519370Spst 6619370Spst/* For BFD64 and bfd_vma. */ 6719370Spst#include "bfd.h" 6819370Spst 6998948Sobrien 7098948Sobrien/* The target is partially multi-arched. Both "tm.h" and the 7198948Sobrien multi-arch vector provide definitions. "tm.h" normally overrides 7298948Sobrien the multi-arch vector (but there are a few exceptions). */ 7398948Sobrien 7498948Sobrien#define GDB_MULTI_ARCH_PARTIAL 1 7598948Sobrien 7698948Sobrien/* The target is partially multi-arched. Both the multi-arch vector 7798948Sobrien and "tm.h" provide definitions. "tm.h" cannot override a definition 7898948Sobrien provided by the multi-arch vector. It is detected as a compilation 7998948Sobrien error. 8098948Sobrien 8198948Sobrien This setting is only useful during a multi-arch conversion. */ 8298948Sobrien 8398948Sobrien#define GDB_MULTI_ARCH_TM 2 8498948Sobrien 8598948Sobrien/* The target is pure multi-arch. The MULTI-ARCH vector provides all 8698948Sobrien definitions. "tm.h" is linked to an empty file. */ 8798948Sobrien 8898948Sobrien#define GDB_MULTI_ARCH_PURE 3 8998948Sobrien 9098948Sobrien 9198948Sobrien 9219370Spst/* An address in the program being debugged. Host byte order. Rather 9319370Spst than duplicate all the logic in BFD which figures out what type 9419370Spst this is (long, long long, etc.) and whether it needs to be 64 9519370Spst bits (the host/target interactions are subtle), we just use 9619370Spst bfd_vma. */ 9719370Spst 9819370Spsttypedef bfd_vma CORE_ADDR; 9919370Spst 10098948Sobrien/* This is to make sure that LONGEST is at least as big as CORE_ADDR. */ 10198948Sobrien 10298948Sobrien#ifndef LONGEST 10398948Sobrien 10498948Sobrien#ifdef BFD64 10598948Sobrien 10698948Sobrien#define LONGEST BFD_HOST_64_BIT 10798948Sobrien#define ULONGEST BFD_HOST_U_64_BIT 10898948Sobrien 10998948Sobrien#else /* No BFD64 */ 11098948Sobrien 11198948Sobrien#ifdef CC_HAS_LONG_LONG 11298948Sobrien#define LONGEST long long 11398948Sobrien#define ULONGEST unsigned long long 11498948Sobrien#else 11598948Sobrien#ifdef BFD_HOST_64_BIT 11698948Sobrien/* BFD_HOST_64_BIT is defined for some hosts that don't have long long 11798948Sobrien (e.g. i386-windows) so try it. */ 11898948Sobrien#define LONGEST BFD_HOST_64_BIT 11998948Sobrien#define ULONGEST BFD_HOST_U_64_BIT 12098948Sobrien#else 12198948Sobrien#define LONGEST long 12298948Sobrien#define ULONGEST unsigned long 12398948Sobrien#endif 12498948Sobrien#endif 12598948Sobrien 12698948Sobrien#endif /* No BFD64 */ 12798948Sobrien 12898948Sobrien#endif /* ! LONGEST */ 12998948Sobrien 13046283Sdfr#ifndef min 13119370Spst#define min(a, b) ((a) < (b) ? (a) : (b)) 13246283Sdfr#endif 13346283Sdfr#ifndef max 13419370Spst#define max(a, b) ((a) > (b) ? (a) : (b)) 13546283Sdfr#endif 13619370Spst 13798948Sobrien/* Macros to do string compares. 13819370Spst 13998948Sobrien NOTE: cagney/2000-03-14: 14098948Sobrien 14198948Sobrien While old code can continue to refer to these macros, new code is 14298948Sobrien probably better off using strcmp() directly vis: ``strcmp() == 0'' 14398948Sobrien and ``strcmp() != 0''. 14498948Sobrien 14598948Sobrien This is because modern compilers can directly inline strcmp() 14698948Sobrien making the original justification for these macros - avoid function 14798948Sobrien call overhead by pre-testing the first characters 14898948Sobrien (``*X==*Y?...:0'') - redundant. 14998948Sobrien 15098948Sobrien ``Even if [...] testing the first character does have a modest 15198948Sobrien performance improvement, I'd rather that whenever a performance 15298948Sobrien issue is found that we spend the effort on algorithmic 15398948Sobrien optimizations than micro-optimizing.'' J.T. */ 15498948Sobrien 155130809Smarcel/* NOTE: cagney/2003-11-23: All instances of STREQ[N] covered by 156130809Smarcel testing GDB on a stabs system have been replaced by equivalent 157130809Smarcel str[n]cmp calls. To avoid the possability of introducing bugs when 158130809Smarcel making untested changes, the remaining references were deprecated 159130809Smarcel rather than replaced. */ 16019370Spst 161130809Smarcel/* DISCLAIMER: cagney/2003-11-23: Simplified definition of these 162130809Smarcel macros so that they just map directly onto strcmp equivalent. I'm 163130809Smarcel not responsible for any breakage due to code that relied on the old 164130809Smarcel underlying implementation. */ 16519370Spst 166130809Smarcel#define DEPRECATED_STREQ(a,b) (strcmp ((a), (b)) == 0) 167130809Smarcel#define DEPRECATED_STREQN(a,b,c) (strncmp ((a), (b), (c)) == 0) 168130809Smarcel 16919370Spst/* Check if a character is one of the commonly used C++ marker characters. */ 17098948Sobrienextern int is_cplus_marker (int); 17119370Spst 17246283Sdfr/* enable xdb commands if set */ 17346283Sdfrextern int xdb_commands; 17446283Sdfr 17546283Sdfr/* enable dbx commands if set */ 17646283Sdfrextern int dbx_commands; 17746283Sdfr 178130809Smarcel/* System root path, used to find libraries etc. */ 179130809Smarcelextern char *gdb_sysroot; 180130809Smarcel 18119370Spstextern int quit_flag; 18219370Spstextern int immediate_quit; 18319370Spstextern int sevenbit_strings; 18419370Spst 18598948Sobrienextern void quit (void); 18619370Spst 18798948Sobrien/* FIXME: cagney/2000-03-13: It has been suggested that the peformance 18898948Sobrien benefits of having a ``QUIT'' macro rather than a function are 18998948Sobrien marginal. If the overhead of a QUIT function call is proving 19098948Sobrien significant then its calling frequency should probably be reduced 19198948Sobrien [kingdon]. A profile analyzing the current situtation is 19298948Sobrien needed. */ 19398948Sobrien 19446283Sdfr#ifdef QUIT 19546283Sdfr/* do twice to force compiler warning */ 19646283Sdfr#define QUIT_FIXME "FIXME" 19746283Sdfr#define QUIT_FIXME "ignoring redefinition of QUIT" 19846283Sdfr#else 19919370Spst#define QUIT { \ 20019370Spst if (quit_flag) quit (); \ 20119370Spst if (interactive_hook) interactive_hook (); \ 20219370Spst} 20346283Sdfr#endif 20419370Spst 20519370Spst/* Languages represented in the symbol table and elsewhere. 20619370Spst This should probably be in language.h, but since enum's can't 20719370Spst be forward declared to satisfy opaque references before their 20819370Spst actual definition, needs to be here. */ 20919370Spst 21098948Sobrienenum language 21198948Sobrien { 21298948Sobrien language_unknown, /* Language not known */ 21398948Sobrien language_auto, /* Placeholder for automatic setting */ 21498948Sobrien language_c, /* C */ 21598948Sobrien language_cplus, /* C++ */ 216130809Smarcel language_objc, /* Objective-C */ 21798948Sobrien language_java, /* Java */ 21898948Sobrien language_fortran, /* Fortran */ 21998948Sobrien language_m2, /* Modula-2 */ 22098948Sobrien language_asm, /* Assembly language */ 22198948Sobrien language_scm, /* Scheme / Guile */ 222130809Smarcel language_pascal, /* Pascal */ 223130809Smarcel language_minimal /* All other languages, minimal support only */ 22498948Sobrien }; 22519370Spst 22646283Sdfrenum precision_type 22798948Sobrien { 22898948Sobrien single_precision, 22998948Sobrien double_precision, 23098948Sobrien unspecified_precision 23198948Sobrien }; 23298948Sobrien 233130809Smarcel/* A generic, not quite boolean, enumeration. */ 234130809Smarcelenum auto_boolean 235130809Smarcel{ 236130809Smarcel AUTO_BOOLEAN_TRUE, 237130809Smarcel AUTO_BOOLEAN_FALSE, 238130809Smarcel AUTO_BOOLEAN_AUTO 239130809Smarcel}; 24098948Sobrien 241130809Smarcel/* Potential ways that a function can return a value of a given type. */ 242130809Smarcelenum return_value_convention 243130809Smarcel{ 244130809Smarcel /* Where the return value has been squeezed into one or more 245130809Smarcel registers. */ 246130809Smarcel RETURN_VALUE_REGISTER_CONVENTION, 247130809Smarcel /* Commonly known as the "struct return convention". The caller 248130809Smarcel passes an additional hidden first parameter to the caller. That 249130809Smarcel parameter contains the address at which the value being returned 250130809Smarcel should be stored. While typically, and historically, used for 251130809Smarcel large structs, this is convention is applied to values of many 252130809Smarcel different types. */ 253130809Smarcel RETURN_VALUE_STRUCT_CONVENTION 254130809Smarcel}; 25598948Sobrien 25619370Spst/* the cleanup list records things that have to be undone 25719370Spst if an error happens (descriptors to be closed, memory to be freed, etc.) 25819370Spst Each link in the chain records a function to call and an 25919370Spst argument to give it. 26019370Spst 26119370Spst Use make_cleanup to add an element to the cleanup chain. 26219370Spst Use do_cleanups to do all cleanup actions back to a given 26319370Spst point in the chain. Use discard_cleanups to remove cleanups 26419370Spst from the chain back to a given point, not doing them. */ 26519370Spst 26619370Spststruct cleanup 26798948Sobrien { 26898948Sobrien struct cleanup *next; 269130809Smarcel void (*function) (void *); 270130809Smarcel void *arg; 27198948Sobrien }; 27219370Spst 27319370Spst 27419370Spst/* The ability to declare that a function never returns is useful, but 27519370Spst not really required to compile GDB successfully, so the NORETURN and 27619370Spst ATTR_NORETURN macros normally expand into nothing. */ 27719370Spst 27819370Spst/* If compiling with older versions of GCC, a function may be declared 27919370Spst "volatile" to indicate that it does not return. */ 28019370Spst 28119370Spst#ifndef NORETURN 28298948Sobrien#if defined(__GNUC__) \ 28319370Spst && (__GNUC__ == 1 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)) 28498948Sobrien#define NORETURN volatile 28598948Sobrien#else 28698948Sobrien#define NORETURN /* nothing */ 28719370Spst#endif 28898948Sobrien#endif 28919370Spst 29019370Spst/* GCC 2.5 and later versions define a function attribute "noreturn", 29119370Spst which is the preferred way to declare that a function never returns. 29219370Spst However GCC 2.7 appears to be the first version in which this fully 29319370Spst works everywhere we use it. */ 29419370Spst 29519370Spst#ifndef ATTR_NORETURN 29698948Sobrien#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)) 29798948Sobrien#define ATTR_NORETURN __attribute__ ((noreturn)) 29898948Sobrien#else 29998948Sobrien#define ATTR_NORETURN /* nothing */ 30019370Spst#endif 30198948Sobrien#endif 30219370Spst 30319370Spst#ifndef ATTR_FORMAT 30498948Sobrien#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4)) 30598948Sobrien#define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y))) 30698948Sobrien#else 30798948Sobrien#define ATTR_FORMAT(type, x, y) /* nothing */ 30819370Spst#endif 30998948Sobrien#endif 31019370Spst 311130809Smarcel/* Be conservative and use enum bitfields only with GCC. 312130809Smarcel This is copied from gcc 3.3.1, system.h. */ 313130809Smarcel 314130809Smarcel#if defined(__GNUC__) && (__GNUC__ >= 2) 315130809Smarcel#define ENUM_BITFIELD(TYPE) enum TYPE 316130809Smarcel#else 317130809Smarcel#define ENUM_BITFIELD(TYPE) unsigned int 318130809Smarcel#endif 319130809Smarcel 32019370Spst/* Needed for various prototypes */ 32119370Spst 32219370Spststruct symtab; 32319370Spststruct breakpoint; 324130809Smarcelstruct frame_info; 32519370Spst 32619370Spst/* From blockframe.c */ 32719370Spst 328130809Smarcelextern int inside_entry_func (struct frame_info *this_frame); 32919370Spst 330130809Smarcelextern int deprecated_inside_entry_file (CORE_ADDR addr); 33119370Spst 33298948Sobrienextern int inside_main_func (CORE_ADDR pc); 33319370Spst 33419370Spst/* From utils.c */ 33519370Spst 33698948Sobrienextern void initialize_utils (void); 33746283Sdfr 33898948Sobrienextern void notice_quit (void); 33919370Spst 34098948Sobrienextern int strcmp_iw (const char *, const char *); 34119370Spst 342130809Smarcelextern int strcmp_iw_ordered (const char *, const char *); 343130809Smarcel 344130809Smarcelextern int streq (const char *, const char *); 345130809Smarcel 34698948Sobrienextern int subset_compare (char *, char *); 34719370Spst 34898948Sobrienextern char *safe_strerror (int); 34919370Spst 35098948Sobrienextern void init_malloc (void *); 35119370Spst 35298948Sobrienextern void request_quit (int); 35319370Spst 35498948Sobrienextern void do_cleanups (struct cleanup *); 35598948Sobrienextern void do_final_cleanups (struct cleanup *); 35698948Sobrienextern void do_run_cleanups (struct cleanup *); 35798948Sobrienextern void do_exec_cleanups (struct cleanup *); 35898948Sobrienextern void do_exec_error_cleanups (struct cleanup *); 35919370Spst 36098948Sobrienextern void discard_cleanups (struct cleanup *); 36198948Sobrienextern void discard_final_cleanups (struct cleanup *); 36298948Sobrienextern void discard_exec_error_cleanups (struct cleanup *); 36398948Sobrienextern void discard_my_cleanups (struct cleanup **, struct cleanup *); 36419370Spst 36598948Sobrien/* NOTE: cagney/2000-03-04: This typedef is strictly for the 36698948Sobrien make_cleanup function declarations below. Do not use this typedef 36798948Sobrien as a cast when passing functions into the make_cleanup() code. 36898948Sobrien Instead either use a bounce function or add a wrapper function. 36998948Sobrien Calling a f(char*) function with f(void*) is non-portable. */ 37098948Sobrientypedef void (make_cleanup_ftype) (void *); 37119370Spst 37298948Sobrienextern struct cleanup *make_cleanup (make_cleanup_ftype *, void *); 37319370Spst 37498948Sobrienextern struct cleanup *make_cleanup_freeargv (char **); 37519370Spst 37698948Sobrienstruct ui_file; 37798948Sobrienextern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *); 37846283Sdfr 37998948Sobrienextern struct cleanup *make_cleanup_close (int fd); 38019370Spst 38198948Sobrienextern struct cleanup *make_cleanup_bfd_close (bfd *abfd); 38219370Spst 38398948Sobrienextern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *); 38419370Spst 38598948Sobrienextern struct cleanup *make_my_cleanup (struct cleanup **, 38698948Sobrien make_cleanup_ftype *, void *); 38719370Spst 38898948Sobrienextern struct cleanup *make_run_cleanup (make_cleanup_ftype *, void *); 38919370Spst 39098948Sobrienextern struct cleanup *make_exec_cleanup (make_cleanup_ftype *, void *); 39198948Sobrienextern struct cleanup *make_exec_error_cleanup (make_cleanup_ftype *, void *); 39246283Sdfr 39398948Sobrienextern struct cleanup *save_cleanups (void); 39498948Sobrienextern struct cleanup *save_final_cleanups (void); 39598948Sobrienextern struct cleanup *save_my_cleanups (struct cleanup **); 39646283Sdfr 39798948Sobrienextern void restore_cleanups (struct cleanup *); 39898948Sobrienextern void restore_final_cleanups (struct cleanup *); 39998948Sobrienextern void restore_my_cleanups (struct cleanup **, struct cleanup *); 40098948Sobrien 40198948Sobrienextern void free_current_contents (void *); 40298948Sobrien 40398948Sobrienextern void null_cleanup (void *); 40498948Sobrien 40598948Sobrienextern int myread (int, char *, int); 40698948Sobrien 40798948Sobrienextern int query (const char *, ...) ATTR_FORMAT (printf, 1, 2); 408130809Smarcelextern int nquery (const char *, ...) ATTR_FORMAT (printf, 1, 2); 409130809Smarcelextern int yquery (const char *, ...) ATTR_FORMAT (printf, 1, 2); 41098948Sobrien 41198948Sobrienextern void init_page_info (void); 41298948Sobrien 41398948Sobrienextern char *gdb_realpath (const char *); 414130809Smarcelextern char *xfullpath (const char *); 41598948Sobrien 416130809Smarcelextern unsigned long gnu_debuglink_crc32 (unsigned long crc, 417130809Smarcel unsigned char *buf, size_t len); 418130809Smarcel 41946283Sdfr/* From demangle.c */ 42046283Sdfr 42198948Sobrienextern void set_demangling_style (char *); 42246283Sdfr 42346283Sdfr/* From tm.h */ 42446283Sdfr 42546283Sdfrstruct type; 42698948Sobrientypedef int (use_struct_convention_fn) (int gcc_p, struct type * value_type); 42746283Sdfrextern use_struct_convention_fn generic_use_struct_convention; 42846283Sdfr 42919370Spst 43019370Spst/* Annotation stuff. */ 43119370Spst 43298948Sobrienextern int annotation_level; /* in stack.c */ 43319370Spst 43498948Sobrienextern void begin_line (void); 43519370Spst 43698948Sobrienextern void wrap_here (char *); 43719370Spst 43898948Sobrienextern void reinitialize_more_filter (void); 43919370Spst 44098948Sobrien/* Normal results */ 44198948Sobrienextern struct ui_file *gdb_stdout; 442130809Smarcel/* Input stream */ 443130809Smarcelextern struct ui_file *gdb_stdin; 44498948Sobrien/* Serious error notifications */ 44598948Sobrienextern struct ui_file *gdb_stderr; 44698948Sobrien/* Log/debug/trace messages that should bypass normal stdout/stderr 447130809Smarcel filtering. For moment, always call this stream using 44898948Sobrien *_unfiltered. In the very near future that restriction shall be 44998948Sobrien removed - either call shall be unfiltered. (cagney 1999-06-13). */ 45098948Sobrienextern struct ui_file *gdb_stdlog; 45198948Sobrien/* Target output that should bypass normal stdout/stderr filtering. 452130809Smarcel For moment, always call this stream using *_unfiltered. In the 45398948Sobrien very near future that restriction shall be removed - either call 45498948Sobrien shall be unfiltered. (cagney 1999-07-02). */ 45598948Sobrienextern struct ui_file *gdb_stdtarg; 456130809Smarcelextern struct ui_file *gdb_stdtargerr; 457130809Smarcelextern struct ui_file *gdb_stdtargin; 45846283Sdfr 45998948Sobrien#include "ui-file.h" 46046283Sdfr 46198948Sobrien/* More generic printf like operations. Filtered versions may return 46298948Sobrien non-locally on error. */ 46319370Spst 46498948Sobrienextern void fputs_filtered (const char *, struct ui_file *); 46519370Spst 46698948Sobrienextern void fputs_unfiltered (const char *, struct ui_file *); 46719370Spst 46898948Sobrienextern int fputc_filtered (int c, struct ui_file *); 46919370Spst 47098948Sobrienextern int fputc_unfiltered (int c, struct ui_file *); 47146283Sdfr 47298948Sobrienextern int putchar_filtered (int c); 47319370Spst 47498948Sobrienextern int putchar_unfiltered (int c); 47519370Spst 47698948Sobrienextern void puts_filtered (const char *); 47719370Spst 47898948Sobrienextern void puts_unfiltered (const char *); 47919370Spst 480130809Smarcelextern void puts_filtered_tabular (char *string, int width, int right); 481130809Smarcel 48298948Sobrienextern void puts_debug (char *prefix, char *string, char *suffix); 48346283Sdfr 48498948Sobrienextern void vprintf_filtered (const char *, va_list) ATTR_FORMAT (printf, 1, 0); 48519370Spst 48698948Sobrienextern void vfprintf_filtered (struct ui_file *, const char *, va_list) ATTR_FORMAT (printf, 2, 0); 48719370Spst 48898948Sobrienextern void fprintf_filtered (struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 2, 3); 48919370Spst 49098948Sobrienextern void fprintfi_filtered (int, struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 3, 4); 49119370Spst 49298948Sobrienextern void printf_filtered (const char *, ...) ATTR_FORMAT (printf, 1, 2); 49319370Spst 49498948Sobrienextern void printfi_filtered (int, const char *, ...) ATTR_FORMAT (printf, 2, 3); 49519370Spst 49698948Sobrienextern void vprintf_unfiltered (const char *, va_list) ATTR_FORMAT (printf, 1, 0); 49719370Spst 49898948Sobrienextern void vfprintf_unfiltered (struct ui_file *, const char *, va_list) ATTR_FORMAT (printf, 2, 0); 49919370Spst 50098948Sobrienextern void fprintf_unfiltered (struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 2, 3); 50119370Spst 50298948Sobrienextern void printf_unfiltered (const char *, ...) ATTR_FORMAT (printf, 1, 2); 50319370Spst 50498948Sobrienextern void print_spaces (int, struct ui_file *); 50546283Sdfr 50698948Sobrienextern void print_spaces_filtered (int, struct ui_file *); 50746283Sdfr 50898948Sobrienextern char *n_spaces (int); 50946283Sdfr 51098948Sobrienextern void fputstr_filtered (const char *str, int quotr, struct ui_file * stream); 51146283Sdfr 51298948Sobrienextern void fputstr_unfiltered (const char *str, int quotr, struct ui_file * stream); 51346283Sdfr 51498948Sobrienextern void fputstrn_unfiltered (const char *str, int n, int quotr, struct ui_file * stream); 51519370Spst 51698948Sobrien/* Display the host ADDR on STREAM formatted as ``0x%x''. */ 517130809Smarcelextern void gdb_print_host_address (const void *addr, struct ui_file *stream); 51819370Spst 51998948Sobrien/* Convert a CORE_ADDR into a HEX string. paddr() is like %08lx. 52098948Sobrien paddr_nz() is like %lx. paddr_u() is like %lu. paddr_width() is 52198948Sobrien for ``%*''. */ 52298948Sobrienextern int strlen_paddr (void); 52398948Sobrienextern char *paddr (CORE_ADDR addr); 52498948Sobrienextern char *paddr_nz (CORE_ADDR addr); 52598948Sobrienextern char *paddr_u (CORE_ADDR addr); 52698948Sobrienextern char *paddr_d (LONGEST addr); 52719370Spst 52898948Sobrienextern char *phex (ULONGEST l, int sizeof_l); 52998948Sobrienextern char *phex_nz (ULONGEST l, int sizeof_l); 53019370Spst 53198948Sobrien/* Like paddr() only print/scan raw CORE_ADDR. The output from 53298948Sobrien core_addr_to_string() can be passed direct to 53398948Sobrien string_to_core_addr(). */ 53498948Sobrienextern const char *core_addr_to_string (const CORE_ADDR addr); 53598948Sobrienextern const char *core_addr_to_string_nz (const CORE_ADDR addr); 53698948Sobrienextern CORE_ADDR string_to_core_addr (const char *my_string); 53719370Spst 53898948Sobrienextern void fprintf_symbol_filtered (struct ui_file *, char *, 53998948Sobrien enum language, int); 54046283Sdfr 54198948Sobrienextern NORETURN void perror_with_name (const char *) ATTR_NORETURN; 54246283Sdfr 54398948Sobrienextern void print_sys_errmsg (const char *, int); 54446283Sdfr 54519370Spst/* From regex.c or libc. BSD 4.4 declares this with the argument type as 54619370Spst "const char *" in unistd.h, so we can't declare the argument 54719370Spst as "char *". */ 54819370Spst 54998948Sobrienextern char *re_comp (const char *); 55019370Spst 55119370Spst/* From symfile.c */ 55219370Spst 55398948Sobrienextern void symbol_file_command (char *, int); 55419370Spst 55598948Sobrien/* Remote targets may wish to use this as their load function. */ 55698948Sobrienextern void generic_load (char *name, int from_tty); 55798948Sobrien 55898948Sobrien/* Summarise a download */ 55998948Sobrienextern void print_transfer_performance (struct ui_file *stream, 56098948Sobrien unsigned long data_count, 56198948Sobrien unsigned long write_count, 56298948Sobrien unsigned long time_count); 56398948Sobrien 56419370Spst/* From top.c */ 56519370Spst 56698948Sobrientypedef void initialize_file_ftype (void); 56719370Spst 56898948Sobrienextern char *skip_quoted (char *); 56919370Spst 57098948Sobrienextern char *gdb_readline (char *); 57119370Spst 572130809Smarcelextern char *gdb_readline_wrapper (char *); 573130809Smarcel 57498948Sobrienextern char *command_line_input (char *, int, char *); 57519370Spst 57698948Sobrienextern void print_prompt (void); 57719370Spst 57898948Sobrienextern int input_from_terminal_p (void); 57998948Sobrien 58019370Spstextern int info_verbose; 58119370Spst 58219370Spst/* From printcmd.c */ 58319370Spst 58498948Sobrienextern void set_next_address (CORE_ADDR); 58519370Spst 58698948Sobrienextern void print_address_symbolic (CORE_ADDR, struct ui_file *, int, 58798948Sobrien char *); 58819370Spst 58998948Sobrienextern int build_address_symbolic (CORE_ADDR addr, 59098948Sobrien int do_demangle, 59198948Sobrien char **name, 59298948Sobrien int *offset, 59398948Sobrien char **filename, 59498948Sobrien int *line, 59598948Sobrien int *unmapped); 59619370Spst 59798948Sobrienextern void print_address_numeric (CORE_ADDR, int, struct ui_file *); 59819370Spst 59998948Sobrienextern void print_address (CORE_ADDR, struct ui_file *); 60098948Sobrien 60119370Spst/* From source.c */ 60219370Spst 60398948Sobrienextern int openp (const char *, int, const char *, int, int, char **); 60419370Spst 60598948Sobrienextern int source_full_path_of (char *, char **); 60646283Sdfr 60798948Sobrienextern void mod_path (char *, char **); 60819370Spst 609130809Smarcelextern void add_path (char *, char **, int); 610130809Smarcel 61198948Sobrienextern void directory_command (char *, int); 61219370Spst 613130809Smarcelextern char *source_path; 614130809Smarcel 61598948Sobrienextern void init_source_path (void); 61619370Spst 617130809Smarcelextern void init_last_source_visited (void); 618130809Smarcel 61998948Sobrienextern char *symtab_to_filename (struct symtab *); 62019370Spst 62198948Sobrien/* From exec.c */ 62298948Sobrien 62398948Sobrienextern void exec_set_section_offsets (bfd_signed_vma text_off, 62498948Sobrien bfd_signed_vma data_off, 62598948Sobrien bfd_signed_vma bss_off); 62698948Sobrien 62798948Sobrien/* Take over the 'find_mapped_memory' vector from exec.c. */ 62898948Sobrienextern void exec_set_find_memory_regions (int (*) (int (*) (CORE_ADDR, 62998948Sobrien unsigned long, 63098948Sobrien int, int, int, 63198948Sobrien void *), 63298948Sobrien void *)); 63398948Sobrien 63498948Sobrien/* Possible lvalue types. Like enum language, this should be in 63598948Sobrien value.h, but needs to be here for the same reason. */ 63698948Sobrien 63798948Sobrienenum lval_type 63898948Sobrien { 63998948Sobrien /* Not an lval. */ 64098948Sobrien not_lval, 64198948Sobrien /* In memory. Could be a saved register. */ 64298948Sobrien lval_memory, 64398948Sobrien /* In a register. */ 64498948Sobrien lval_register, 64598948Sobrien /* In a gdb internal variable. */ 64698948Sobrien lval_internalvar, 64798948Sobrien /* Part of a gdb internal variable (structure field). */ 64898948Sobrien lval_internalvar_component, 64998948Sobrien /* In a register series in a frame not the current one, which may have been 65098948Sobrien partially saved or saved in different places (otherwise would be 65198948Sobrien lval_register or lval_memory). */ 65298948Sobrien lval_reg_frame_relative 65398948Sobrien }; 65498948Sobrien 65519370Spst/* Control types for commands */ 65619370Spst 65719370Spstenum misc_command_type 65898948Sobrien { 65998948Sobrien ok_command, 66098948Sobrien end_command, 66198948Sobrien else_command, 66298948Sobrien nop_command 66398948Sobrien }; 66419370Spst 66519370Spstenum command_control_type 66698948Sobrien { 66798948Sobrien simple_control, 66898948Sobrien break_control, 66998948Sobrien continue_control, 67098948Sobrien while_control, 67198948Sobrien if_control, 67298948Sobrien invalid_control 67398948Sobrien }; 67419370Spst 67519370Spst/* Structure for saved commands lines 67619370Spst (for breakpoints, defined commands, etc). */ 67719370Spst 67819370Spststruct command_line 67998948Sobrien { 68098948Sobrien struct command_line *next; 68198948Sobrien char *line; 68298948Sobrien enum command_control_type control_type; 68398948Sobrien int body_count; 68498948Sobrien struct command_line **body_list; 68598948Sobrien }; 68619370Spst 68798948Sobrienextern struct command_line *read_command_lines (char *, int); 68819370Spst 68998948Sobrienextern void free_command_lines (struct command_line **); 69019370Spst 69198948Sobrien/* To continue the execution commands when running gdb asynchronously. 69298948Sobrien A continuation structure contains a pointer to a function to be called 69398948Sobrien to finish the command, once the target has stopped. Such mechanism is 69498948Sobrien used bt the finish and until commands, and in the remote protocol 69598948Sobrien when opening an extended-remote connection. */ 69698948Sobrien 69798948Sobrienstruct continuation_arg 69898948Sobrien { 69998948Sobrien struct continuation_arg *next; 70098948Sobrien union continuation_data { 70198948Sobrien void *pointer; 70298948Sobrien int integer; 70398948Sobrien long longint; 70498948Sobrien } data; 70598948Sobrien }; 70698948Sobrien 70798948Sobrienstruct continuation 70898948Sobrien { 70998948Sobrien void (*continuation_hook) (struct continuation_arg *); 71098948Sobrien struct continuation_arg *arg_list; 71198948Sobrien struct continuation *next; 71298948Sobrien }; 71398948Sobrien 71498948Sobrien/* In infrun.c. */ 71598948Sobrienextern struct continuation *cmd_continuation; 71698948Sobrien/* Used only by the step_1 function. */ 71798948Sobrienextern struct continuation *intermediate_continuation; 71898948Sobrien 71998948Sobrien/* From utils.c */ 72098948Sobrienextern void add_continuation (void (*)(struct continuation_arg *), 72198948Sobrien struct continuation_arg *); 72298948Sobrienextern void do_all_continuations (void); 72398948Sobrienextern void discard_all_continuations (void); 72498948Sobrien 72598948Sobrienextern void add_intermediate_continuation (void (*)(struct continuation_arg *), 72698948Sobrien struct continuation_arg *); 72798948Sobrienextern void do_all_intermediate_continuations (void); 72898948Sobrienextern void discard_all_intermediate_continuations (void); 72998948Sobrien 73019370Spst/* String containing the current directory (what getwd would return). */ 73119370Spst 73219370Spstextern char *current_directory; 73319370Spst 73419370Spst/* Default radixes for input and output. Only some values supported. */ 73519370Spstextern unsigned input_radix; 73619370Spstextern unsigned output_radix; 73719370Spst 73819370Spst/* Possibilities for prettyprint parameters to routines which print 73919370Spst things. Like enum language, this should be in value.h, but needs 74019370Spst to be here for the same reason. FIXME: If we can eliminate this 74119370Spst as an arg to LA_VAL_PRINT, then we can probably move it back to 74219370Spst value.h. */ 74319370Spst 74419370Spstenum val_prettyprint 74598948Sobrien { 74698948Sobrien Val_no_prettyprint = 0, 74798948Sobrien Val_prettyprint, 74898948Sobrien /* Use the default setting which the user has specified. */ 74998948Sobrien Val_pretty_default 75098948Sobrien }; 75119370Spst 75298948Sobrien/* The ptid struct is a collection of the various "ids" necessary 75398948Sobrien for identifying the inferior. This consists of the process id 75498948Sobrien (pid), thread id (tid), and other fields necessary for uniquely 75598948Sobrien identifying the inferior process/thread being debugged. When 75698948Sobrien manipulating ptids, the constructors, accessors, and predicate 75798948Sobrien declared in inferior.h should be used. These are as follows: 75898948Sobrien 75998948Sobrien ptid_build - Make a new ptid from a pid, lwp, and tid. 76098948Sobrien pid_to_ptid - Make a new ptid from just a pid. 76198948Sobrien ptid_get_pid - Fetch the pid component of a ptid. 76298948Sobrien ptid_get_lwp - Fetch the lwp component of a ptid. 76398948Sobrien ptid_get_tid - Fetch the tid component of a ptid. 76498948Sobrien ptid_equal - Test to see if two ptids are equal. 76598948Sobrien 76698948Sobrien Please do NOT access the struct ptid members directly (except, of 76798948Sobrien course, in the implementation of the above ptid manipulation 76898948Sobrien functions). */ 76998948Sobrien 77098948Sobrienstruct ptid 77198948Sobrien { 77298948Sobrien /* Process id */ 77398948Sobrien int pid; 77498948Sobrien 77598948Sobrien /* Lightweight process id */ 77698948Sobrien long lwp; 77798948Sobrien 77898948Sobrien /* Thread id */ 77998948Sobrien long tid; 78098948Sobrien }; 78198948Sobrien 78298948Sobrientypedef struct ptid ptid_t; 78398948Sobrien 78419370Spst 78519370Spst 78698948Sobrien/* Optional host machine definition. Pure autoconf targets will not 78798948Sobrien need a "xm.h" file. This will be a symlink to one of the xm-*.h 78898948Sobrien files, built by the `configure' script. */ 78998948Sobrien 79098948Sobrien#ifdef GDB_XM_FILE 79119370Spst#include "xm.h" 79298948Sobrien#endif 79319370Spst 79498948Sobrien/* Optional native machine support. Non-native (and possibly pure 79598948Sobrien multi-arch) targets do not need a "nm.h" file. This will be a 79698948Sobrien symlink to one of the nm-*.h files, built by the `configure' 79798948Sobrien script. */ 79819370Spst 79998948Sobrien#ifdef GDB_NM_FILE 80019370Spst#include "nm.h" 80198948Sobrien#endif 80219370Spst 80398948Sobrien/* Optional target machine definition. Pure multi-arch configurations 80498948Sobrien do not need a "tm.h" file. This will be a symlink to one of the 80519370Spst tm-*.h files, built by the `configure' script. */ 80619370Spst 80798948Sobrien#ifdef GDB_TM_FILE 80819370Spst#include "tm.h" 80998948Sobrien#endif 81019370Spst 81119370Spst/* If the xm.h file did not define the mode string used to open the 81219370Spst files, assume that binary files are opened the same way as text 81319370Spst files */ 81419370Spst#ifndef FOPEN_RB 81519370Spst#include "fopen-same.h" 81619370Spst#endif 81719370Spst 81846283Sdfr/* Defaults for system-wide constants (if not defined by xm.h, we fake it). 81946283Sdfr FIXME: Assumes 2's complement arithmetic */ 82019370Spst 82119370Spst#if !defined (UINT_MAX) 82298948Sobrien#define UINT_MAX ((unsigned int)(~0)) /* 0xFFFFFFFF for 32-bits */ 82319370Spst#endif 82419370Spst 82519370Spst#if !defined (INT_MAX) 82698948Sobrien#define INT_MAX ((int)(UINT_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */ 82719370Spst#endif 82819370Spst 82919370Spst#if !defined (INT_MIN) 83046283Sdfr#define INT_MIN ((int)((int) ~0 ^ INT_MAX)) /* 0x80000000 for 32-bits */ 83119370Spst#endif 83219370Spst 83319370Spst#if !defined (ULONG_MAX) 83419370Spst#define ULONG_MAX ((unsigned long)(~0L)) /* 0xFFFFFFFF for 32-bits */ 83519370Spst#endif 83619370Spst 83719370Spst#if !defined (LONG_MAX) 83819370Spst#define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */ 83919370Spst#endif 84019370Spst 84198948Sobrien#if !defined (ULONGEST_MAX) 84298948Sobrien#define ULONGEST_MAX (~(ULONGEST)0) /* 0xFFFFFFFFFFFFFFFF for 64-bits */ 84398948Sobrien#endif 84446283Sdfr 84598948Sobrien#if !defined (LONGEST_MAX) /* 0x7FFFFFFFFFFFFFFF for 64-bits */ 84698948Sobrien#define LONGEST_MAX ((LONGEST)(ULONGEST_MAX >> 1)) 84798948Sobrien#endif 84819370Spst 84919370Spst/* Convert a LONGEST to an int. This is used in contexts (e.g. number of 85019370Spst arguments to a function, number in a value history, register number, etc.) 85119370Spst where the value must not be larger than can fit in an int. */ 85219370Spst 85398948Sobrienextern int longest_to_int (LONGEST); 85419370Spst 85519370Spst/* Assorted functions we can declare, now that const and volatile are 85619370Spst defined. */ 85719370Spst 85898948Sobrienextern char *savestring (const char *, size_t); 85919370Spst 86098948Sobrienextern char *msavestring (void *, const char *, size_t); 86119370Spst 86298948Sobrienextern char *mstrsave (void *, const char *); 86319370Spst 86498948Sobrien/* Robust versions of same. Throw an internal error when no memory, 86598948Sobrien guard against stray NULL arguments. */ 86698948Sobrienextern void *xmmalloc (void *md, size_t size); 86798948Sobrienextern void *xmrealloc (void *md, void *ptr, size_t size); 86898948Sobrienextern void *xmcalloc (void *md, size_t number, size_t size); 86998948Sobrienextern void xmfree (void *md, void *ptr); 87019370Spst 87198948Sobrien/* xmalloc(), xrealloc() and xcalloc() have already been declared in 87298948Sobrien "libiberty.h". */ 87398948Sobrienextern void xfree (void *); 87446283Sdfr 875130809Smarcel/* Utility macros to allocate typed memory. Avoids errors like: 876130809Smarcel struct foo *foo = xmalloc (sizeof struct bar); and memset (foo, 877130809Smarcel sizeof (struct foo), 0). */ 878130809Smarcel#define XZALLOC(TYPE) ((TYPE*) memset (xmalloc (sizeof (TYPE)), 0, sizeof (TYPE))) 879130809Smarcel#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE))) 880130809Smarcel#define XCALLOC(NMEMB, TYPE) ((TYPE*) xcalloc ((NMEMB), sizeof (TYPE))) 881130809Smarcel 88298948Sobrien/* Like asprintf/vasprintf but get an internal_error if the call 88398948Sobrien fails. */ 88498948Sobrienextern void xasprintf (char **ret, const char *format, ...) ATTR_FORMAT (printf, 2, 3); 88598948Sobrienextern void xvasprintf (char **ret, const char *format, va_list ap); 88619370Spst 887130809Smarcel/* Like asprintf, but return the string, throw an error if no memory. */ 888130809Smarcelextern char *xstrprintf (const char *format, ...) ATTR_FORMAT (printf, 1, 2); 889130809Smarcel 89098948Sobrienextern int parse_escape (char **); 89119370Spst 89219370Spst/* Message to be printed before the error message, when an error occurs. */ 89319370Spst 89419370Spstextern char *error_pre_print; 89519370Spst 89619370Spst/* Message to be printed before the error message, when an error occurs. */ 89719370Spst 89819370Spstextern char *quit_pre_print; 89919370Spst 90019370Spst/* Message to be printed before the warning message, when a warning occurs. */ 90119370Spst 90219370Spstextern char *warning_pre_print; 90319370Spst 90498948Sobrienextern NORETURN void verror (const char *fmt, va_list ap) ATTR_NORETURN; 90519370Spst 906130809Smarcelextern NORETURN void error (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2); 90719370Spst 908130809Smarcelextern NORETURN void error_silent (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2); 909130809Smarcel 91098948Sobrienextern NORETURN void error_stream (struct ui_file *) ATTR_NORETURN; 91119370Spst 912130809Smarcel/* Initialize the error buffer. */ 913130809Smarcelextern void error_init (void); 914130809Smarcel 91598948Sobrien/* Returns a freshly allocate buffer containing the last error 91698948Sobrien message. */ 91798948Sobrienextern char *error_last_message (void); 91819370Spst 919130809Smarcel/* Output arbitrary error message. */ 920130809Smarcelextern void error_output_message (char *pre_print, char *msg); 921130809Smarcel 92298948Sobrienextern NORETURN void internal_verror (const char *file, int line, 92398948Sobrien const char *, va_list ap) ATTR_NORETURN; 92419370Spst 92598948Sobrienextern NORETURN void internal_error (const char *file, int line, 92698948Sobrien const char *, ...) ATTR_NORETURN ATTR_FORMAT (printf, 3, 4); 92719370Spst 928130809Smarcelextern void internal_vwarning (const char *file, int line, 929130809Smarcel const char *, va_list ap); 930130809Smarcel 931130809Smarcelextern void internal_warning (const char *file, int line, 932130809Smarcel const char *, ...) ATTR_FORMAT (printf, 3, 4); 933130809Smarcel 93498948Sobrienextern NORETURN void nomem (long) ATTR_NORETURN; 93598948Sobrien 93698948Sobrien/* Reasons for calling throw_exception(). NOTE: all reason values 93798948Sobrien must be less than zero. enum value 0 is reserved for internal use 93898948Sobrien as the return value from an initial setjmp(). The function 93998948Sobrien catch_exceptions() reserves values >= 0 as legal results from its 94098948Sobrien wrapped function. */ 94198948Sobrien 94298948Sobrienenum return_reason 94398948Sobrien { 94498948Sobrien /* User interrupt. */ 94598948Sobrien RETURN_QUIT = -2, 94698948Sobrien /* Any other error. */ 94798948Sobrien RETURN_ERROR 94898948Sobrien }; 94998948Sobrien 95098948Sobrien#define ALL_CLEANUPS ((struct cleanup *)0) 95198948Sobrien 95298948Sobrien#define RETURN_MASK(reason) (1 << (int)(-reason)) 95398948Sobrien#define RETURN_MASK_QUIT RETURN_MASK (RETURN_QUIT) 95498948Sobrien#define RETURN_MASK_ERROR RETURN_MASK (RETURN_ERROR) 95598948Sobrien#define RETURN_MASK_ALL (RETURN_MASK_QUIT | RETURN_MASK_ERROR) 95619370Spsttypedef int return_mask; 95719370Spst 95898948Sobrien/* Throw an exception of type RETURN_REASON. Will execute a LONG JUMP 95998948Sobrien to the inner most containing exception handler established using 96098948Sobrien catch_exceptions() (or the legacy catch_errors()). 96119370Spst 96298948Sobrien Code normally throws an exception using error() et.al. For various 96398948Sobrien reaons, GDB also contains code that throws an exception directly. 96498948Sobrien For instance, the remote*.c targets contain CNTRL-C signal handlers 96598948Sobrien that propogate the QUIT event up the exception chain. ``This could 96698948Sobrien be a good thing or a dangerous thing.'' -- the Existential Wombat. */ 96719370Spst 96898948Sobrienextern NORETURN void throw_exception (enum return_reason) ATTR_NORETURN; 96919370Spst 97098948Sobrien/* Call FUNC(UIOUT, FUNC_ARGS) but wrapped within an exception 97198948Sobrien handler. If an exception (enum return_reason) is thrown using 97298948Sobrien throw_exception() than all cleanups installed since 97398948Sobrien catch_exceptions() was entered are invoked, the (-ve) exception 97498948Sobrien value is then returned by catch_exceptions. If FUNC() returns 97598948Sobrien normally (with a postive or zero return value) then that value is 97698948Sobrien returned by catch_exceptions(). It is an internal_error() for 97798948Sobrien FUNC() to return a negative value. 97819370Spst 97998948Sobrien For the period of the FUNC() call: UIOUT is installed as the output 98098948Sobrien builder; ERRSTRING is installed as the error/quit message; and a 98198948Sobrien new cleanup_chain is established. The old values are restored 98298948Sobrien before catch_exceptions() returns. 98398948Sobrien 984130809Smarcel The variant catch_exceptions_with_msg() is the same as 985130809Smarcel catch_exceptions() but adds the ability to return an allocated 986130809Smarcel copy of the gdb error message. This is used when a silent error is 987130809Smarcel issued and the caller wants to manually issue the error message. 988130809Smarcel 98998948Sobrien FIXME; cagney/2001-08-13: The need to override the global UIOUT 99098948Sobrien builder variable should just go away. 99198948Sobrien 99298948Sobrien This function superseeds catch_errors(). 99398948Sobrien 99498948Sobrien This function uses SETJMP() and LONGJUMP(). */ 99598948Sobrien 99698948Sobrienstruct ui_out; 99798948Sobrientypedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args); 99898948Sobrienextern int catch_exceptions (struct ui_out *uiout, 99998948Sobrien catch_exceptions_ftype *func, void *func_args, 100098948Sobrien char *errstring, return_mask mask); 1001130809Smarcelextern int catch_exceptions_with_msg (struct ui_out *uiout, 1002130809Smarcel catch_exceptions_ftype *func, 1003130809Smarcel void *func_args, 1004130809Smarcel char *errstring, char **gdberrmsg, 1005130809Smarcel return_mask mask); 100698948Sobrien 100798948Sobrien/* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero 100898948Sobrien otherwize the result from CATCH_ERRORS_FTYPE is returned. It is 100998948Sobrien probably useful for CATCH_ERRORS_FTYPE to always return a non-zero 101098948Sobrien value. It's unfortunate that, catch_errors() does not return an 101198948Sobrien indication of the exact exception that it caught - quit_flag might 101298948Sobrien help. 101398948Sobrien 101498948Sobrien This function is superseeded by catch_exceptions(). */ 101598948Sobrien 1016130809Smarceltypedef int (catch_errors_ftype) (void *); 101798948Sobrienextern int catch_errors (catch_errors_ftype *, void *, char *, return_mask); 101898948Sobrien 101998948Sobrien/* Template to catch_errors() that wraps calls to command 102098948Sobrien functions. */ 102198948Sobrien 102298948Sobrientypedef void (catch_command_errors_ftype) (char *, int); 102398948Sobrienextern int catch_command_errors (catch_command_errors_ftype *func, char *command, int from_tty, return_mask); 102498948Sobrien 102598948Sobrienextern void warning (const char *, ...) ATTR_FORMAT (printf, 1, 2); 102698948Sobrien 102798948Sobrienextern void vwarning (const char *, va_list args); 102898948Sobrien 1029130809Smarcel/* List of known OS ABIs. If you change this, make sure to update the 1030130809Smarcel table in osabi.c. */ 1031130809Smarcelenum gdb_osabi 1032130809Smarcel{ 1033130809Smarcel GDB_OSABI_UNINITIALIZED = -1, /* For struct gdbarch_info. */ 1034130809Smarcel 1035130809Smarcel GDB_OSABI_UNKNOWN = 0, /* keep this zero */ 1036130809Smarcel 1037130809Smarcel GDB_OSABI_SVR4, 1038130809Smarcel GDB_OSABI_HURD, 1039130809Smarcel GDB_OSABI_SOLARIS, 1040130809Smarcel GDB_OSABI_OSF1, 1041130809Smarcel GDB_OSABI_LINUX, 1042130809Smarcel GDB_OSABI_FREEBSD_AOUT, 1043130809Smarcel GDB_OSABI_FREEBSD_ELF, 1044130809Smarcel GDB_OSABI_NETBSD_AOUT, 1045130809Smarcel GDB_OSABI_NETBSD_ELF, 1046130809Smarcel GDB_OSABI_OPENBSD_ELF, 1047130809Smarcel GDB_OSABI_WINCE, 1048130809Smarcel GDB_OSABI_GO32, 1049130809Smarcel GDB_OSABI_NETWARE, 1050130809Smarcel GDB_OSABI_IRIX, 1051130809Smarcel GDB_OSABI_LYNXOS, 1052130809Smarcel GDB_OSABI_INTERIX, 1053130809Smarcel GDB_OSABI_HPUX_ELF, 1054130809Smarcel GDB_OSABI_HPUX_SOM, 1055130809Smarcel 1056130809Smarcel GDB_OSABI_ARM_EABI_V1, 1057130809Smarcel GDB_OSABI_ARM_EABI_V2, 1058130809Smarcel GDB_OSABI_ARM_APCS, 1059130809Smarcel GDB_OSABI_QNXNTO, 1060130809Smarcel 1061130809Smarcel GDB_OSABI_CYGWIN, 1062130809Smarcel 1063130809Smarcel GDB_OSABI_INVALID /* keep this last */ 1064130809Smarcel}; 1065130809Smarcel 106619370Spst/* Global functions from other, non-gdb GNU thingies. 106719370Spst Libiberty thingies are no longer declared here. We include libiberty.h 106819370Spst above, instead. */ 106919370Spst 107019370Spst#ifndef GETENV_PROVIDED 107198948Sobrienextern char *getenv (const char *); 107219370Spst#endif 107319370Spst 107419370Spst/* From other system libraries */ 107519370Spst 107646283Sdfr#ifdef HAVE_STDDEF_H 107719370Spst#include <stddef.h> 107846283Sdfr#endif 107946283Sdfr 108046283Sdfr#ifdef HAVE_STDLIB_H 108119370Spst#include <stdlib.h> 108219370Spst#endif 108346283Sdfr#ifndef min 108446283Sdfr#define min(a, b) ((a) < (b) ? (a) : (b)) 108546283Sdfr#endif 108646283Sdfr#ifndef max 108746283Sdfr#define max(a, b) ((a) > (b) ? (a) : (b)) 108846283Sdfr#endif 108919370Spst 109019370Spst 109119370Spst/* We take the address of fclose later, but some stdio's forget 109219370Spst to declare this. We can't always declare it since there's 109319370Spst no way to declare the parameters without upsetting some compiler 109419370Spst somewhere. */ 109519370Spst 109619370Spst#ifndef FCLOSE_PROVIDED 109798948Sobrienextern int fclose (FILE *); 109819370Spst#endif 109919370Spst 110019370Spst#ifndef atof 110198948Sobrienextern double atof (const char *); /* X3.159-1989 4.10.1.1 */ 110219370Spst#endif 110319370Spst 110419370Spst/* Various possibilities for alloca. */ 110519370Spst#ifndef alloca 110698948Sobrien#ifdef __GNUC__ 110798948Sobrien#define alloca __builtin_alloca 110898948Sobrien#else /* Not GNU C */ 110998948Sobrien#ifdef HAVE_ALLOCA_H 111098948Sobrien#include <alloca.h> 111198948Sobrien#else 111298948Sobrien#ifdef _AIX 111398948Sobrien#pragma alloca 111498948Sobrien#else 111519370Spst 111619370Spst/* We need to be careful not to declare this in a way which conflicts with 111719370Spst bison. Bison never declares it as char *, but under various circumstances 111819370Spst (like __hpux) we need to use void *. */ 111998948Sobrienextern void *alloca (); 112098948Sobrien#endif /* Not _AIX */ 112198948Sobrien#endif /* Not HAVE_ALLOCA_H */ 112298948Sobrien#endif /* Not GNU C */ 112319370Spst#endif /* alloca not defined */ 112419370Spst 1125130809Smarcel/* Is GDB multi-arch? If there's a "tm.h" file, it is not. */ 1126130809Smarcel#ifndef GDB_MULTI_ARCH 1127130809Smarcel#ifdef GDB_TM_FILE 1128130809Smarcel#define GDB_MULTI_ARCH GDB_MULTI_ARCH_PARTIAL 1129130809Smarcel#else 1130130809Smarcel#define GDB_MULTI_ARCH GDB_MULTI_ARCH_PURE 1131130809Smarcel#endif 1132130809Smarcel#endif 1133130809Smarcel 113446283Sdfr/* Dynamic target-system-dependent parameters for GDB. */ 113546283Sdfr#include "gdbarch.h" 113619370Spst 1137130809Smarcel/* Maximum size of a register. Something small, but large enough for 1138130809Smarcel all known ISAs. If it turns out to be too small, make it bigger. */ 1139130809Smarcel 1140130809Smarcelenum { MAX_REGISTER_SIZE = 16 }; 1141130809Smarcel 114246283Sdfr/* Static target-system-dependent parameters for GDB. */ 114319370Spst 114419370Spst/* Number of bits in a char or unsigned char for the target machine. 114519370Spst Just like CHAR_BIT in <limits.h> but describes the target machine. */ 114619370Spst#if !defined (TARGET_CHAR_BIT) 114719370Spst#define TARGET_CHAR_BIT 8 114819370Spst#endif 114919370Spst 115019370Spst/* If we picked up a copy of CHAR_BIT from a configuration file 115119370Spst (which may get it by including <limits.h>) then use it to set 115219370Spst the number of bits in a host char. If not, use the same size 115319370Spst as the target. */ 115419370Spst 115519370Spst#if defined (CHAR_BIT) 115619370Spst#define HOST_CHAR_BIT CHAR_BIT 115719370Spst#else 115819370Spst#define HOST_CHAR_BIT TARGET_CHAR_BIT 115919370Spst#endif 116019370Spst 116119370Spst/* The bit byte-order has to do just with numbering of bits in 116219370Spst debugging symbols and such. Conceptually, it's quite separate 116319370Spst from byte/word byte order. */ 116419370Spst 116519370Spst#if !defined (BITS_BIG_ENDIAN) 116698948Sobrien#define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) 116746283Sdfr#endif 116819370Spst 116919370Spst/* In findvar.c. */ 117019370Spst 1171130809Smarcelextern LONGEST extract_signed_integer (const void *, int); 117219370Spst 1173130809Smarcelextern ULONGEST extract_unsigned_integer (const void *, int); 117419370Spst 1175130809Smarcelextern int extract_long_unsigned_integer (const void *, int, LONGEST *); 117619370Spst 1177130809Smarcelextern CORE_ADDR extract_typed_address (const void *buf, struct type *type); 117819370Spst 117998948Sobrienextern void store_signed_integer (void *, int, LONGEST); 118019370Spst 118198948Sobrienextern void store_unsigned_integer (void *, int, ULONGEST); 118219370Spst 118398948Sobrienextern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr); 118446283Sdfr 118519370Spst 118619370Spst/* From valops.c */ 118719370Spst 118898948Sobrienextern CORE_ADDR push_bytes (CORE_ADDR, char *, int); 118919370Spst 119098948Sobrienextern CORE_ADDR push_word (CORE_ADDR, ULONGEST); 119119370Spst 119219370Spstextern int watchdog; 119319370Spst 119419370Spst/* Hooks for alternate command interfaces. */ 119519370Spst 119698948Sobrien/* The name of the interpreter if specified on the command line. */ 119798948Sobrienextern char *interpreter_p; 119898948Sobrien 119998948Sobrien/* If a given interpreter matches INTERPRETER_P then it should update 120098948Sobrien command_loop_hook and init_ui_hook with the per-interpreter 120198948Sobrien implementation. */ 120298948Sobrien/* FIXME: command_loop_hook and init_ui_hook should be moved here. */ 120398948Sobrien 120419370Spststruct target_waitstatus; 120519370Spststruct cmd_list_element; 120619370Spst 120798948Sobrien/* Should the asynchronous variant of the interpreter (using the 120898948Sobrien event-loop) be enabled? */ 120998948Sobrienextern int event_loop_p; 121019370Spst 121198948Sobrienextern void (*init_ui_hook) (char *argv0); 121298948Sobrienextern void (*command_loop_hook) (void); 121398948Sobrienextern void (*show_load_progress) (const char *section, 121498948Sobrien unsigned long section_sent, 121598948Sobrien unsigned long section_size, 121698948Sobrien unsigned long total_sent, 121798948Sobrien unsigned long total_size); 121898948Sobrienextern void (*print_frame_info_listing_hook) (struct symtab * s, 121998948Sobrien int line, int stopline, 122098948Sobrien int noerror); 122198948Sobrienextern struct frame_info *parse_frame_specification (char *frame_exp); 122298948Sobrienextern int (*query_hook) (const char *, va_list); 122398948Sobrienextern void (*warning_hook) (const char *, va_list); 122498948Sobrienextern void (*flush_hook) (struct ui_file * stream); 122598948Sobrienextern void (*create_breakpoint_hook) (struct breakpoint * b); 122698948Sobrienextern void (*delete_breakpoint_hook) (struct breakpoint * bpt); 122798948Sobrienextern void (*modify_breakpoint_hook) (struct breakpoint * bpt); 122898948Sobrienextern void (*interactive_hook) (void); 122998948Sobrienextern void (*registers_changed_hook) (void); 123098948Sobrienextern void (*readline_begin_hook) (char *,...); 123198948Sobrienextern char *(*readline_hook) (char *); 123298948Sobrienextern void (*readline_end_hook) (void); 123398948Sobrienextern void (*register_changed_hook) (int regno); 123498948Sobrienextern void (*memory_changed_hook) (CORE_ADDR addr, int len); 123598948Sobrienextern void (*context_hook) (int); 123698948Sobrienextern ptid_t (*target_wait_hook) (ptid_t ptid, 123798948Sobrien struct target_waitstatus * status); 123819370Spst 123998948Sobrienextern void (*attach_hook) (void); 124098948Sobrienextern void (*detach_hook) (void); 124198948Sobrienextern void (*call_command_hook) (struct cmd_list_element * c, 124298948Sobrien char *cmd, int from_tty); 124319370Spst 124498948Sobrienextern void (*set_hook) (struct cmd_list_element * c); 124519370Spst 124698948Sobrienextern NORETURN void (*error_hook) (void) ATTR_NORETURN; 124719370Spst 124898948Sobrienextern void (*error_begin_hook) (void); 124998948Sobrien 125098948Sobrienextern int (*ui_load_progress_hook) (const char *section, unsigned long num); 125198948Sobrien 125298948Sobrien 125319370Spst/* Inhibit window interface if non-zero. */ 125419370Spst 125519370Spstextern int use_windows; 125619370Spst 125719370Spst/* Symbolic definitions of filename-related things. */ 125819370Spst/* FIXME, this doesn't work very well if host and executable 125919370Spst filesystems conventions are different. */ 126019370Spst 126119370Spst#ifndef DIRNAME_SEPARATOR 126219370Spst#define DIRNAME_SEPARATOR ':' 126319370Spst#endif 126419370Spst 126519370Spst#ifndef SLASH_STRING 126619370Spst#define SLASH_STRING "/" 126719370Spst#endif 126819370Spst 126998948Sobrien#ifdef __MSDOS__ 127098948Sobrien# define CANT_FORK 127198948Sobrien# define GLOBAL_CURDIR 127219370Spst#endif 127319370Spst 127498948Sobrien/* Provide default definitions of PIDGET, TIDGET, and MERGEPID. 127598948Sobrien The name ``TIDGET'' is a historical accident. Many uses of TIDGET 127698948Sobrien in the code actually refer to a lightweight process id, i.e, 127798948Sobrien something that can be considered a process id in its own right for 127898948Sobrien certain purposes. */ 127946283Sdfr 128046283Sdfr#ifndef PIDGET 128198948Sobrien#define PIDGET(PTID) (ptid_get_pid (PTID)) 128298948Sobrien#define TIDGET(PTID) (ptid_get_lwp (PTID)) 128398948Sobrien#define MERGEPID(PID, TID) ptid_build (PID, TID, 0) 128446283Sdfr#endif 128546283Sdfr 128698948Sobrien/* Define well known filenos if the system does not define them. */ 128798948Sobrien#ifndef STDIN_FILENO 128898948Sobrien#define STDIN_FILENO 0 128946283Sdfr#endif 129098948Sobrien#ifndef STDOUT_FILENO 129198948Sobrien#define STDOUT_FILENO 1 129246283Sdfr#endif 129398948Sobrien#ifndef STDERR_FILENO 129498948Sobrien#define STDERR_FILENO 2 129598948Sobrien#endif 129646283Sdfr 129798948Sobrien/* If this definition isn't overridden by the header files, assume 129898948Sobrien that isatty and fileno exist on this system. */ 129998948Sobrien#ifndef ISATTY 130098948Sobrien#define ISATTY(FP) (isatty (fileno (FP))) 130198948Sobrien#endif 130298948Sobrien 1303130809Smarcel/* Ensure that V is aligned to an N byte boundary (B's assumed to be a 1304130809Smarcel power of 2). Round up/down when necessary. Examples of correct 1305130809Smarcel use include: 1306130809Smarcel 1307130809Smarcel addr = align_up (addr, 8); -- VALUE needs 8 byte alignment 1308130809Smarcel write_memory (addr, value, len); 1309130809Smarcel addr += len; 1310130809Smarcel 1311130809Smarcel and: 1312130809Smarcel 1313130809Smarcel sp = align_down (sp - len, 16); -- Keep SP 16 byte aligned 1314130809Smarcel write_memory (sp, value, len); 1315130809Smarcel 1316130809Smarcel Note that uses such as: 1317130809Smarcel 1318130809Smarcel write_memory (addr, value, len); 1319130809Smarcel addr += align_up (len, 8); 1320130809Smarcel 1321130809Smarcel and: 1322130809Smarcel 1323130809Smarcel sp -= align_up (len, 8); 1324130809Smarcel write_memory (sp, value, len); 1325130809Smarcel 1326130809Smarcel are typically not correct as they don't ensure that the address (SP 1327130809Smarcel or ADDR) is correctly aligned (relying on previous alignment to 1328130809Smarcel keep things right). This is also why the methods are called 1329130809Smarcel "align_..." instead of "round_..." as the latter reads better with 1330130809Smarcel this incorrect coding style. */ 1331130809Smarcel 1332130809Smarcelextern ULONGEST align_up (ULONGEST v, int n); 1333130809Smarcelextern ULONGEST align_down (ULONGEST v, int n); 1334130809Smarcel 133519370Spst#endif /* #ifndef DEFS_H */ 1336