10dcb205obrien/* *INDENT-OFF* */ /* ATTR_FORMAT confuses indent, avoid running it for now */
2d3bb418pst/* Basic, host-specific, and target-specific definitions for GDB.
30dcb205obrien   Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
478a152dmarcel   1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
5d3bb418pst   Free Software Foundation, Inc.
6d3bb418pst
70dcb205obrien   This file is part of GDB.
8d3bb418pst
90dcb205obrien   This program is free software; you can redistribute it and/or modify
100dcb205obrien   it under the terms of the GNU General Public License as published by
110dcb205obrien   the Free Software Foundation; either version 2 of the License, or
120dcb205obrien   (at your option) any later version.
13d3bb418pst
140dcb205obrien   This program is distributed in the hope that it will be useful,
150dcb205obrien   but WITHOUT ANY WARRANTY; without even the implied warranty of
160dcb205obrien   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
170dcb205obrien   GNU General Public License for more details.
18d3bb418pst
190dcb205obrien   You should have received a copy of the GNU General Public License
200dcb205obrien   along with this program; if not, write to the Free Software
210dcb205obrien   Foundation, Inc., 59 Temple Place - Suite 330,
220dcb205obrien   Boston, MA 02111-1307, USA.  */
239f7387dobrien
24d3bb418pst#ifndef DEFS_H
25d3bb418pst#define DEFS_H
26d3bb418pst
2778a152dmarcel#include "config.h"		/* Generated by configure.  */
2878a152dmarcel
29d3bb418pst#include <stdio.h>
3078a152dmarcel#include <errno.h>		/* System call error return status.  */
315d522dfdfr#include <limits.h>
325d522dfdfr
335d522dfdfr#ifdef HAVE_STDDEF_H
340dcb205obrien#include <stddef.h>
355d522dfdfr#else
3678a152dmarcel#include <sys/types.h>		/* For size_t.  */
370dcb205obrien#endif
380dcb205obrien
390dcb205obrien#ifdef HAVE_UNISTD_H
400dcb205obrien#include <unistd.h>
415d522dfdfr#endif
42d3bb418pst
4378a152dmarcel/* First include ansidecl.h so we can use the various macro definitions
4478a152dmarcel   here and in all subsequent file inclusions.  */
4578a152dmarcel
4678a152dmarcel#include "ansidecl.h"
4778a152dmarcel
4878a152dmarcel#include "gdb_locale.h"
4978a152dmarcel
5078a152dmarcel/* For ``enum target_signal''.  */
5178a152dmarcel#include "gdb/signals.h"
5278a152dmarcel
5378a152dmarcel/* Just in case they're not defined in stdio.h.  */
54d3bb418pst
55d3bb418pst#ifndef SEEK_SET
56d3bb418pst#define SEEK_SET 0
57d3bb418pst#endif
58d3bb418pst#ifndef SEEK_CUR
59d3bb418pst#define SEEK_CUR 1
60d3bb418pst#endif
61d3bb418pst
6278a152dmarcel#include <stdarg.h>		/* For va_list.  */
63d3bb418pst
64d3bb418pst#include "libiberty.h"
65d3bb418pst
66d3bb418pst/* For BFD64 and bfd_vma.  */
67d3bb418pst#include "bfd.h"
68d3bb418pst
690dcb205obrien
700dcb205obrien/* The target is partially multi-arched.  Both "tm.h" and the
710dcb205obrien   multi-arch vector provide definitions.  "tm.h" normally overrides
720dcb205obrien   the multi-arch vector (but there are a few exceptions).  */
730dcb205obrien
740dcb205obrien#define GDB_MULTI_ARCH_PARTIAL 1
750dcb205obrien
760dcb205obrien/* The target is partially multi-arched. Both the multi-arch vector
770dcb205obrien   and "tm.h" provide definitions. "tm.h" cannot override a definition
780dcb205obrien   provided by the multi-arch vector.  It is detected as a compilation
790dcb205obrien   error.
800dcb205obrien
810dcb205obrien   This setting is only useful during a multi-arch conversion. */
820dcb205obrien
830dcb205obrien#define GDB_MULTI_ARCH_TM 2
840dcb205obrien
850dcb205obrien/* The target is pure multi-arch.  The MULTI-ARCH vector provides all
860dcb205obrien   definitions.  "tm.h" is linked to an empty file. */
870dcb205obrien
880dcb205obrien#define GDB_MULTI_ARCH_PURE 3
890dcb205obrien
900dcb205obrien
910dcb205obrien
92d3bb418pst/* An address in the program being debugged.  Host byte order.  Rather
93d3bb418pst   than duplicate all the logic in BFD which figures out what type
94d3bb418pst   this is (long, long long, etc.) and whether it needs to be 64
95d3bb418pst   bits (the host/target interactions are subtle), we just use
96d3bb418pst   bfd_vma.  */
97d3bb418pst
98d3bb418psttypedef bfd_vma CORE_ADDR;
99d3bb418pst
1000dcb205obrien/* This is to make sure that LONGEST is at least as big as CORE_ADDR.  */
1010dcb205obrien
1020dcb205obrien#ifndef LONGEST
1030dcb205obrien
1040dcb205obrien#ifdef BFD64
1050dcb205obrien
1060dcb205obrien#define LONGEST BFD_HOST_64_BIT
1070dcb205obrien#define ULONGEST BFD_HOST_U_64_BIT
1080dcb205obrien
1090dcb205obrien#else /* No BFD64 */
1100dcb205obrien
1110dcb205obrien#ifdef CC_HAS_LONG_LONG
1120dcb205obrien#define LONGEST long long
1130dcb205obrien#define ULONGEST unsigned long long
1140dcb205obrien#else
1150dcb205obrien#ifdef BFD_HOST_64_BIT
1160dcb205obrien/* BFD_HOST_64_BIT is defined for some hosts that don't have long long
1170dcb205obrien   (e.g. i386-windows) so try it.  */
1180dcb205obrien#define LONGEST BFD_HOST_64_BIT
1190dcb205obrien#define ULONGEST BFD_HOST_U_64_BIT
1200dcb205obrien#else
1210dcb205obrien#define LONGEST long
1220dcb205obrien#define ULONGEST unsigned long
1230dcb205obrien#endif
1240dcb205obrien#endif
1250dcb205obrien
1260dcb205obrien#endif /* No BFD64 */
1270dcb205obrien
1280dcb205obrien#endif /* ! LONGEST */
1290dcb205obrien
1305d522dfdfr#ifndef min
131d3bb418pst#define min(a, b) ((a) < (b) ? (a) : (b))
1325d522dfdfr#endif
1335d522dfdfr#ifndef max
134d3bb418pst#define max(a, b) ((a) > (b) ? (a) : (b))
1355d522dfdfr#endif
136d3bb418pst
1370dcb205obrien/* Macros to do string compares.
1380dcb205obrien
1390dcb205obrien   NOTE: cagney/2000-03-14:
1400dcb205obrien
1410dcb205obrien   While old code can continue to refer to these macros, new code is
1420dcb205obrien   probably better off using strcmp() directly vis: ``strcmp() == 0''
1430dcb205obrien   and ``strcmp() != 0''.
1440dcb205obrien
1450dcb205obrien   This is because modern compilers can directly inline strcmp()
1460dcb205obrien   making the original justification for these macros - avoid function
1470dcb205obrien   call overhead by pre-testing the first characters
1480dcb205obrien   (``*X==*Y?...:0'') - redundant.
1490dcb205obrien
1500dcb205obrien   ``Even if [...] testing the first character does have a modest
1510dcb205obrien   performance improvement, I'd rather that whenever a performance
1520dcb205obrien   issue is found that we spend the effort on algorithmic
1530dcb205obrien   optimizations than micro-optimizing.'' J.T. */
154d3bb418pst
15578a152dmarcel/* NOTE: cagney/2003-11-23: All instances of STREQ[N] covered by
15678a152dmarcel   testing GDB on a stabs system have been replaced by equivalent
15778a152dmarcel   str[n]cmp calls.  To avoid the possability of introducing bugs when
15878a152dmarcel   making untested changes, the remaining references were deprecated
15978a152dmarcel   rather than replaced.  */
160d3bb418pst
16178a152dmarcel/* DISCLAIMER: cagney/2003-11-23: Simplified definition of these
16278a152dmarcel   macros so that they just map directly onto strcmp equivalent.  I'm
16378a152dmarcel   not responsible for any breakage due to code that relied on the old
16478a152dmarcel   underlying implementation.  */
16578a152dmarcel
16678a152dmarcel#define DEPRECATED_STREQ(a,b) (strcmp ((a), (b)) == 0)
16778a152dmarcel#define DEPRECATED_STREQN(a,b,c) (strncmp ((a), (b), (c)) == 0)
168d3bb418pst
169d3bb418pst/* Check if a character is one of the commonly used C++ marker characters.  */
1700dcb205obrienextern int is_cplus_marker (int);
171d3bb418pst
1725d522dfdfr/* enable xdb commands if set */
1735d522dfdfrextern int xdb_commands;
1745d522dfdfr
1755d522dfdfr/* enable dbx commands if set */
1765d522dfdfrextern int dbx_commands;
1775d522dfdfr
17878a152dmarcel/* System root path, used to find libraries etc.  */
17978a152dmarcelextern char *gdb_sysroot;
18078a152dmarcel
181d3bb418pstextern int quit_flag;
182d3bb418pstextern int immediate_quit;
183d3bb418pstextern int sevenbit_strings;
184d3bb418pst
1850dcb205obrienextern void quit (void);
1860dcb205obrien
1870dcb205obrien/* FIXME: cagney/2000-03-13: It has been suggested that the peformance
1880dcb205obrien   benefits of having a ``QUIT'' macro rather than a function are
1890dcb205obrien   marginal.  If the overhead of a QUIT function call is proving
1900dcb205obrien   significant then its calling frequency should probably be reduced
1910dcb205obrien   [kingdon].  A profile analyzing the current situtation is
1920dcb205obrien   needed. */
193d3bb418pst
1945d522dfdfr#ifdef QUIT
1955d522dfdfr/* do twice to force compiler warning */
1965d522dfdfr#define QUIT_FIXME "FIXME"
1975d522dfdfr#define QUIT_FIXME "ignoring redefinition of QUIT"
1985d522dfdfr#else
199d3bb418pst#define QUIT { \
200d3bb418pst  if (quit_flag) quit (); \
201d3bb418pst  if (interactive_hook) interactive_hook (); \
202d3bb418pst}
2035d522dfdfr#endif
204d3bb418pst
205d3bb418pst/* Languages represented in the symbol table and elsewhere.
206d3bb418pst   This should probably be in language.h, but since enum's can't
207d3bb418pst   be forward declared to satisfy opaque references before their
208d3bb418pst   actual definition, needs to be here. */
209d3bb418pst
2100dcb205obrienenum language
2110dcb205obrien  {
2120dcb205obrien    language_unknown,		/* Language not known */
2130dcb205obrien    language_auto,		/* Placeholder for automatic setting */
2140dcb205obrien    language_c,			/* C */
2150dcb205obrien    language_cplus,		/* C++ */
21678a152dmarcel    language_objc,		/* Objective-C */
2170dcb205obrien    language_java,		/* Java */
2180dcb205obrien    language_fortran,		/* Fortran */
2190dcb205obrien    language_m2,		/* Modula-2 */
2200dcb205obrien    language_asm,		/* Assembly language */
2210dcb205obrien    language_scm,    		/* Scheme / Guile */
22278a152dmarcel    language_pascal,		/* Pascal */
22378a152dmarcel    language_minimal		/* All other languages, minimal support only */
2240dcb205obrien  };
225d3bb418pst
2265d522dfdfrenum precision_type
2270dcb205obrien  {
2280dcb205obrien    single_precision,
2290dcb205obrien    double_precision,
2300dcb205obrien    unspecified_precision
2310dcb205obrien  };
2320dcb205obrien
23378a152dmarcel/* A generic, not quite boolean, enumeration.  */
23478a152dmarcelenum auto_boolean
23578a152dmarcel{
23678a152dmarcel  AUTO_BOOLEAN_TRUE,
23778a152dmarcel  AUTO_BOOLEAN_FALSE,
23878a152dmarcel  AUTO_BOOLEAN_AUTO
23978a152dmarcel};
24078a152dmarcel
24178a152dmarcel/* Potential ways that a function can return a value of a given type.  */
24278a152dmarcelenum return_value_convention
24378a152dmarcel{
24478a152dmarcel  /* Where the return value has been squeezed into one or more
24578a152dmarcel     registers.  */
24678a152dmarcel  RETURN_VALUE_REGISTER_CONVENTION,
24778a152dmarcel  /* Commonly known as the "struct return convention".  The caller
24878a152dmarcel     passes an additional hidden first parameter to the caller.  That
24978a152dmarcel     parameter contains the address at which the value being returned
25078a152dmarcel     should be stored.  While typically, and historically, used for
25178a152dmarcel     large structs, this is convention is applied to values of many
25278a152dmarcel     different types.  */
25378a152dmarcel  RETURN_VALUE_STRUCT_CONVENTION
25478a152dmarcel};
2550dcb205obrien
256d3bb418pst/* the cleanup list records things that have to be undone
257d3bb418pst   if an error happens (descriptors to be closed, memory to be freed, etc.)
258d3bb418pst   Each link in the chain records a function to call and an
259d3bb418pst   argument to give it.
260d3bb418pst
261d3bb418pst   Use make_cleanup to add an element to the cleanup chain.
262d3bb418pst   Use do_cleanups to do all cleanup actions back to a given
263d3bb418pst   point in the chain.  Use discard_cleanups to remove cleanups
264d3bb418pst   from the chain back to a given point, not doing them.  */
265d3bb418pst
266d3bb418pststruct cleanup
2670dcb205obrien  {
2680dcb205obrien    struct cleanup *next;
26978a152dmarcel    void (*function) (void *);
27078a152dmarcel    void *arg;
2710dcb205obrien  };
272d3bb418pst
273d3bb418pst
274d3bb418pst/* The ability to declare that a function never returns is useful, but
275d3bb418pst   not really required to compile GDB successfully, so the NORETURN and
276d3bb418pst   ATTR_NORETURN macros normally expand into nothing.  */
277d3bb418pst
278d3bb418pst/* If compiling with older versions of GCC, a function may be declared
279d3bb418pst   "volatile" to indicate that it does not return.  */
280d3bb418pst
281d3bb418pst#ifndef NORETURN
2820dcb205obrien#if defined(__GNUC__) \
283d3bb418pst     && (__GNUC__ == 1 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
2840dcb205obrien#define NORETURN volatile
2850dcb205obrien#else
2860dcb205obrien#define NORETURN		/* nothing */
2870dcb205obrien#endif
288d3bb418pst#endif
289d3bb418pst
290d3bb418pst/* GCC 2.5 and later versions define a function attribute "noreturn",
291d3bb418pst   which is the preferred way to declare that a function never returns.
292d3bb418pst   However GCC 2.7 appears to be the first version in which this fully
293d3bb418pst   works everywhere we use it. */
294d3bb418pst
295d3bb418pst#ifndef ATTR_NORETURN
2960dcb205obrien#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
2970dcb205obrien#define ATTR_NORETURN __attribute__ ((noreturn))
2980dcb205obrien#else
2990dcb205obrien#define ATTR_NORETURN		/* nothing */
3000dcb205obrien#endif
301d3bb418pst#endif
302d3bb418pst
303d3bb418pst#ifndef ATTR_FORMAT
3040dcb205obrien#if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4))
3050dcb205obrien#define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y)))
3060dcb205obrien#else
3070dcb205obrien#define ATTR_FORMAT(type, x, y)	/* nothing */
3080dcb205obrien#endif
309d3bb418pst#endif
310d3bb418pst
31178a152dmarcel/* Be conservative and use enum bitfields only with GCC.
31278a152dmarcel   This is copied from gcc 3.3.1, system.h.  */
31378a152dmarcel
31478a152dmarcel#if defined(__GNUC__) && (__GNUC__ >= 2)
31578a152dmarcel#define ENUM_BITFIELD(TYPE) enum TYPE
31678a152dmarcel#else
31778a152dmarcel#define ENUM_BITFIELD(TYPE) unsigned int
31878a152dmarcel#endif
31978a152dmarcel
320d3bb418pst/* Needed for various prototypes */
321d3bb418pst
322d3bb418pststruct symtab;
323d3bb418pststruct breakpoint;
32478a152dmarcelstruct frame_info;
325d3bb418pst
326d3bb418pst/* From blockframe.c */
327d3bb418pst
32878a152dmarcelextern int inside_entry_func (struct frame_info *this_frame);
329d3bb418pst
33078a152dmarcelextern int deprecated_inside_entry_file (CORE_ADDR addr);
331d3bb418pst
3320dcb205obrienextern int inside_main_func (CORE_ADDR pc);
333d3bb418pst
334d3bb418pst/* From utils.c */
335d3bb418pst
3360dcb205obrienextern void initialize_utils (void);
3375d522dfdfr
3380dcb205obrienextern void notice_quit (void);
339d3bb418pst
3400dcb205obrienextern int strcmp_iw (const char *, const char *);
341d3bb418pst
34278a152dmarcelextern int strcmp_iw_ordered (const char *, const char *);
34378a152dmarcel
34478a152dmarcelextern int streq (const char *, const char *);
34578a152dmarcel
3460dcb205obrienextern int subset_compare (char *, char *);
347d3bb418pst
3480dcb205obrienextern char *safe_strerror (int);
349d3bb418pst
3500dcb205obrienextern void init_malloc (void *);
351d3bb418pst
3520dcb205obrienextern void request_quit (int);
353d3bb418pst
3540dcb205obrienextern void do_cleanups (struct cleanup *);
3550dcb205obrienextern void do_final_cleanups (struct cleanup *);
3560dcb205obrienextern void do_run_cleanups (struct cleanup *);
3570dcb205obrienextern void do_exec_cleanups (struct cleanup *);
3580dcb205obrienextern void do_exec_error_cleanups (struct cleanup *);
3595d522dfdfr
3600dcb205obrienextern void discard_cleanups (struct cleanup *);
3610dcb205obrienextern void discard_final_cleanups (struct cleanup *);
3620dcb205obrienextern void discard_exec_error_cleanups (struct cleanup *);
3630dcb205obrienextern void discard_my_cleanups (struct cleanup **, struct cleanup *);
364d3bb418pst
3650dcb205obrien/* NOTE: cagney/2000-03-04: This typedef is strictly for the
3660dcb205obrien   make_cleanup function declarations below. Do not use this typedef
3670dcb205obrien   as a cast when passing functions into the make_cleanup() code.
3680dcb205obrien   Instead either use a bounce function or add a wrapper function.
3690dcb205obrien   Calling a f(char*) function with f(void*) is non-portable. */
3700dcb205obrientypedef void (make_cleanup_ftype) (void *);
371d3bb418pst
3720dcb205obrienextern struct cleanup *make_cleanup (make_cleanup_ftype *, void *);
373d3bb418pst
3740dcb205obrienextern struct cleanup *make_cleanup_freeargv (char **);
375d3bb418pst
3760dcb205obrienstruct ui_file;
3770dcb205obrienextern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *);
378d3bb418pst
3790dcb205obrienextern struct cleanup *make_cleanup_close (int fd);
380d3bb418pst
3810dcb205obrienextern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
382d3bb418pst
3830dcb205obrienextern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
384d3bb418pst
3850dcb205obrienextern struct cleanup *make_my_cleanup (struct cleanup **,
3860dcb205obrien					make_cleanup_ftype *, void *);
387d3bb418pst
3880dcb205obrienextern struct cleanup *make_run_cleanup (make_cleanup_ftype *, void *);
389d3bb418pst
3900dcb205obrienextern struct cleanup *make_exec_cleanup (make_cleanup_ftype *, void *);
3910dcb205obrienextern struct cleanup *make_exec_error_cleanup (make_cleanup_ftype *, void *);
3925d522dfdfr
3930dcb205obrienextern struct cleanup *save_cleanups (void);
3940dcb205obrienextern struct cleanup *save_final_cleanups (void);
3950dcb205obrienextern struct cleanup *save_my_cleanups (struct cleanup **);
3960dcb205obrien
3970dcb205obrienextern void restore_cleanups (struct cleanup *);
3980dcb205obrienextern void restore_final_cleanups (struct cleanup *);
3990dcb205obrienextern void restore_my_cleanups (struct cleanup **, struct cleanup *);
4000dcb205obrien
4010dcb205obrienextern void free_current_contents (void *);
4020dcb205obrien
4030dcb205obrienextern void null_cleanup (void *);
4040dcb205obrien
4050dcb205obrienextern int myread (int, char *, int);
4060dcb205obrien
4070dcb205obrienextern int query (const char *, ...) ATTR_FORMAT (printf, 1, 2);
40878a152dmarcelextern int nquery (const char *, ...) ATTR_FORMAT (printf, 1, 2);
40978a152dmarcelextern int yquery (const char *, ...) ATTR_FORMAT (printf, 1, 2);
4100dcb205obrien
4110dcb205obrienextern void init_page_info (void);
4120dcb205obrien
4130dcb205obrienextern char *gdb_realpath (const char *);
41478a152dmarcelextern char *xfullpath (const char *);
41578a152dmarcel
41678a152dmarcelextern unsigned long gnu_debuglink_crc32 (unsigned long crc,
41778a152dmarcel                                          unsigned char *buf, size_t len);
4185d522dfdfr
4195d522dfdfr/* From demangle.c */
4205d522dfdfr
4210dcb205obrienextern void set_demangling_style (char *);
4225d522dfdfr
4235d522dfdfr/* From tm.h */
4245d522dfdfr
4255d522dfdfrstruct type;
4260dcb205obrientypedef int (use_struct_convention_fn) (int gcc_p, struct type * value_type);
4275d522dfdfrextern use_struct_convention_fn generic_use_struct_convention;
4285d522dfdfr
429d3bb418pst
430d3bb418pst/* Annotation stuff.  */
431d3bb418pst
4320dcb205obrienextern int annotation_level;	/* in stack.c */
433d3bb418pst
4340dcb205obrienextern void begin_line (void);
4350dcb205obrien
4360dcb205obrienextern void wrap_here (char *);
4370dcb205obrien
4380dcb205obrienextern void reinitialize_more_filter (void);
4390dcb205obrien
4400dcb205obrien/* Normal results */
4410dcb205obrienextern struct ui_file *gdb_stdout;
44278a152dmarcel/* Input stream */
44378a152dmarcelextern struct ui_file *gdb_stdin;
4440dcb205obrien/* Serious error notifications */
4450dcb205obrienextern struct ui_file *gdb_stderr;
4460dcb205obrien/* Log/debug/trace messages that should bypass normal stdout/stderr
44778a152dmarcel   filtering.  For moment, always call this stream using
4480dcb205obrien   *_unfiltered. In the very near future that restriction shall be
4490dcb205obrien   removed - either call shall be unfiltered. (cagney 1999-06-13). */
4500dcb205obrienextern struct ui_file *gdb_stdlog;
4510dcb205obrien/* Target output that should bypass normal stdout/stderr filtering.
45278a152dmarcel   For moment, always call this stream using *_unfiltered. In the
4530dcb205obrien   very near future that restriction shall be removed - either call
4540dcb205obrien   shall be unfiltered. (cagney 1999-07-02). */
4550dcb205obrienextern struct ui_file *gdb_stdtarg;
45678a152dmarcelextern struct ui_file *gdb_stdtargerr;
45778a152dmarcelextern struct ui_file *gdb_stdtargin;
4585d522dfdfr
4590dcb205obrien#include "ui-file.h"
460d3bb418pst
4610dcb205obrien/* More generic printf like operations.  Filtered versions may return
4620dcb205obrien   non-locally on error.  */
463d3bb418pst
4640dcb205obrienextern void fputs_filtered (const char *, struct ui_file *);
465d3bb418pst
4660dcb205obrienextern void fputs_unfiltered (const char *, struct ui_file *);
467d3bb418pst
4680dcb205obrienextern int fputc_filtered (int c, struct ui_file *);
4695d522dfdfr
4700dcb205obrienextern int fputc_unfiltered (int c, struct ui_file *);
471d3bb418pst
4720dcb205obrienextern int putchar_filtered (int c);
473d3bb418pst
4740dcb205obrienextern int putchar_unfiltered (int c);
475d3bb418pst
4760dcb205obrienextern void puts_filtered (const char *);
477d3bb418pst
4780dcb205obrienextern void puts_unfiltered (const char *);
4795d522dfdfr
48078a152dmarcelextern void puts_filtered_tabular (char *string, int width, int right);
48178a152dmarcel
4820dcb205obrienextern void puts_debug (char *prefix, char *string, char *suffix);
483d3bb418pst
4840dcb205obrienextern void vprintf_filtered (const char *, va_list) ATTR_FORMAT (printf, 1, 0);
485d3bb418pst
4860dcb205obrienextern void vfprintf_filtered (struct ui_file *, const char *, va_list) ATTR_FORMAT (printf, 2, 0);
487d3bb418pst
4880dcb205obrienextern void fprintf_filtered (struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 2, 3);
489d3bb418pst
4900dcb205obrienextern void fprintfi_filtered (int, struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 3, 4);
491d3bb418pst
4920dcb205obrienextern void printf_filtered (const char *, ...) ATTR_FORMAT (printf, 1, 2);
493d3bb418pst
4940dcb205obrienextern void printfi_filtered (int, const char *, ...) ATTR_FORMAT (printf, 2, 3);
495d3bb418pst
4960dcb205obrienextern void vprintf_unfiltered (const char *, va_list) ATTR_FORMAT (printf, 1, 0);
497d3bb418pst
4980dcb205obrienextern void vfprintf_unfiltered (struct ui_file *, const char *, va_list) ATTR_FORMAT (printf, 2, 0);
499d3bb418pst
5000dcb205obrienextern void fprintf_unfiltered (struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 2, 3);
501d3bb418pst
5020dcb205obrienextern void printf_unfiltered (const char *, ...) ATTR_FORMAT (printf, 1, 2);
5035d522dfdfr
5040dcb205obrienextern void print_spaces (int, struct ui_file *);
5055d522dfdfr
5060dcb205obrienextern void print_spaces_filtered (int, struct ui_file *);
5075d522dfdfr
5080dcb205obrienextern char *n_spaces (int);
5095d522dfdfr
5100dcb205obrienextern void fputstr_filtered (const char *str, int quotr, struct ui_file * stream);
5115d522dfdfr
5120dcb205obrienextern void fputstr_unfiltered (const char *str, int quotr, struct ui_file * stream);
513d3bb418pst
5140dcb205obrienextern void fputstrn_unfiltered (const char *str, int n, int quotr, struct ui_file * stream);
515d3bb418pst
5160dcb205obrien/* Display the host ADDR on STREAM formatted as ``0x%x''. */
51778a152dmarcelextern void gdb_print_host_address (const void *addr, struct ui_file *stream);
518d3bb418pst
5190dcb205obrien/* Convert a CORE_ADDR into a HEX string.  paddr() is like %08lx.
5200dcb205obrien   paddr_nz() is like %lx.  paddr_u() is like %lu. paddr_width() is
5210dcb205obrien   for ``%*''. */
5220dcb205obrienextern int strlen_paddr (void);
5230dcb205obrienextern char *paddr (CORE_ADDR addr);
5240dcb205obrienextern char *paddr_nz (CORE_ADDR addr);
5250dcb205obrienextern char *paddr_u (CORE_ADDR addr);
5260dcb205obrienextern char *paddr_d (LONGEST addr);
527d3bb418pst
5280dcb205obrienextern char *phex (ULONGEST l, int sizeof_l);
5290dcb205obrienextern char *phex_nz (ULONGEST l, int sizeof_l);
530d3bb418pst
5310dcb205obrien/* Like paddr() only print/scan raw CORE_ADDR.  The output from
5320dcb205obrien   core_addr_to_string() can be passed direct to
5330dcb205obrien   string_to_core_addr().  */
5340dcb205obrienextern const char *core_addr_to_string (const CORE_ADDR addr);
5350dcb205obrienextern const char *core_addr_to_string_nz (const CORE_ADDR addr);
5360dcb205obrienextern CORE_ADDR string_to_core_addr (const char *my_string);
5375d522dfdfr
5380dcb205obrienextern void fprintf_symbol_filtered (struct ui_file *, char *,
5390dcb205obrien				     enum language, int);
5405d522dfdfr
5410dcb205obrienextern NORETURN void perror_with_name (const char *) ATTR_NORETURN;
5425d522dfdfr
5430dcb205obrienextern void print_sys_errmsg (const char *, int);
544d3bb418pst
545d3bb418pst/* From regex.c or libc.  BSD 4.4 declares this with the argument type as
546d3bb418pst   "const char *" in unistd.h, so we can't declare the argument
547d3bb418pst   as "char *".  */
548d3bb418pst
5490dcb205obrienextern char *re_comp (const char *);
550d3bb418pst
551d3bb418pst/* From symfile.c */
552d3bb418pst
5530dcb205obrienextern void symbol_file_command (char *, int);
5540dcb205obrien
5550dcb205obrien/* Remote targets may wish to use this as their load function.  */
5560dcb205obrienextern void generic_load (char *name, int from_tty);
5570dcb205obrien
5580dcb205obrien/* Summarise a download */
5590dcb205obrienextern void print_transfer_performance (struct ui_file *stream,
5600dcb205obrien					unsigned long data_count,
5610dcb205obrien					unsigned long write_count,
5620dcb205obrien					unsigned long time_count);
563d3bb418pst
564d3bb418pst/* From top.c */
565d3bb418pst
5660dcb205obrientypedef void initialize_file_ftype (void);
5670dcb205obrien
5680dcb205obrienextern char *skip_quoted (char *);
569d3bb418pst
5700dcb205obrienextern char *gdb_readline (char *);
571d3bb418pst
57278a152dmarcelextern char *gdb_readline_wrapper (char *);
57378a152dmarcel
5740dcb205obrienextern char *command_line_input (char *, int, char *);
575d3bb418pst
5760dcb205obrienextern void print_prompt (void);
577d3bb418pst
5780dcb205obrienextern int input_from_terminal_p (void);
579d3bb418pst
580d3bb418pstextern int info_verbose;
581d3bb418pst
582d3bb418pst/* From printcmd.c */
583d3bb418pst
5840dcb205obrienextern void set_next_address (CORE_ADDR);
585d3bb418pst
5860dcb205obrienextern void print_address_symbolic (CORE_ADDR, struct ui_file *, int,
5870dcb205obrien				    char *);
588d3bb418pst
5890dcb205obrienextern int build_address_symbolic (CORE_ADDR addr,
5900dcb205obrien				   int do_demangle,
5910dcb205obrien				   char **name,
5920dcb205obrien				   int *offset,
5930dcb205obrien				   char **filename,
5940dcb205obrien				   int *line,
5950dcb205obrien				   int *unmapped);
596d3bb418pst
5970dcb205obrienextern void print_address_numeric (CORE_ADDR, int, struct ui_file *);
5980dcb205obrien
5990dcb205obrienextern void print_address (CORE_ADDR, struct ui_file *);
600d3bb418pst
601d3bb418pst/* From source.c */
602d3bb418pst
6030dcb205obrienextern int openp (const char *, int, const char *, int, int, char **);
6040dcb205obrien
6050dcb205obrienextern int source_full_path_of (char *, char **);
6060dcb205obrien
6070dcb205obrienextern void mod_path (char *, char **);
6080dcb205obrien
60978a152dmarcelextern void add_path (char *, char **, int);
61078a152dmarcel
6110dcb205obrienextern void directory_command (char *, int);
612d3bb418pst
61378a152dmarcelextern char *source_path;
61478a152dmarcel
6150dcb205obrienextern void init_source_path (void);
6165d522dfdfr
61778a152dmarcelextern void init_last_source_visited (void);
61878a152dmarcel
6190dcb205obrienextern char *symtab_to_filename (struct symtab *);
620d3bb418pst
6210dcb205obrien/* From exec.c */
622d3bb418pst
6230dcb205obrienextern void exec_set_section_offsets (bfd_signed_vma text_off,
6240dcb205obrien				      bfd_signed_vma data_off,
6250dcb205obrien				      bfd_signed_vma bss_off);
626d3bb418pst
6270dcb205obrien/* Take over the 'find_mapped_memory' vector from exec.c. */
6280dcb205obrienextern void exec_set_find_memory_regions (int (*) (int (*) (CORE_ADDR,
6290dcb205obrien							    unsigned long,
6300dcb205obrien							    int, int, int,
6310dcb205obrien							    void *),
6320dcb205obrien						   void *));
633d3bb418pst
6340dcb205obrien/* Possible lvalue types.  Like enum language, this should be in
6350dcb205obrien   value.h, but needs to be here for the same reason. */
6360dcb205obrien
6370dcb205obrienenum lval_type
6380dcb205obrien  {
6390dcb205obrien    /* Not an lval. */
6400dcb205obrien    not_lval,
6410dcb205obrien    /* In memory.  Could be a saved register.  */
6420dcb205obrien    lval_memory,
6430dcb205obrien    /* In a register.  */
6440dcb205obrien    lval_register,
6450dcb205obrien    /* In a gdb internal variable.  */
6460dcb205obrien    lval_internalvar,
6470dcb205obrien    /* Part of a gdb internal variable (structure field).  */
6480dcb205obrien    lval_internalvar_component,
6490dcb205obrien    /* In a register series in a frame not the current one, which may have been
6500dcb205obrien       partially saved or saved in different places (otherwise would be
6510dcb205obrien       lval_register or lval_memory).  */
6520dcb205obrien    lval_reg_frame_relative
6530dcb205obrien  };
6540dcb205obrien
655d3bb418pst/* Control types for commands */
656d3bb418pst
657d3bb418pstenum misc_command_type
6580dcb205obrien  {
6590dcb205obrien    ok_command,
6600dcb205obrien    end_command,
6610dcb205obrien    else_command,
6620dcb205obrien    nop_command
6630dcb205obrien  };
664d3bb418pst
665d3bb418pstenum command_control_type
6660dcb205obrien  {
6670dcb205obrien    simple_control,
6680dcb205obrien    break_control,
6690dcb205obrien    continue_control,
6700dcb205obrien    while_control,
6710dcb205obrien    if_control,
6720dcb205obrien    invalid_control
6730dcb205obrien  };
674d3bb418pst
675d3bb418pst/* Structure for saved commands lines
676d3bb418pst   (for breakpoints, defined commands, etc).  */
677d3bb418pst
678d3bb418pststruct command_line
6790dcb205obrien  {
6800dcb205obrien    struct command_line *next;
6810dcb205obrien    char *line;
6820dcb205obrien    enum command_control_type control_type;
6830dcb205obrien    int body_count;
6840dcb205obrien    struct command_line **body_list;
6850dcb205obrien  };
6860dcb205obrien
6870dcb205obrienextern struct command_line *read_command_lines (char *, int);
6880dcb205obrien
6890dcb205obrienextern void free_command_lines (struct command_line **);
6900dcb205obrien
6910dcb205obrien/* To continue the execution commands when running gdb asynchronously.
6920dcb205obrien   A continuation structure contains a pointer to a function to be called
6930dcb205obrien   to finish the command, once the target has stopped. Such mechanism is
6940dcb205obrien   used bt the finish and until commands, and in the remote protocol
6950dcb205obrien   when opening an extended-remote connection. */
6960dcb205obrien
6970dcb205obrienstruct continuation_arg
6980dcb205obrien  {
6990dcb205obrien    struct continuation_arg *next;
7000dcb205obrien    union continuation_data {
7010dcb205obrien      void *pointer;
7020dcb205obrien      int   integer;
7030dcb205obrien      long  longint;
7040dcb205obrien    } data;
7050dcb205obrien  };
7060dcb205obrien
7070dcb205obrienstruct continuation
7080dcb205obrien  {
7090dcb205obrien    void (*continuation_hook) (struct continuation_arg *);
7100dcb205obrien    struct continuation_arg *arg_list;
7110dcb205obrien    struct continuation *next;
7120dcb205obrien  };
7130dcb205obrien
7140dcb205obrien/* In infrun.c. */
7150dcb205obrienextern struct continuation *cmd_continuation;
7160dcb205obrien/* Used only by the step_1 function. */
7170dcb205obrienextern struct continuation *intermediate_continuation;
718d3bb418pst
7190dcb205obrien/* From utils.c */
7200dcb205obrienextern void add_continuation (void (*)(struct continuation_arg *),
7210dcb205obrien			      struct continuation_arg *);
7220dcb205obrienextern void do_all_continuations (void);
7230dcb205obrienextern void discard_all_continuations (void);
724d3bb418pst
7250dcb205obrienextern void add_intermediate_continuation (void (*)(struct continuation_arg *),
7260dcb205obrien			      struct continuation_arg *);
7270dcb205obrienextern void do_all_intermediate_continuations (void);
7280dcb205obrienextern void discard_all_intermediate_continuations (void);
729d3bb418pst
730d3bb418pst/* String containing the current directory (what getwd would return).  */
731d3bb418pst
732d3bb418pstextern char *current_directory;
733d3bb418pst
734d3bb418pst/* Default radixes for input and output.  Only some values supported.  */
735d3bb418pstextern unsigned input_radix;
736d3bb418pstextern unsigned output_radix;
737d3bb418pst
738d3bb418pst/* Possibilities for prettyprint parameters to routines which print
739d3bb418pst   things.  Like enum language, this should be in value.h, but needs
740d3bb418pst   to be here for the same reason.  FIXME:  If we can eliminate this
741d3bb418pst   as an arg to LA_VAL_PRINT, then we can probably move it back to
742d3bb418pst   value.h. */
743d3bb418pst
744d3bb418pstenum val_prettyprint
7450dcb205obrien  {
7460dcb205obrien    Val_no_prettyprint = 0,
7470dcb205obrien    Val_prettyprint,
7480dcb205obrien    /* Use the default setting which the user has specified.  */
7490dcb205obrien    Val_pretty_default
7500dcb205obrien  };
7510dcb205obrien
7520dcb205obrien/* The ptid struct is a collection of the various "ids" necessary
7530dcb205obrien   for identifying the inferior.  This consists of the process id
7540dcb205obrien   (pid), thread id (tid), and other fields necessary for uniquely
7550dcb205obrien   identifying the inferior process/thread being debugged.  When
7560dcb205obrien   manipulating ptids, the constructors, accessors, and predicate
7570dcb205obrien   declared in inferior.h should be used.  These are as follows:
7580dcb205obrien
7590dcb205obrien      ptid_build	- Make a new ptid from a pid, lwp, and tid.
7600dcb205obrien      pid_to_ptid	- Make a new ptid from just a pid.
7610dcb205obrien      ptid_get_pid	- Fetch the pid component of a ptid.
7620dcb205obrien      ptid_get_lwp	- Fetch the lwp component of a ptid.
7630dcb205obrien      ptid_get_tid	- Fetch the tid component of a ptid.
7640dcb205obrien      ptid_equal	- Test to see if two ptids are equal.
7650dcb205obrien
7660dcb205obrien   Please do NOT access the struct ptid members directly (except, of
7670dcb205obrien   course, in the implementation of the above ptid manipulation
7680dcb205obrien   functions).  */
7690dcb205obrien
7700dcb205obrienstruct ptid
7710dcb205obrien  {
7720dcb205obrien    /* Process id */
7730dcb205obrien    int pid;
7740dcb205obrien
7750dcb205obrien    /* Lightweight process id */
7760dcb205obrien    long lwp;
7770dcb205obrien
7780dcb205obrien    /* Thread id */
7790dcb205obrien    long tid;
7800dcb205obrien  };
7810dcb205obrien
7820dcb205obrientypedef struct ptid ptid_t;
783d3bb418pst
784d3bb418pst
785d3bb418pst
7860dcb205obrien/* Optional host machine definition.  Pure autoconf targets will not
7870dcb205obrien   need a "xm.h" file.  This will be a symlink to one of the xm-*.h
7880dcb205obrien   files, built by the `configure' script.  */
7890dcb205obrien
7900dcb205obrien#ifdef GDB_XM_FILE
791d3bb418pst#include "xm.h"
7920dcb205obrien#endif
793d3bb418pst
7940dcb205obrien/* Optional native machine support.  Non-native (and possibly pure
7950dcb205obrien   multi-arch) targets do not need a "nm.h" file.  This will be a
7960dcb205obrien   symlink to one of the nm-*.h files, built by the `configure'
7970dcb205obrien   script.  */
798d3bb418pst
7990dcb205obrien#ifdef GDB_NM_FILE
800d3bb418pst#include "nm.h"
8010dcb205obrien#endif
802d3bb418pst
8030dcb205obrien/* Optional target machine definition.  Pure multi-arch configurations
8040dcb205obrien   do not need a "tm.h" file.  This will be a symlink to one of the
805d3bb418pst   tm-*.h files, built by the `configure' script.  */
806d3bb418pst
8070dcb205obrien#ifdef GDB_TM_FILE
808d3bb418pst#include "tm.h"
8090dcb205obrien#endif
8100dcb205obrien
811d3bb418pst/* If the xm.h file did not define the mode string used to open the
812d3bb418pst   files, assume that binary files are opened the same way as text
813d3bb418pst   files */
814d3bb418pst#ifndef FOPEN_RB
815d3bb418pst#include "fopen-same.h"
816d3bb418pst#endif
817d3bb418pst
8185d522dfdfr/* Defaults for system-wide constants (if not defined by xm.h, we fake it).
8195d522dfdfr   FIXME: Assumes 2's complement arithmetic */
820d3bb418pst
821d3bb418pst#if !defined (UINT_MAX)
8220dcb205obrien#define	UINT_MAX ((unsigned int)(~0))	/* 0xFFFFFFFF for 32-bits */
823d3bb418pst#endif
824d3bb418pst
825d3bb418pst#if !defined (INT_MAX)
8260dcb205obrien#define	INT_MAX ((int)(UINT_MAX >> 1))	/* 0x7FFFFFFF for 32-bits */
827d3bb418pst#endif
828d3bb418pst
829d3bb418pst#if !defined (INT_MIN)
8305d522dfdfr#define INT_MIN ((int)((int) ~0 ^ INT_MAX))	/* 0x80000000 for 32-bits */
831d3bb418pst#endif
832d3bb418pst
833d3bb418pst#if !defined (ULONG_MAX)
834d3bb418pst#define	ULONG_MAX ((unsigned long)(~0L))	/* 0xFFFFFFFF for 32-bits */
835d3bb418pst#endif
836d3bb418pst
837d3bb418pst#if !defined (LONG_MAX)
838d3bb418pst#define	LONG_MAX ((long)(ULONG_MAX >> 1))	/* 0x7FFFFFFF for 32-bits */
839d3bb418pst#endif
840d3bb418pst
8410dcb205obrien#if !defined (ULONGEST_MAX)
8420dcb205obrien#define	ULONGEST_MAX (~(ULONGEST)0)        /* 0xFFFFFFFFFFFFFFFF for 64-bits */
8430dcb205obrien#endif
844d3bb418pst
8450dcb205obrien#if !defined (LONGEST_MAX)                 /* 0x7FFFFFFFFFFFFFFF for 64-bits */
8460dcb205obrien#define	LONGEST_MAX ((LONGEST)(ULONGEST_MAX >> 1))
8470dcb205obrien#endif
8485d522dfdfr
849d3bb418pst/* Convert a LONGEST to an int.  This is used in contexts (e.g. number of
850d3bb418pst   arguments to a function, number in a value history, register number, etc.)
851d3bb418pst   where the value must not be larger than can fit in an int.  */
852d3bb418pst
8530dcb205obrienextern int longest_to_int (LONGEST);
854d3bb418pst
855d3bb418pst/* Assorted functions we can declare, now that const and volatile are
856d3bb418pst   defined.  */
857d3bb418pst
8580dcb205obrienextern char *savestring (const char *, size_t);
859d3bb418pst
8600dcb205obrienextern char *msavestring (void *, const char *, size_t);
861d3bb418pst
8620dcb205obrienextern char *mstrsave (void *, const char *);
863d3bb418pst
8640dcb205obrien/* Robust versions of same.  Throw an internal error when no memory,
8650dcb205obrien   guard against stray NULL arguments. */
8660dcb205obrienextern void *xmmalloc (void *md, size_t size);
8670dcb205obrienextern void *xmrealloc (void *md, void *ptr, size_t size);
8680dcb205obrienextern void *xmcalloc (void *md, size_t number, size_t size);
8690dcb205obrienextern void xmfree (void *md, void *ptr);
870d3bb418pst
8710dcb205obrien/* xmalloc(), xrealloc() and xcalloc() have already been declared in
8720dcb205obrien   "libiberty.h". */
8730dcb205obrienextern void xfree (void *);
8745d522dfdfr
87578a152dmarcel/* Utility macros to allocate typed memory.  Avoids errors like:
87678a152dmarcel   struct foo *foo = xmalloc (sizeof struct bar); and memset (foo,
87778a152dmarcel   sizeof (struct foo), 0).  */
87878a152dmarcel#define XZALLOC(TYPE) ((TYPE*) memset (xmalloc (sizeof (TYPE)), 0, sizeof (TYPE)))
87978a152dmarcel#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
88078a152dmarcel#define XCALLOC(NMEMB, TYPE) ((TYPE*) xcalloc ((NMEMB), sizeof (TYPE)))
88178a152dmarcel
8820dcb205obrien/* Like asprintf/vasprintf but get an internal_error if the call
8830dcb205obrien   fails. */
8840dcb205obrienextern void xasprintf (char **ret, const char *format, ...) ATTR_FORMAT (printf, 2, 3);
8850dcb205obrienextern void xvasprintf (char **ret, const char *format, va_list ap);
886d3bb418pst
88778a152dmarcel/* Like asprintf, but return the string, throw an error if no memory.  */
88878a152dmarcelextern char *xstrprintf (const char *format, ...) ATTR_FORMAT (printf, 1, 2);
88978a152dmarcel
8900dcb205obrienextern int parse_escape (char **);
891d3bb418pst
892d3bb418pst/* Message to be printed before the error message, when an error occurs.  */
893d3bb418pst
894d3bb418pstextern char *error_pre_print;
895d3bb418pst
896d3bb418pst/* Message to be printed before the error message, when an error occurs.  */
897d3bb418pst
898d3bb418pstextern char *quit_pre_print;
899d3bb418pst
900d3bb418pst/* Message to be printed before the warning message, when a warning occurs.  */
901d3bb418pst
902d3bb418pstextern char *warning_pre_print;
903d3bb418pst
9040dcb205obrienextern NORETURN void verror (const char *fmt, va_list ap) ATTR_NORETURN;
9050dcb205obrien
90678a152dmarcelextern NORETURN void error (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
90778a152dmarcel
90878a152dmarcelextern NORETURN void error_silent (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
9090dcb205obrien
9100dcb205obrienextern NORETURN void error_stream (struct ui_file *) ATTR_NORETURN;
911d3bb418pst
91278a152dmarcel/* Initialize the error buffer.  */
91378a152dmarcelextern void error_init (void);
91478a152dmarcel
9150dcb205obrien/* Returns a freshly allocate buffer containing the last error
9160dcb205obrien   message.  */
9170dcb205obrienextern char *error_last_message (void);
918d3bb418pst
91978a152dmarcel/* Output arbitrary error message.  */
92078a152dmarcelextern void error_output_message (char *pre_print, char *msg);
92178a152dmarcel
9220dcb205obrienextern NORETURN void internal_verror (const char *file, int line,
9230dcb205obrien				      const char *, va_list ap) ATTR_NORETURN;
924d3bb418pst
9250dcb205obrienextern NORETURN void internal_error (const char *file, int line,
9260dcb205obrien				     const char *, ...) ATTR_NORETURN ATTR_FORMAT (printf, 3, 4);
927d3bb418pst
92878a152dmarcelextern void internal_vwarning (const char *file, int line,
92978a152dmarcel			       const char *, va_list ap);
93078a152dmarcel
93178a152dmarcelextern void internal_warning (const char *file, int line,
93278a152dmarcel			      const char *, ...) ATTR_FORMAT (printf, 3, 4);
93378a152dmarcel
9340dcb205obrienextern NORETURN void nomem (long) ATTR_NORETURN;
935d3bb418pst
9360dcb205obrien/* Reasons for calling throw_exception().  NOTE: all reason values
9370dcb205obrien   must be less than zero.  enum value 0 is reserved for internal use
9380dcb205obrien   as the return value from an initial setjmp().  The function
9390dcb205obrien   catch_exceptions() reserves values >= 0 as legal results from its
9400dcb205obrien   wrapped function.  */
941d3bb418pst
9420dcb205obrienenum return_reason
9430dcb205obrien  {
9440dcb205obrien    /* User interrupt.  */
9450dcb205obrien    RETURN_QUIT = -2,
9460dcb205obrien    /* Any other error.  */
9470dcb205obrien    RETURN_ERROR
9480dcb205obrien  };
9490dcb205obrien
9500dcb205obrien#define	ALL_CLEANUPS	((struct cleanup *)0)
9510dcb205obrien
9520dcb205obrien#define RETURN_MASK(reason)	(1 << (int)(-reason))
9530dcb205obrien#define RETURN_MASK_QUIT	RETURN_MASK (RETURN_QUIT)
9540dcb205obrien#define RETURN_MASK_ERROR	RETURN_MASK (RETURN_ERROR)
9550dcb205obrien#define RETURN_MASK_ALL		(RETURN_MASK_QUIT | RETURN_MASK_ERROR)
956d3bb418psttypedef int return_mask;
957d3bb418pst
9580dcb205obrien/* Throw an exception of type RETURN_REASON.  Will execute a LONG JUMP
9590dcb205obrien   to the inner most containing exception handler established using
9600dcb205obrien   catch_exceptions() (or the legacy catch_errors()).
9610dcb205obrien
9620dcb205obrien   Code normally throws an exception using error() et.al.  For various
9630dcb205obrien   reaons, GDB also contains code that throws an exception directly.
9640dcb205obrien   For instance, the remote*.c targets contain CNTRL-C signal handlers
9650dcb205obrien   that propogate the QUIT event up the exception chain.  ``This could
9660dcb205obrien   be a good thing or a dangerous thing.'' -- the Existential Wombat.  */
9670dcb205obrien
9680dcb205obrienextern NORETURN void throw_exception (enum return_reason) ATTR_NORETURN;
9690dcb205obrien
9700dcb205obrien/* Call FUNC(UIOUT, FUNC_ARGS) but wrapped within an exception
9710dcb205obrien   handler.  If an exception (enum return_reason) is thrown using
9720dcb205obrien   throw_exception() than all cleanups installed since
9730dcb205obrien   catch_exceptions() was entered are invoked, the (-ve) exception
9740dcb205obrien   value is then returned by catch_exceptions.  If FUNC() returns
9750dcb205obrien   normally (with a postive or zero return value) then that value is
9760dcb205obrien   returned by catch_exceptions().  It is an internal_error() for
9770dcb205obrien   FUNC() to return a negative value.
9780dcb205obrien
9790dcb205obrien   For the period of the FUNC() call: UIOUT is installed as the output
9800dcb205obrien   builder; ERRSTRING is installed as the error/quit message; and a
9810dcb205obrien   new cleanup_chain is established.  The old values are restored
9820dcb205obrien   before catch_exceptions() returns.
983d3bb418pst
98478a152dmarcel   The variant catch_exceptions_with_msg() is the same as
98578a152dmarcel   catch_exceptions() but adds the ability to return an allocated
98678a152dmarcel   copy of the gdb error message.  This is used when a silent error is
98778a152dmarcel   issued and the caller wants to manually issue the error message.
98878a152dmarcel
9890dcb205obrien   FIXME; cagney/2001-08-13: The need to override the global UIOUT
9900dcb205obrien   builder variable should just go away.
991d3bb418pst
9920dcb205obrien   This function superseeds catch_errors().
993d3bb418pst
9940dcb205obrien   This function uses SETJMP() and LONGJUMP().  */
9950dcb205obrien
9960dcb205obrienstruct ui_out;
9970dcb205obrientypedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args);
9980dcb205obrienextern int catch_exceptions (struct ui_out *uiout,
9990dcb205obrien			     catch_exceptions_ftype *func, void *func_args,
10000dcb205obrien			     char *errstring, return_mask mask);
100178a152dmarcelextern int catch_exceptions_with_msg (struct ui_out *uiout,
100278a152dmarcel			     	      catch_exceptions_ftype *func,
100378a152dmarcel			     	      void *func_args,
100478a152dmarcel			     	      char *errstring, char **gdberrmsg,
100578a152dmarcel				      return_mask mask);
10060dcb205obrien
10070dcb205obrien/* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero
10080dcb205obrien   otherwize the result from CATCH_ERRORS_FTYPE is returned. It is
10090dcb205obrien   probably useful for CATCH_ERRORS_FTYPE to always return a non-zero
10100dcb205obrien   value. It's unfortunate that, catch_errors() does not return an
10110dcb205obrien   indication of the exact exception that it caught - quit_flag might
10120dcb205obrien   help.
10130dcb205obrien
10140dcb205obrien   This function is superseeded by catch_exceptions().  */
10150dcb205obrien
101678a152dmarceltypedef int (catch_errors_ftype) (void *);
10170dcb205obrienextern int catch_errors (catch_errors_ftype *, void *, char *, return_mask);
10180dcb205obrien
10190dcb205obrien/* Template to catch_errors() that wraps calls to command
10200dcb205obrien   functions. */
10210dcb205obrien
10220dcb205obrientypedef void (catch_command_errors_ftype) (char *, int);
10230dcb205obrienextern int catch_command_errors (catch_command_errors_ftype *func, char *command, int from_tty, return_mask);
10240dcb205obrien
10250dcb205obrienextern void warning (const char *, ...) ATTR_FORMAT (printf, 1, 2);
10260dcb205obrien
10270dcb205obrienextern void vwarning (const char *, va_list args);
1028d3bb418pst
102978a152dmarcel/* List of known OS ABIs.  If you change this, make sure to update the
103078a152dmarcel   table in osabi.c.  */
103178a152dmarcelenum gdb_osabi
103278a152dmarcel{
103378a152dmarcel  GDB_OSABI_UNINITIALIZED = -1, /* For struct gdbarch_info.  */
103478a152dmarcel
103578a152dmarcel  GDB_OSABI_UNKNOWN = 0,	/* keep this zero */
103678a152dmarcel
103778a152dmarcel  GDB_OSABI_SVR4,
103878a152dmarcel  GDB_OSABI_HURD,
103978a152dmarcel  GDB_OSABI_SOLARIS,
104078a152dmarcel  GDB_OSABI_OSF1,
104178a152dmarcel  GDB_OSABI_LINUX,
104278a152dmarcel  GDB_OSABI_FREEBSD_AOUT,
104378a152dmarcel  GDB_OSABI_FREEBSD_ELF,
104478a152dmarcel  GDB_OSABI_NETBSD_AOUT,
104578a152dmarcel  GDB_OSABI_NETBSD_ELF,
104678a152dmarcel  GDB_OSABI_OPENBSD_ELF,
104778a152dmarcel  GDB_OSABI_WINCE,
104878a152dmarcel  GDB_OSABI_GO32,
104978a152dmarcel  GDB_OSABI_NETWARE,
105078a152dmarcel  GDB_OSABI_IRIX,
105178a152dmarcel  GDB_OSABI_LYNXOS,
105278a152dmarcel  GDB_OSABI_INTERIX,
105378a152dmarcel  GDB_OSABI_HPUX_ELF,
105478a152dmarcel  GDB_OSABI_HPUX_SOM,
105578a152dmarcel
105678a152dmarcel  GDB_OSABI_ARM_EABI_V1,
105778a152dmarcel  GDB_OSABI_ARM_EABI_V2,
105878a152dmarcel  GDB_OSABI_ARM_APCS,
105978a152dmarcel  GDB_OSABI_QNXNTO,
106078a152dmarcel
106178a152dmarcel  GDB_OSABI_CYGWIN,
106278a152dmarcel
106378a152dmarcel  GDB_OSABI_INVALID		/* keep this last */
106478a152dmarcel};
106578a152dmarcel
1066d3bb418pst/* Global functions from other, non-gdb GNU thingies.
1067d3bb418pst   Libiberty thingies are no longer declared here.  We include libiberty.h
1068d3bb418pst   above, instead.  */
1069d3bb418pst
1070d3bb418pst#ifndef GETENV_PROVIDED
10710dcb205obrienextern char *getenv (const char *);
1072d3bb418pst#endif
1073d3bb418pst
1074d3bb418pst/* From other system libraries */
1075d3bb418pst
10765d522dfdfr#ifdef HAVE_STDDEF_H
1077d3bb418pst#include <stddef.h>
10785d522dfdfr#endif
10795d522dfdfr
10805d522dfdfr#ifdef HAVE_STDLIB_H
1081d3bb418pst#include <stdlib.h>
1082d3bb418pst#endif
10835d522dfdfr#ifndef min
10845d522dfdfr#define min(a, b) ((a) < (b) ? (a) : (b))
10855d522dfdfr#endif
10865d522dfdfr#ifndef max
10875d522dfdfr#define max(a, b) ((a) > (b) ? (a) : (b))
10885d522dfdfr#endif
1089d3bb418pst
1090d3bb418pst
1091d3bb418pst/* We take the address of fclose later, but some stdio's forget
1092d3bb418pst   to declare this.  We can't always declare it since there's
1093d3bb418pst   no way to declare the parameters without upsetting some compiler
1094d3bb418pst   somewhere. */
1095d3bb418pst
1096d3bb418pst#ifndef FCLOSE_PROVIDED
10970dcb205obrienextern int fclose (FILE *);
1098d3bb418pst#endif
1099d3bb418pst
1100d3bb418pst#ifndef atof
11010dcb205obrienextern double atof (const char *);	/* X3.159-1989  4.10.1.1 */
1102d3bb418pst#endif
1103d3bb418pst
1104d3bb418pst/* Various possibilities for alloca.  */
1105d3bb418pst#ifndef alloca
11060dcb205obrien#ifdef __GNUC__
11070dcb205obrien#define alloca __builtin_alloca
11080dcb205obrien#else /* Not GNU C */
11090dcb205obrien#ifdef HAVE_ALLOCA_H
11100dcb205obrien#include <alloca.h>
11110dcb205obrien#else
11120dcb205obrien#ifdef _AIX
11130dcb205obrien#pragma alloca
11140dcb205obrien#else
1115d3bb418pst
1116d3bb418pst/* We need to be careful not to declare this in a way which conflicts with
1117d3bb418pst   bison.  Bison never declares it as char *, but under various circumstances
1118d3bb418pst   (like __hpux) we need to use void *.  */
11190dcb205obrienextern void *alloca ();
11200dcb205obrien#endif /* Not _AIX */
11210dcb205obrien#endif /* Not HAVE_ALLOCA_H */
11220dcb205obrien#endif /* Not GNU C */
1123d3bb418pst#endif /* alloca not defined */
1124d3bb418pst
112578a152dmarcel/* Is GDB multi-arch?  If there's a "tm.h" file, it is not.  */
112678a152dmarcel#ifndef GDB_MULTI_ARCH
112778a152dmarcel#ifdef GDB_TM_FILE
112878a152dmarcel#define GDB_MULTI_ARCH GDB_MULTI_ARCH_PARTIAL
112978a152dmarcel#else
113078a152dmarcel#define GDB_MULTI_ARCH GDB_MULTI_ARCH_PURE
113178a152dmarcel#endif
113278a152dmarcel#endif
113378a152dmarcel
11345d522dfdfr/* Dynamic target-system-dependent parameters for GDB. */
11355d522dfdfr#include "gdbarch.h"
113678a152dmarcel
113778a152dmarcel/* Maximum size of a register.  Something small, but large enough for
113878a152dmarcel   all known ISAs.  If it turns out to be too small, make it bigger.  */
113978a152dmarcel
114078a152dmarcelenum { MAX_REGISTER_SIZE = 16 };
1141d3bb418pst
11425d522dfdfr/* Static target-system-dependent parameters for GDB. */
1143d3bb418pst
1144d3bb418pst/* Number of bits in a char or unsigned char for the target machine.
1145d3bb418pst   Just like CHAR_BIT in <limits.h> but describes the target machine.  */
1146d3bb418pst#if !defined (TARGET_CHAR_BIT)
1147d3bb418pst#define TARGET_CHAR_BIT 8
1148d3bb418pst#endif
1149d3bb418pst
1150d3bb418pst/* If we picked up a copy of CHAR_BIT from a configuration file
1151d3bb418pst   (which may get it by including <limits.h>) then use it to set
1152d3bb418pst   the number of bits in a host char.  If not, use the same size
1153d3bb418pst   as the target. */
1154d3bb418pst
1155d3bb418pst#if defined (CHAR_BIT)
1156d3bb418pst#define HOST_CHAR_BIT CHAR_BIT
1157d3bb418pst#else
1158d3bb418pst#define HOST_CHAR_BIT TARGET_CHAR_BIT
1159d3bb418pst#endif
1160d3bb418pst
1161d3bb418pst/* The bit byte-order has to do just with numbering of bits in
1162d3bb418pst   debugging symbols and such.  Conceptually, it's quite separate
1163d3bb418pst   from byte/word byte order.  */
1164d3bb418pst
1165d3bb418pst#if !defined (BITS_BIG_ENDIAN)
11660dcb205obrien#define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
11675d522dfdfr#endif
1168d3bb418pst
1169d3bb418pst/* In findvar.c.  */
1170d3bb418pst
117178a152dmarcelextern LONGEST extract_signed_integer (const void *, int);
1172d3bb418pst
117378a152dmarcelextern ULONGEST extract_unsigned_integer (const void *, int);
1174d3bb418pst
117578a152dmarcelextern int extract_long_unsigned_integer (const void *, int, LONGEST *);
11765d522dfdfr
117778a152dmarcelextern CORE_ADDR extract_typed_address (const void *buf, struct type *type);
1178d3bb418pst
11790dcb205obrienextern void store_signed_integer (void *, int, LONGEST);
11805d522dfdfr
11810dcb205obrienextern void store_unsigned_integer (void *, int, ULONGEST);
11825d522dfdfr
11830dcb205obrienextern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr);
1184d3bb418pst
1185d3bb418pst
1186d3bb418pst/* From valops.c */
1187d3bb418pst
11880dcb205obrienextern CORE_ADDR push_bytes (CORE_ADDR, char *, int);
1189d3bb418pst
11900dcb205obrienextern CORE_ADDR push_word (CORE_ADDR, ULONGEST);
1191d3bb418pst
1192d3bb418pstextern int watchdog;
1193d3bb418pst
1194d3bb418pst/* Hooks for alternate command interfaces.  */
1195d3bb418pst
11960dcb205obrien/* The name of the interpreter if specified on the command line. */
11970dcb205obrienextern char *interpreter_p;
11980dcb205obrien
11990dcb205obrien/* If a given interpreter matches INTERPRETER_P then it should update
12000dcb205obrien   command_loop_hook and init_ui_hook with the per-interpreter
12010dcb205obrien   implementation. */
12020dcb205obrien/* FIXME: command_loop_hook and init_ui_hook should be moved here. */
12030dcb205obrien
1204d3bb418pststruct target_waitstatus;
1205d3bb418pststruct cmd_list_element;
1206d3bb418pst
12070dcb205obrien/* Should the asynchronous variant of the interpreter (using the
12080dcb205obrien   event-loop) be enabled? */
12090dcb205obrienextern int event_loop_p;
12100dcb205obrien
12110dcb205obrienextern void (*init_ui_hook) (char *argv0);
12120dcb205obrienextern void (*command_loop_hook) (void);
12130dcb205obrienextern void (*show_load_progress) (const char *section,
12140dcb205obrien				   unsigned long section_sent,
12150dcb205obrien				   unsigned long section_size,
12160dcb205obrien				   unsigned long total_sent,
12170dcb205obrien				   unsigned long total_size);
12180dcb205obrienextern void (*print_frame_info_listing_hook) (struct symtab * s,
12190dcb205obrien					      int line, int stopline,
12200dcb205obrien					      int noerror);
12210dcb205obrienextern struct frame_info *parse_frame_specification (char *frame_exp);
12220dcb205obrienextern int (*query_hook) (const char *, va_list);
12230dcb205obrienextern void (*warning_hook) (const char *, va_list);
12240dcb205obrienextern void (*flush_hook) (struct ui_file * stream);
12250dcb205obrienextern void (*create_breakpoint_hook) (struct breakpoint * b);
12260dcb205obrienextern void (*delete_breakpoint_hook) (struct breakpoint * bpt);
12270dcb205obrienextern void (*modify_breakpoint_hook) (struct breakpoint * bpt);
12280dcb205obrienextern void (*interactive_hook) (void);
12290dcb205obrienextern void (*registers_changed_hook) (void);
12300dcb205obrienextern void (*readline_begin_hook) (char *,...);
12310dcb205obrienextern char *(*readline_hook) (char *);
12320dcb205obrienextern void (*readline_end_hook) (void);
12330dcb205obrienextern void (*register_changed_hook) (int regno);
12340dcb205obrienextern void (*memory_changed_hook) (CORE_ADDR addr, int len);
12350dcb205obrienextern void (*context_hook) (int);
12360dcb205obrienextern ptid_t (*target_wait_hook) (ptid_t ptid,
12370dcb205obrien                                         struct target_waitstatus * status);
12380dcb205obrien
12390dcb205obrienextern void (*attach_hook) (void);
12400dcb205obrienextern void (*detach_hook) (void);
12410dcb205obrienextern void (*call_command_hook) (struct cmd_list_element * c,
12420dcb205obrien				  char *cmd, int from_tty);
12430dcb205obrien
12440dcb205obrienextern void (*set_hook) (struct cmd_list_element * c);
12450dcb205obrien
12460dcb205obrienextern NORETURN void (*error_hook) (void) ATTR_NORETURN;
12470dcb205obrien
12480dcb205obrienextern void (*error_begin_hook) (void);
12490dcb205obrien
12500dcb205obrienextern int (*ui_load_progress_hook) (const char *section, unsigned long num);
1251d3bb418pst
1252d3bb418pst
1253d3bb418pst/* Inhibit window interface if non-zero. */
1254d3bb418pst
1255d3bb418pstextern int use_windows;
1256d3bb418pst
1257d3bb418pst/* Symbolic definitions of filename-related things.  */
1258d3bb418pst/* FIXME, this doesn't work very well if host and executable
1259d3bb418pst   filesystems conventions are different.  */
1260d3bb418pst
1261d3bb418pst#ifndef DIRNAME_SEPARATOR
1262d3bb418pst#define DIRNAME_SEPARATOR ':'
1263d3bb418pst#endif
1264d3bb418pst
1265d3bb418pst#ifndef SLASH_STRING
1266d3bb418pst#define SLASH_STRING "/"
1267d3bb418pst#endif
1268d3bb418pst
12690dcb205obrien#ifdef __MSDOS__
12700dcb205obrien# define CANT_FORK
12710dcb205obrien# define GLOBAL_CURDIR
1272d3bb418pst#endif
1273d3bb418pst
12740dcb205obrien/* Provide default definitions of PIDGET, TIDGET, and MERGEPID.
12750dcb205obrien   The name ``TIDGET'' is a historical accident.  Many uses of TIDGET
12760dcb205obrien   in the code actually refer to a lightweight process id, i.e,
12770dcb205obrien   something that can be considered a process id in its own right for
12780dcb205obrien   certain purposes.  */
12795d522dfdfr
12805d522dfdfr#ifndef PIDGET
12810dcb205obrien#define PIDGET(PTID) (ptid_get_pid (PTID))
12820dcb205obrien#define TIDGET(PTID) (ptid_get_lwp (PTID))
12830dcb205obrien#define MERGEPID(PID, TID) ptid_build (PID, TID, 0)
12845d522dfdfr#endif
12855d522dfdfr
12860dcb205obrien/* Define well known filenos if the system does not define them.  */
12870dcb205obrien#ifndef STDIN_FILENO
12880dcb205obrien#define STDIN_FILENO   0
12895d522dfdfr#endif
12900dcb205obrien#ifndef STDOUT_FILENO
12910dcb205obrien#define STDOUT_FILENO  1
12920dcb205obrien#endif
12930dcb205obrien#ifndef STDERR_FILENO
12940dcb205obrien#define STDERR_FILENO  2
12950dcb205obrien#endif
12960dcb205obrien
12970dcb205obrien/* If this definition isn't overridden by the header files, assume
12980dcb205obrien   that isatty and fileno exist on this system.  */
12990dcb205obrien#ifndef ISATTY
13000dcb205obrien#define ISATTY(FP)	(isatty (fileno (FP)))
13015d522dfdfr#endif
13025d522dfdfr
130378a152dmarcel/* Ensure that V is aligned to an N byte boundary (B's assumed to be a
130478a152dmarcel   power of 2).  Round up/down when necessary.  Examples of correct
130578a152dmarcel   use include:
130678a152dmarcel
130778a152dmarcel   addr = align_up (addr, 8); -- VALUE needs 8 byte alignment
130878a152dmarcel   write_memory (addr, value, len);
130978a152dmarcel   addr += len;
131078a152dmarcel
131178a152dmarcel   and:
131278a152dmarcel
131378a152dmarcel   sp = align_down (sp - len, 16); -- Keep SP 16 byte aligned
131478a152dmarcel   write_memory (sp, value, len);
131578a152dmarcel
131678a152dmarcel   Note that uses such as:
131778a152dmarcel
131878a152dmarcel   write_memory (addr, value, len);
131978a152dmarcel   addr += align_up (len, 8);
132078a152dmarcel
132178a152dmarcel   and:
132278a152dmarcel
132378a152dmarcel   sp -= align_up (len, 8);
132478a152dmarcel   write_memory (sp, value, len);
132578a152dmarcel
132678a152dmarcel   are typically not correct as they don't ensure that the address (SP
132778a152dmarcel   or ADDR) is correctly aligned (relying on previous alignment to
132878a152dmarcel   keep things right).  This is also why the methods are called
132978a152dmarcel   "align_..." instead of "round_..." as the latter reads better with
133078a152dmarcel   this incorrect coding style.  */
133178a152dmarcel
133278a152dmarcelextern ULONGEST align_up (ULONGEST v, int n);
133378a152dmarcelextern ULONGEST align_down (ULONGEST v, int n);
133478a152dmarcel
1335d3bb418pst#endif /* #ifndef DEFS_H */
1336