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