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