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