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