xref: /openbsd-src/gnu/usr.bin/binutils/gdb/defs.h (revision bb02a7f54797b51801cd7f69948ed635c0f8406b)
1b725ae77Skettenis /* *INDENT-OFF* */ /* ATTR_FORMAT confuses indent, avoid running it for now */
2e93f7393Sniklas /* Basic, host-specific, and target-specific definitions for GDB.
3b725ae77Skettenis    Copyright 1986, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
4b725ae77Skettenis    1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
5e93f7393Sniklas    Free Software Foundation, Inc.
6e93f7393Sniklas 
7e93f7393Sniklas    This file is part of GDB.
8e93f7393Sniklas 
9e93f7393Sniklas    This program is free software; you can redistribute it and/or modify
10e93f7393Sniklas    it under the terms of the GNU General Public License as published by
11e93f7393Sniklas    the Free Software Foundation; either version 2 of the License, or
12e93f7393Sniklas    (at your option) any later version.
13e93f7393Sniklas 
14e93f7393Sniklas    This program is distributed in the hope that it will be useful,
15e93f7393Sniklas    but WITHOUT ANY WARRANTY; without even the implied warranty of
16e93f7393Sniklas    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17e93f7393Sniklas    GNU General Public License for more details.
18e93f7393Sniklas 
19e93f7393Sniklas    You should have received a copy of the GNU General Public License
20e93f7393Sniklas    along with this program; if not, write to the Free Software
21b725ae77Skettenis    Foundation, Inc., 59 Temple Place - Suite 330,
22b725ae77Skettenis    Boston, MA 02111-1307, USA.  */
23e93f7393Sniklas 
24e93f7393Sniklas #ifndef DEFS_H
25e93f7393Sniklas #define DEFS_H
26e93f7393Sniklas 
27b725ae77Skettenis #include "config.h"		/* Generated by configure.  */
28b725ae77Skettenis 
29e93f7393Sniklas #include <stdio.h>
30b725ae77Skettenis #include <errno.h>		/* System call error return status.  */
31b725ae77Skettenis #include <limits.h>
32b725ae77Skettenis 
33b725ae77Skettenis #ifdef HAVE_STDDEF_H
34b725ae77Skettenis #include <stddef.h>
35b725ae77Skettenis #else
36b725ae77Skettenis #include <sys/types.h>		/* For size_t.  */
37b725ae77Skettenis #endif
38b725ae77Skettenis 
39b725ae77Skettenis #ifdef HAVE_UNISTD_H
40b725ae77Skettenis #include <unistd.h>
41b725ae77Skettenis #endif
42b725ae77Skettenis 
43b725ae77Skettenis /* First include ansidecl.h so we can use the various macro definitions
44b725ae77Skettenis    here and in all subsequent file inclusions.  */
45b725ae77Skettenis 
46b725ae77Skettenis #include "ansidecl.h"
47b725ae77Skettenis 
48b725ae77Skettenis #include "gdb_locale.h"
49b725ae77Skettenis 
50b725ae77Skettenis /* For ``enum target_signal''.  */
51b725ae77Skettenis #include "gdb/signals.h"
52e93f7393Sniklas 
53e93f7393Sniklas /* Just in case they're not defined in stdio.h.  */
54e93f7393Sniklas 
55e93f7393Sniklas #ifndef SEEK_SET
56e93f7393Sniklas #define SEEK_SET 0
57e93f7393Sniklas #endif
58e93f7393Sniklas #ifndef SEEK_CUR
59e93f7393Sniklas #define SEEK_CUR 1
60e93f7393Sniklas #endif
61e93f7393Sniklas 
62b725ae77Skettenis #include <stdarg.h>		/* For va_list.  */
63e93f7393Sniklas 
64e93f7393Sniklas #include "libiberty.h"
65e93f7393Sniklas 
66e93f7393Sniklas /* For BFD64 and bfd_vma.  */
67e93f7393Sniklas #include "bfd.h"
68007c2a45Smiod 
69e93f7393Sniklas /* An address in the program being debugged.  Host byte order.  Rather
70e93f7393Sniklas    than duplicate all the logic in BFD which figures out what type
71e93f7393Sniklas    this is (long, long long, etc.) and whether it needs to be 64
72e93f7393Sniklas    bits (the host/target interactions are subtle), we just use
73e93f7393Sniklas    bfd_vma.  */
74e93f7393Sniklas 
75e93f7393Sniklas typedef bfd_vma CORE_ADDR;
76e93f7393Sniklas 
77b725ae77Skettenis /* This is to make sure that LONGEST is at least as big as CORE_ADDR.  */
78b725ae77Skettenis 
79b725ae77Skettenis #ifndef LONGEST
80b725ae77Skettenis 
81b725ae77Skettenis #ifdef BFD64
82b725ae77Skettenis 
83b725ae77Skettenis #define LONGEST BFD_HOST_64_BIT
84b725ae77Skettenis #define ULONGEST BFD_HOST_U_64_BIT
85b725ae77Skettenis 
86b725ae77Skettenis #else /* No BFD64 */
87b725ae77Skettenis 
88b725ae77Skettenis #ifdef CC_HAS_LONG_LONG
89b725ae77Skettenis #define LONGEST long long
90b725ae77Skettenis #define ULONGEST unsigned long long
91b725ae77Skettenis #else
92b725ae77Skettenis #ifdef BFD_HOST_64_BIT
93b725ae77Skettenis /* BFD_HOST_64_BIT is defined for some hosts that don't have long long
94b725ae77Skettenis    (e.g. i386-windows) so try it.  */
95b725ae77Skettenis #define LONGEST BFD_HOST_64_BIT
96b725ae77Skettenis #define ULONGEST BFD_HOST_U_64_BIT
97b725ae77Skettenis #else
98b725ae77Skettenis #define LONGEST long
99b725ae77Skettenis #define ULONGEST unsigned long
100b725ae77Skettenis #endif
101b725ae77Skettenis #endif
102b725ae77Skettenis 
103b725ae77Skettenis #endif /* No BFD64 */
104b725ae77Skettenis 
105b725ae77Skettenis #endif /* ! LONGEST */
106b725ae77Skettenis 
107e93f7393Sniklas #ifndef min
108e93f7393Sniklas #define min(a, b) ((a) < (b) ? (a) : (b))
109e93f7393Sniklas #endif
110e93f7393Sniklas #ifndef max
111e93f7393Sniklas #define max(a, b) ((a) > (b) ? (a) : (b))
112e93f7393Sniklas #endif
113e93f7393Sniklas 
114b725ae77Skettenis /* Macros to do string compares.
115e93f7393Sniklas 
116b725ae77Skettenis    NOTE: cagney/2000-03-14:
117e93f7393Sniklas 
118b725ae77Skettenis    While old code can continue to refer to these macros, new code is
119b725ae77Skettenis    probably better off using strcmp() directly vis: ``strcmp() == 0''
120b725ae77Skettenis    and ``strcmp() != 0''.
121b725ae77Skettenis 
122b725ae77Skettenis    This is because modern compilers can directly inline strcmp()
123b725ae77Skettenis    making the original justification for these macros - avoid function
124b725ae77Skettenis    call overhead by pre-testing the first characters
125b725ae77Skettenis    (``*X==*Y?...:0'') - redundant.
126b725ae77Skettenis 
127b725ae77Skettenis    ``Even if [...] testing the first character does have a modest
128b725ae77Skettenis    performance improvement, I'd rather that whenever a performance
129b725ae77Skettenis    issue is found that we spend the effort on algorithmic
130b725ae77Skettenis    optimizations than micro-optimizing.'' J.T. */
131b725ae77Skettenis 
132b725ae77Skettenis /* NOTE: cagney/2003-11-23: All instances of STREQ[N] covered by
133b725ae77Skettenis    testing GDB on a stabs system have been replaced by equivalent
134b725ae77Skettenis    str[n]cmp calls.  To avoid the possability of introducing bugs when
135b725ae77Skettenis    making untested changes, the remaining references were deprecated
136b725ae77Skettenis    rather than replaced.  */
137b725ae77Skettenis 
138b725ae77Skettenis /* DISCLAIMER: cagney/2003-11-23: Simplified definition of these
139b725ae77Skettenis    macros so that they just map directly onto strcmp equivalent.  I'm
140b725ae77Skettenis    not responsible for any breakage due to code that relied on the old
141b725ae77Skettenis    underlying implementation.  */
142b725ae77Skettenis 
143b725ae77Skettenis #define DEPRECATED_STREQ(a,b) (strcmp ((a), (b)) == 0)
144b725ae77Skettenis #define DEPRECATED_STREQN(a,b,c) (strncmp ((a), (b), (c)) == 0)
145e93f7393Sniklas 
146e93f7393Sniklas /* Check if a character is one of the commonly used C++ marker characters.  */
147b725ae77Skettenis extern int is_cplus_marker (int);
148b725ae77Skettenis 
149b725ae77Skettenis /* enable xdb commands if set */
150b725ae77Skettenis extern int xdb_commands;
151b725ae77Skettenis 
152b725ae77Skettenis /* enable dbx commands if set */
153b725ae77Skettenis extern int dbx_commands;
154b725ae77Skettenis 
155b725ae77Skettenis /* System root path, used to find libraries etc.  */
156b725ae77Skettenis extern char *gdb_sysroot;
157e93f7393Sniklas 
158e93f7393Sniklas extern int quit_flag;
159e93f7393Sniklas extern int immediate_quit;
160e93f7393Sniklas extern int sevenbit_strings;
161e93f7393Sniklas 
162b725ae77Skettenis extern void quit (void);
163b725ae77Skettenis 
164b725ae77Skettenis /* FIXME: cagney/2000-03-13: It has been suggested that the peformance
165b725ae77Skettenis    benefits of having a ``QUIT'' macro rather than a function are
166b725ae77Skettenis    marginal.  If the overhead of a QUIT function call is proving
167b725ae77Skettenis    significant then its calling frequency should probably be reduced
168b725ae77Skettenis    [kingdon].  A profile analyzing the current situtation is
169b725ae77Skettenis    needed. */
170e93f7393Sniklas 
171e93f7393Sniklas #ifdef QUIT
172e93f7393Sniklas /* do twice to force compiler warning */
173b725ae77Skettenis #define QUIT_FIXME "FIXME"
174b725ae77Skettenis #define QUIT_FIXME "ignoring redefinition of QUIT"
175e93f7393Sniklas #else
176e93f7393Sniklas #define QUIT { \
177e93f7393Sniklas   if (quit_flag) quit (); \
17863addd46Skettenis   if (deprecated_interactive_hook) deprecated_interactive_hook (); \
179e93f7393Sniklas }
180e93f7393Sniklas #endif
181e93f7393Sniklas 
182e93f7393Sniklas /* Languages represented in the symbol table and elsewhere.
183e93f7393Sniklas    This should probably be in language.h, but since enum's can't
184e93f7393Sniklas    be forward declared to satisfy opaque references before their
185e93f7393Sniklas    actual definition, needs to be here. */
186e93f7393Sniklas 
187e93f7393Sniklas enum language
188e93f7393Sniklas   {
189e93f7393Sniklas     language_unknown,		/* Language not known */
190e93f7393Sniklas     language_auto,		/* Placeholder for automatic setting */
191e93f7393Sniklas     language_c,			/* C */
192e93f7393Sniklas     language_cplus,		/* C++ */
193b725ae77Skettenis     language_objc,		/* Objective-C */
194b725ae77Skettenis     language_java,		/* Java */
195e93f7393Sniklas     language_fortran,		/* Fortran */
196e93f7393Sniklas     language_m2,		/* Modula-2 */
197e93f7393Sniklas     language_asm,		/* Assembly language */
198b725ae77Skettenis     language_scm,    		/* Scheme / Guile */
199b725ae77Skettenis     language_pascal,		/* Pascal */
20063addd46Skettenis     language_ada,		/* Ada */
20163addd46Skettenis     language_minimal,		/* All other languages, minimal support only */
20263addd46Skettenis     nr_languages
203b725ae77Skettenis   };
204b725ae77Skettenis 
205b725ae77Skettenis enum precision_type
206b725ae77Skettenis   {
207b725ae77Skettenis     single_precision,
208b725ae77Skettenis     double_precision,
209b725ae77Skettenis     unspecified_precision
210b725ae77Skettenis   };
211b725ae77Skettenis 
212b725ae77Skettenis /* A generic, not quite boolean, enumeration.  */
213b725ae77Skettenis enum auto_boolean
214b725ae77Skettenis {
215b725ae77Skettenis   AUTO_BOOLEAN_TRUE,
216b725ae77Skettenis   AUTO_BOOLEAN_FALSE,
217b725ae77Skettenis   AUTO_BOOLEAN_AUTO
218b725ae77Skettenis };
219b725ae77Skettenis 
220b725ae77Skettenis /* Potential ways that a function can return a value of a given type.  */
221b725ae77Skettenis enum return_value_convention
222b725ae77Skettenis {
223b725ae77Skettenis   /* Where the return value has been squeezed into one or more
224b725ae77Skettenis      registers.  */
225b725ae77Skettenis   RETURN_VALUE_REGISTER_CONVENTION,
226b725ae77Skettenis   /* Commonly known as the "struct return convention".  The caller
227b725ae77Skettenis      passes an additional hidden first parameter to the caller.  That
228b725ae77Skettenis      parameter contains the address at which the value being returned
229b725ae77Skettenis      should be stored.  While typically, and historically, used for
230b725ae77Skettenis      large structs, this is convention is applied to values of many
231b725ae77Skettenis      different types.  */
23263addd46Skettenis   RETURN_VALUE_STRUCT_CONVENTION,
23363addd46Skettenis   /* Like the "struct return convention" above, but where the ABI
23463addd46Skettenis      guarantees that the called function stores the address at which
23563addd46Skettenis      the value being returned is stored in a well-defined location,
23663addd46Skettenis      such as a register or memory slot in the stack frame.  Don't use
23763addd46Skettenis      this if the ABI doesn't explicitly guarantees this.  */
23863addd46Skettenis   RETURN_VALUE_ABI_RETURNS_ADDRESS,
23963addd46Skettenis   /* Like the "struct return convention" above, but where the ABI
24063addd46Skettenis      guarantees that the address at which the value being returned is
24163addd46Skettenis      stored will be available in a well-defined location, such as a
24263addd46Skettenis      register or memory slot in the stack frame.  Don't use this if
24363addd46Skettenis      the ABI doesn't explicitly guarantees this.  */
24463addd46Skettenis   RETURN_VALUE_ABI_PRESERVES_ADDRESS,
245e93f7393Sniklas };
246e93f7393Sniklas 
247e93f7393Sniklas /* the cleanup list records things that have to be undone
248e93f7393Sniklas    if an error happens (descriptors to be closed, memory to be freed, etc.)
249e93f7393Sniklas    Each link in the chain records a function to call and an
250e93f7393Sniklas    argument to give it.
251e93f7393Sniklas 
252e93f7393Sniklas    Use make_cleanup to add an element to the cleanup chain.
253e93f7393Sniklas    Use do_cleanups to do all cleanup actions back to a given
254e93f7393Sniklas    point in the chain.  Use discard_cleanups to remove cleanups
255e93f7393Sniklas    from the chain back to a given point, not doing them.  */
256e93f7393Sniklas 
257e93f7393Sniklas struct cleanup
258e93f7393Sniklas   {
259e93f7393Sniklas     struct cleanup *next;
260b725ae77Skettenis     void (*function) (void *);
261b725ae77Skettenis     void *arg;
262e93f7393Sniklas   };
263e93f7393Sniklas 
264e93f7393Sniklas 
265e93f7393Sniklas /* The ability to declare that a function never returns is useful, but
266e93f7393Sniklas    not really required to compile GDB successfully, so the NORETURN and
267e93f7393Sniklas    ATTR_NORETURN macros normally expand into nothing.  */
268e93f7393Sniklas 
269e93f7393Sniklas /* If compiling with older versions of GCC, a function may be declared
270e93f7393Sniklas    "volatile" to indicate that it does not return.  */
271e93f7393Sniklas 
272e93f7393Sniklas #ifndef NORETURN
273e93f7393Sniklas #if defined(__GNUC__) \
274e93f7393Sniklas      && (__GNUC__ == 1 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
275e93f7393Sniklas #define NORETURN volatile
276e93f7393Sniklas #else
277e93f7393Sniklas #define NORETURN		/* nothing */
278e93f7393Sniklas #endif
279e93f7393Sniklas #endif
280e93f7393Sniklas 
281e93f7393Sniklas /* GCC 2.5 and later versions define a function attribute "noreturn",
282e93f7393Sniklas    which is the preferred way to declare that a function never returns.
283e93f7393Sniklas    However GCC 2.7 appears to be the first version in which this fully
284e93f7393Sniklas    works everywhere we use it. */
285e93f7393Sniklas 
286e93f7393Sniklas #ifndef ATTR_NORETURN
287b725ae77Skettenis #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
288e93f7393Sniklas #define ATTR_NORETURN __attribute__ ((noreturn))
289e93f7393Sniklas #else
290e93f7393Sniklas #define ATTR_NORETURN		/* nothing */
291e93f7393Sniklas #endif
292e93f7393Sniklas #endif
293e93f7393Sniklas 
294e93f7393Sniklas #ifndef ATTR_FORMAT
295b725ae77Skettenis #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 4))
296e93f7393Sniklas #define ATTR_FORMAT(type, x, y) __attribute__ ((format(type, x, y)))
297e93f7393Sniklas #else
298e93f7393Sniklas #define ATTR_FORMAT(type, x, y)	/* nothing */
299e93f7393Sniklas #endif
300e93f7393Sniklas #endif
301e93f7393Sniklas 
302b725ae77Skettenis /* Be conservative and use enum bitfields only with GCC.
303b725ae77Skettenis    This is copied from gcc 3.3.1, system.h.  */
304b725ae77Skettenis 
305b725ae77Skettenis #if defined(__GNUC__) && (__GNUC__ >= 2)
306b725ae77Skettenis #define ENUM_BITFIELD(TYPE) enum TYPE
307b725ae77Skettenis #else
308b725ae77Skettenis #define ENUM_BITFIELD(TYPE) unsigned int
309b725ae77Skettenis #endif
310b725ae77Skettenis 
311e93f7393Sniklas /* Needed for various prototypes */
312e93f7393Sniklas 
313e93f7393Sniklas struct symtab;
314e93f7393Sniklas struct breakpoint;
315b725ae77Skettenis struct frame_info;
316e93f7393Sniklas 
317e93f7393Sniklas /* From blockframe.c */
318e93f7393Sniklas 
319b725ae77Skettenis extern int inside_entry_func (struct frame_info *this_frame);
320e93f7393Sniklas 
321e93f7393Sniklas /* From utils.c */
322e93f7393Sniklas 
323b725ae77Skettenis extern void initialize_utils (void);
324e93f7393Sniklas 
325b725ae77Skettenis extern void notice_quit (void);
326e93f7393Sniklas 
327b725ae77Skettenis extern int strcmp_iw (const char *, const char *);
328e93f7393Sniklas 
329b725ae77Skettenis extern int strcmp_iw_ordered (const char *, const char *);
330e93f7393Sniklas 
331b725ae77Skettenis extern int streq (const char *, const char *);
332e93f7393Sniklas 
333b725ae77Skettenis extern int subset_compare (char *, char *);
334e93f7393Sniklas 
335b725ae77Skettenis extern char *safe_strerror (int);
336e93f7393Sniklas 
337b725ae77Skettenis extern void request_quit (int);
338e93f7393Sniklas 
339b725ae77Skettenis extern void do_cleanups (struct cleanup *);
340b725ae77Skettenis extern void do_final_cleanups (struct cleanup *);
341b725ae77Skettenis extern void do_run_cleanups (struct cleanup *);
342b725ae77Skettenis extern void do_exec_cleanups (struct cleanup *);
343b725ae77Skettenis extern void do_exec_error_cleanups (struct cleanup *);
344e93f7393Sniklas 
345b725ae77Skettenis extern void discard_cleanups (struct cleanup *);
346b725ae77Skettenis extern void discard_final_cleanups (struct cleanup *);
347b725ae77Skettenis extern void discard_exec_error_cleanups (struct cleanup *);
348b725ae77Skettenis extern void discard_my_cleanups (struct cleanup **, struct cleanup *);
349e93f7393Sniklas 
350b725ae77Skettenis /* NOTE: cagney/2000-03-04: This typedef is strictly for the
351b725ae77Skettenis    make_cleanup function declarations below. Do not use this typedef
352b725ae77Skettenis    as a cast when passing functions into the make_cleanup() code.
353b725ae77Skettenis    Instead either use a bounce function or add a wrapper function.
354b725ae77Skettenis    Calling a f(char*) function with f(void*) is non-portable. */
355b725ae77Skettenis typedef void (make_cleanup_ftype) (void *);
356e93f7393Sniklas 
357b725ae77Skettenis extern struct cleanup *make_cleanup (make_cleanup_ftype *, void *);
358e93f7393Sniklas 
359b725ae77Skettenis extern struct cleanup *make_cleanup_freeargv (char **);
360e93f7393Sniklas 
361b725ae77Skettenis struct ui_file;
362b725ae77Skettenis extern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *);
363e93f7393Sniklas 
36463addd46Skettenis struct section_addr_info;
36563addd46Skettenis extern struct cleanup *(make_cleanup_free_section_addr_info
36663addd46Skettenis                         (struct section_addr_info *));
36763addd46Skettenis 
368b725ae77Skettenis extern struct cleanup *make_cleanup_close (int fd);
369e93f7393Sniklas 
370b725ae77Skettenis extern struct cleanup *make_cleanup_bfd_close (bfd *abfd);
371e93f7393Sniklas 
372b725ae77Skettenis extern struct cleanup *make_final_cleanup (make_cleanup_ftype *, void *);
373b725ae77Skettenis 
374b725ae77Skettenis extern struct cleanup *make_my_cleanup (struct cleanup **,
375b725ae77Skettenis 					make_cleanup_ftype *, void *);
376b725ae77Skettenis 
377b725ae77Skettenis extern struct cleanup *make_run_cleanup (make_cleanup_ftype *, void *);
378b725ae77Skettenis 
379b725ae77Skettenis extern struct cleanup *make_exec_cleanup (make_cleanup_ftype *, void *);
380b725ae77Skettenis extern struct cleanup *make_exec_error_cleanup (make_cleanup_ftype *, void *);
381b725ae77Skettenis 
382b725ae77Skettenis extern struct cleanup *save_cleanups (void);
383b725ae77Skettenis extern struct cleanup *save_final_cleanups (void);
384b725ae77Skettenis extern struct cleanup *save_my_cleanups (struct cleanup **);
385b725ae77Skettenis 
386b725ae77Skettenis extern void restore_cleanups (struct cleanup *);
387b725ae77Skettenis extern void restore_final_cleanups (struct cleanup *);
388b725ae77Skettenis extern void restore_my_cleanups (struct cleanup **, struct cleanup *);
389b725ae77Skettenis 
390b725ae77Skettenis extern void free_current_contents (void *);
391b725ae77Skettenis 
392b725ae77Skettenis extern void null_cleanup (void *);
393b725ae77Skettenis 
394b725ae77Skettenis extern int myread (int, char *, int);
395b725ae77Skettenis 
396b725ae77Skettenis extern int query (const char *, ...) ATTR_FORMAT (printf, 1, 2);
397b725ae77Skettenis extern int nquery (const char *, ...) ATTR_FORMAT (printf, 1, 2);
398b725ae77Skettenis extern int yquery (const char *, ...) ATTR_FORMAT (printf, 1, 2);
399b725ae77Skettenis 
400b725ae77Skettenis extern void init_page_info (void);
401b725ae77Skettenis 
402b725ae77Skettenis extern char *gdb_realpath (const char *);
403b725ae77Skettenis extern char *xfullpath (const char *);
404b725ae77Skettenis 
405b725ae77Skettenis extern unsigned long gnu_debuglink_crc32 (unsigned long crc,
406b725ae77Skettenis                                           unsigned char *buf, size_t len);
407e93f7393Sniklas 
408e93f7393Sniklas /* From demangle.c */
409e93f7393Sniklas 
410b725ae77Skettenis extern void set_demangling_style (char *);
411b725ae77Skettenis 
412b725ae77Skettenis /* From tm.h */
413b725ae77Skettenis 
414b725ae77Skettenis struct type;
415b725ae77Skettenis typedef int (use_struct_convention_fn) (int gcc_p, struct type * value_type);
416b725ae77Skettenis extern use_struct_convention_fn generic_use_struct_convention;
417e93f7393Sniklas 
418e93f7393Sniklas 
419e93f7393Sniklas /* Annotation stuff.  */
420e93f7393Sniklas 
421e93f7393Sniklas extern int annotation_level;	/* in stack.c */
422e93f7393Sniklas 
423b725ae77Skettenis extern void begin_line (void);
424e93f7393Sniklas 
425b725ae77Skettenis extern void wrap_here (char *);
426e93f7393Sniklas 
427b725ae77Skettenis extern void reinitialize_more_filter (void);
428e93f7393Sniklas 
429b725ae77Skettenis /* Normal results */
430b725ae77Skettenis extern struct ui_file *gdb_stdout;
431b725ae77Skettenis /* Input stream */
432b725ae77Skettenis extern struct ui_file *gdb_stdin;
433b725ae77Skettenis /* Serious error notifications */
434b725ae77Skettenis extern struct ui_file *gdb_stderr;
435b725ae77Skettenis /* Log/debug/trace messages that should bypass normal stdout/stderr
436b725ae77Skettenis    filtering.  For moment, always call this stream using
437b725ae77Skettenis    *_unfiltered. In the very near future that restriction shall be
438b725ae77Skettenis    removed - either call shall be unfiltered. (cagney 1999-06-13). */
439b725ae77Skettenis extern struct ui_file *gdb_stdlog;
440b725ae77Skettenis /* Target output that should bypass normal stdout/stderr filtering.
441b725ae77Skettenis    For moment, always call this stream using *_unfiltered. In the
442b725ae77Skettenis    very near future that restriction shall be removed - either call
443b725ae77Skettenis    shall be unfiltered. (cagney 1999-07-02). */
444b725ae77Skettenis extern struct ui_file *gdb_stdtarg;
445b725ae77Skettenis extern struct ui_file *gdb_stdtargerr;
446b725ae77Skettenis extern struct ui_file *gdb_stdtargin;
447e93f7393Sniklas 
448b725ae77Skettenis #include "ui-file.h"
449e93f7393Sniklas 
450b725ae77Skettenis /* More generic printf like operations.  Filtered versions may return
451b725ae77Skettenis    non-locally on error.  */
452e93f7393Sniklas 
453b725ae77Skettenis extern void fputs_filtered (const char *, struct ui_file *);
454e93f7393Sniklas 
455b725ae77Skettenis extern void fputs_unfiltered (const char *, struct ui_file *);
456e93f7393Sniklas 
457b725ae77Skettenis extern int fputc_filtered (int c, struct ui_file *);
458e93f7393Sniklas 
459b725ae77Skettenis extern int fputc_unfiltered (int c, struct ui_file *);
460e93f7393Sniklas 
461b725ae77Skettenis extern int putchar_filtered (int c);
462e93f7393Sniklas 
463b725ae77Skettenis extern int putchar_unfiltered (int c);
464e93f7393Sniklas 
465b725ae77Skettenis extern void puts_filtered (const char *);
466e93f7393Sniklas 
467b725ae77Skettenis extern void puts_unfiltered (const char *);
468e93f7393Sniklas 
469b725ae77Skettenis extern void puts_filtered_tabular (char *string, int width, int right);
470e93f7393Sniklas 
471b725ae77Skettenis extern void puts_debug (char *prefix, char *string, char *suffix);
472e93f7393Sniklas 
473b725ae77Skettenis extern void vprintf_filtered (const char *, va_list) ATTR_FORMAT (printf, 1, 0);
474e93f7393Sniklas 
475b725ae77Skettenis extern void vfprintf_filtered (struct ui_file *, const char *, va_list) ATTR_FORMAT (printf, 2, 0);
476e93f7393Sniklas 
477b725ae77Skettenis extern void fprintf_filtered (struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 2, 3);
478e93f7393Sniklas 
479b725ae77Skettenis extern void fprintfi_filtered (int, struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 3, 4);
480e93f7393Sniklas 
481b725ae77Skettenis extern void printf_filtered (const char *, ...) ATTR_FORMAT (printf, 1, 2);
482e93f7393Sniklas 
483b725ae77Skettenis extern void printfi_filtered (int, const char *, ...) ATTR_FORMAT (printf, 2, 3);
484e93f7393Sniklas 
485b725ae77Skettenis extern void vprintf_unfiltered (const char *, va_list) ATTR_FORMAT (printf, 1, 0);
486e93f7393Sniklas 
487b725ae77Skettenis extern void vfprintf_unfiltered (struct ui_file *, const char *, va_list) ATTR_FORMAT (printf, 2, 0);
488e93f7393Sniklas 
489b725ae77Skettenis extern void fprintf_unfiltered (struct ui_file *, const char *, ...) ATTR_FORMAT (printf, 2, 3);
490e93f7393Sniklas 
491b725ae77Skettenis extern void printf_unfiltered (const char *, ...) ATTR_FORMAT (printf, 1, 2);
492e93f7393Sniklas 
493b725ae77Skettenis extern void print_spaces (int, struct ui_file *);
494e93f7393Sniklas 
495b725ae77Skettenis extern void print_spaces_filtered (int, struct ui_file *);
496e93f7393Sniklas 
497b725ae77Skettenis extern char *n_spaces (int);
498e93f7393Sniklas 
499b725ae77Skettenis extern void fputstr_filtered (const char *str, int quotr, struct ui_file * stream);
500e93f7393Sniklas 
501b725ae77Skettenis extern void fputstr_unfiltered (const char *str, int quotr, struct ui_file * stream);
502e93f7393Sniklas 
503b725ae77Skettenis extern void fputstrn_unfiltered (const char *str, int n, int quotr, struct ui_file * stream);
504b725ae77Skettenis 
505b725ae77Skettenis /* Display the host ADDR on STREAM formatted as ``0x%x''. */
506b725ae77Skettenis extern void gdb_print_host_address (const void *addr, struct ui_file *stream);
507b725ae77Skettenis 
508b725ae77Skettenis /* Convert a CORE_ADDR into a HEX string.  paddr() is like %08lx.
509b725ae77Skettenis    paddr_nz() is like %lx.  paddr_u() is like %lu. paddr_width() is
510b725ae77Skettenis    for ``%*''. */
511b725ae77Skettenis extern int strlen_paddr (void);
512b725ae77Skettenis extern char *paddr (CORE_ADDR addr);
513b725ae77Skettenis extern char *paddr_nz (CORE_ADDR addr);
514b725ae77Skettenis extern char *paddr_u (CORE_ADDR addr);
515b725ae77Skettenis extern char *paddr_d (LONGEST addr);
516b725ae77Skettenis 
517b725ae77Skettenis extern char *phex (ULONGEST l, int sizeof_l);
518b725ae77Skettenis extern char *phex_nz (ULONGEST l, int sizeof_l);
51963addd46Skettenis extern char *int_string (LONGEST, int, int, int, int);
520b725ae77Skettenis 
521b725ae77Skettenis /* Like paddr() only print/scan raw CORE_ADDR.  The output from
522b725ae77Skettenis    core_addr_to_string() can be passed direct to
523b725ae77Skettenis    string_to_core_addr().  */
524b725ae77Skettenis extern const char *core_addr_to_string (const CORE_ADDR addr);
525b725ae77Skettenis extern const char *core_addr_to_string_nz (const CORE_ADDR addr);
526b725ae77Skettenis extern CORE_ADDR string_to_core_addr (const char *my_string);
527b725ae77Skettenis 
52863addd46Skettenis /* Return a string that contains a number formatted as a hex
52963addd46Skettenis    string.  */
53063addd46Skettenis extern char *hex_string (LONGEST);
53163addd46Skettenis extern char *hex_string_custom (LONGEST, int);
53263addd46Skettenis 
533b725ae77Skettenis extern void fprintf_symbol_filtered (struct ui_file *, char *,
534b725ae77Skettenis 				     enum language, int);
535b725ae77Skettenis 
536b725ae77Skettenis extern NORETURN void perror_with_name (const char *) ATTR_NORETURN;
537b725ae77Skettenis 
538b725ae77Skettenis extern void print_sys_errmsg (const char *, int);
539e93f7393Sniklas 
540e93f7393Sniklas /* From regex.c or libc.  BSD 4.4 declares this with the argument type as
541e93f7393Sniklas    "const char *" in unistd.h, so we can't declare the argument
542e93f7393Sniklas    as "char *".  */
543e93f7393Sniklas 
544b725ae77Skettenis extern char *re_comp (const char *);
545e93f7393Sniklas 
546e93f7393Sniklas /* From symfile.c */
547e93f7393Sniklas 
548b725ae77Skettenis extern void symbol_file_command (char *, int);
549b725ae77Skettenis 
550b725ae77Skettenis /* Remote targets may wish to use this as their load function.  */
551b725ae77Skettenis extern void generic_load (char *name, int from_tty);
552b725ae77Skettenis 
553b725ae77Skettenis /* Summarise a download */
554b725ae77Skettenis extern void print_transfer_performance (struct ui_file *stream,
555b725ae77Skettenis 					unsigned long data_count,
556b725ae77Skettenis 					unsigned long write_count,
557b725ae77Skettenis 					unsigned long time_count);
558e93f7393Sniklas 
559e93f7393Sniklas /* From top.c */
560e93f7393Sniklas 
561b725ae77Skettenis typedef void initialize_file_ftype (void);
562e93f7393Sniklas 
563b725ae77Skettenis extern char *skip_quoted (char *);
564e93f7393Sniklas 
565b725ae77Skettenis extern char *gdb_readline (char *);
566e93f7393Sniklas 
567b725ae77Skettenis extern char *gdb_readline_wrapper (char *);
568e93f7393Sniklas 
569b725ae77Skettenis extern char *command_line_input (char *, int, char *);
570b725ae77Skettenis 
571b725ae77Skettenis extern void print_prompt (void);
572b725ae77Skettenis 
573b725ae77Skettenis extern int input_from_terminal_p (void);
574e93f7393Sniklas 
575e93f7393Sniklas extern int info_verbose;
576e93f7393Sniklas 
577e93f7393Sniklas /* From printcmd.c */
578e93f7393Sniklas 
579b725ae77Skettenis extern void set_next_address (CORE_ADDR);
580e93f7393Sniklas 
581b725ae77Skettenis extern void print_address_symbolic (CORE_ADDR, struct ui_file *, int,
582b725ae77Skettenis 				    char *);
583e93f7393Sniklas 
584b725ae77Skettenis extern int build_address_symbolic (CORE_ADDR addr,
585b725ae77Skettenis 				   int do_demangle,
586b725ae77Skettenis 				   char **name,
587b725ae77Skettenis 				   int *offset,
588b725ae77Skettenis 				   char **filename,
589b725ae77Skettenis 				   int *line,
590b725ae77Skettenis 				   int *unmapped);
591e93f7393Sniklas 
592b725ae77Skettenis extern void print_address_numeric (CORE_ADDR, int, struct ui_file *);
593b725ae77Skettenis 
594b725ae77Skettenis extern void print_address (CORE_ADDR, struct ui_file *);
595e93f7393Sniklas 
596e93f7393Sniklas /* From source.c */
597e93f7393Sniklas 
59863addd46Skettenis #define OPF_TRY_CWD_FIRST     0x01
59963addd46Skettenis #define OPF_SEARCH_IN_PATH    0x02
60063addd46Skettenis 
601b725ae77Skettenis extern int openp (const char *, int, const char *, int, int, char **);
602e93f7393Sniklas 
603b725ae77Skettenis extern int source_full_path_of (char *, char **);
604e93f7393Sniklas 
605b725ae77Skettenis extern void mod_path (char *, char **);
606e93f7393Sniklas 
607b725ae77Skettenis extern void add_path (char *, char **, int);
608e93f7393Sniklas 
609b725ae77Skettenis extern void directory_command (char *, int);
610e93f7393Sniklas 
611b725ae77Skettenis extern char *source_path;
612e93f7393Sniklas 
613b725ae77Skettenis extern void init_source_path (void);
614b725ae77Skettenis 
615b725ae77Skettenis extern void init_last_source_visited (void);
616b725ae77Skettenis 
617b725ae77Skettenis /* From exec.c */
618b725ae77Skettenis 
619b725ae77Skettenis extern void exec_set_section_offsets (bfd_signed_vma text_off,
620b725ae77Skettenis 				      bfd_signed_vma data_off,
621b725ae77Skettenis 				      bfd_signed_vma bss_off);
622b725ae77Skettenis 
623b725ae77Skettenis /* Take over the 'find_mapped_memory' vector from exec.c. */
624b725ae77Skettenis extern void exec_set_find_memory_regions (int (*) (int (*) (CORE_ADDR,
625b725ae77Skettenis 							    unsigned long,
626b725ae77Skettenis 							    int, int, int,
627b725ae77Skettenis 							    void *),
628b725ae77Skettenis 						   void *));
629b725ae77Skettenis 
630b725ae77Skettenis /* Possible lvalue types.  Like enum language, this should be in
631b725ae77Skettenis    value.h, but needs to be here for the same reason. */
632b725ae77Skettenis 
633b725ae77Skettenis enum lval_type
634b725ae77Skettenis   {
635b725ae77Skettenis     /* Not an lval. */
636b725ae77Skettenis     not_lval,
637b725ae77Skettenis     /* In memory.  Could be a saved register.  */
638b725ae77Skettenis     lval_memory,
639b725ae77Skettenis     /* In a register.  */
640b725ae77Skettenis     lval_register,
641b725ae77Skettenis     /* In a gdb internal variable.  */
642b725ae77Skettenis     lval_internalvar,
643b725ae77Skettenis     /* Part of a gdb internal variable (structure field).  */
644b725ae77Skettenis     lval_internalvar_component,
645b725ae77Skettenis     /* In a register series in a frame not the current one, which may have been
646b725ae77Skettenis        partially saved or saved in different places (otherwise would be
647b725ae77Skettenis        lval_register or lval_memory).  */
648b725ae77Skettenis     lval_reg_frame_relative
649b725ae77Skettenis   };
650e93f7393Sniklas 
651e93f7393Sniklas /* Control types for commands */
652e93f7393Sniklas 
653e93f7393Sniklas enum misc_command_type
654e93f7393Sniklas   {
655e93f7393Sniklas     ok_command,
656e93f7393Sniklas     end_command,
657e93f7393Sniklas     else_command,
658e93f7393Sniklas     nop_command
659e93f7393Sniklas   };
660e93f7393Sniklas 
661e93f7393Sniklas enum command_control_type
662e93f7393Sniklas   {
663e93f7393Sniklas     simple_control,
664e93f7393Sniklas     break_control,
665e93f7393Sniklas     continue_control,
666e93f7393Sniklas     while_control,
667e93f7393Sniklas     if_control,
668e93f7393Sniklas     invalid_control
669e93f7393Sniklas   };
670e93f7393Sniklas 
671e93f7393Sniklas /* Structure for saved commands lines
672e93f7393Sniklas    (for breakpoints, defined commands, etc).  */
673e93f7393Sniklas 
674e93f7393Sniklas struct command_line
675e93f7393Sniklas   {
676e93f7393Sniklas     struct command_line *next;
677e93f7393Sniklas     char *line;
678e93f7393Sniklas     enum command_control_type control_type;
679e93f7393Sniklas     int body_count;
680e93f7393Sniklas     struct command_line **body_list;
681e93f7393Sniklas   };
682e93f7393Sniklas 
683b725ae77Skettenis extern struct command_line *read_command_lines (char *, int);
684e93f7393Sniklas 
685b725ae77Skettenis extern void free_command_lines (struct command_line **);
686b725ae77Skettenis 
687b725ae77Skettenis /* To continue the execution commands when running gdb asynchronously.
688b725ae77Skettenis    A continuation structure contains a pointer to a function to be called
689b725ae77Skettenis    to finish the command, once the target has stopped. Such mechanism is
690b725ae77Skettenis    used bt the finish and until commands, and in the remote protocol
691b725ae77Skettenis    when opening an extended-remote connection. */
692b725ae77Skettenis 
693b725ae77Skettenis struct continuation_arg
694b725ae77Skettenis   {
695b725ae77Skettenis     struct continuation_arg *next;
696b725ae77Skettenis     union continuation_data {
697b725ae77Skettenis       void *pointer;
698b725ae77Skettenis       int   integer;
699b725ae77Skettenis       long  longint;
700b725ae77Skettenis     } data;
701b725ae77Skettenis   };
702b725ae77Skettenis 
703b725ae77Skettenis struct continuation
704b725ae77Skettenis   {
705b725ae77Skettenis     void (*continuation_hook) (struct continuation_arg *);
706b725ae77Skettenis     struct continuation_arg *arg_list;
707b725ae77Skettenis     struct continuation *next;
708b725ae77Skettenis   };
709b725ae77Skettenis 
710b725ae77Skettenis /* In infrun.c. */
711b725ae77Skettenis extern struct continuation *cmd_continuation;
712b725ae77Skettenis /* Used only by the step_1 function. */
713b725ae77Skettenis extern struct continuation *intermediate_continuation;
714b725ae77Skettenis 
715b725ae77Skettenis /* From utils.c */
716b725ae77Skettenis extern void add_continuation (void (*)(struct continuation_arg *),
717b725ae77Skettenis 			      struct continuation_arg *);
718b725ae77Skettenis extern void do_all_continuations (void);
719b725ae77Skettenis extern void discard_all_continuations (void);
720b725ae77Skettenis 
721b725ae77Skettenis extern void add_intermediate_continuation (void (*)(struct continuation_arg *),
722b725ae77Skettenis 			      struct continuation_arg *);
723b725ae77Skettenis extern void do_all_intermediate_continuations (void);
724b725ae77Skettenis extern void discard_all_intermediate_continuations (void);
725e93f7393Sniklas 
726e93f7393Sniklas /* String containing the current directory (what getwd would return).  */
727e93f7393Sniklas 
728e93f7393Sniklas extern char *current_directory;
729e93f7393Sniklas 
730e93f7393Sniklas /* Default radixes for input and output.  Only some values supported.  */
731e93f7393Sniklas extern unsigned input_radix;
732e93f7393Sniklas extern unsigned output_radix;
733e93f7393Sniklas 
734e93f7393Sniklas /* Possibilities for prettyprint parameters to routines which print
735e93f7393Sniklas    things.  Like enum language, this should be in value.h, but needs
736e93f7393Sniklas    to be here for the same reason.  FIXME:  If we can eliminate this
737e93f7393Sniklas    as an arg to LA_VAL_PRINT, then we can probably move it back to
738e93f7393Sniklas    value.h. */
739e93f7393Sniklas 
740e93f7393Sniklas enum val_prettyprint
741e93f7393Sniklas   {
742e93f7393Sniklas     Val_no_prettyprint = 0,
743e93f7393Sniklas     Val_prettyprint,
744e93f7393Sniklas     /* Use the default setting which the user has specified.  */
745e93f7393Sniklas     Val_pretty_default
746e93f7393Sniklas   };
747e93f7393Sniklas 
748b725ae77Skettenis /* The ptid struct is a collection of the various "ids" necessary
749b725ae77Skettenis    for identifying the inferior.  This consists of the process id
750b725ae77Skettenis    (pid), thread id (tid), and other fields necessary for uniquely
751b725ae77Skettenis    identifying the inferior process/thread being debugged.  When
752b725ae77Skettenis    manipulating ptids, the constructors, accessors, and predicate
753b725ae77Skettenis    declared in inferior.h should be used.  These are as follows:
754b725ae77Skettenis 
755b725ae77Skettenis       ptid_build	- Make a new ptid from a pid, lwp, and tid.
756b725ae77Skettenis       pid_to_ptid	- Make a new ptid from just a pid.
757b725ae77Skettenis       ptid_get_pid	- Fetch the pid component of a ptid.
758b725ae77Skettenis       ptid_get_lwp	- Fetch the lwp component of a ptid.
759b725ae77Skettenis       ptid_get_tid	- Fetch the tid component of a ptid.
760b725ae77Skettenis       ptid_equal	- Test to see if two ptids are equal.
761b725ae77Skettenis 
762b725ae77Skettenis    Please do NOT access the struct ptid members directly (except, of
763b725ae77Skettenis    course, in the implementation of the above ptid manipulation
764b725ae77Skettenis    functions).  */
765b725ae77Skettenis 
766b725ae77Skettenis struct ptid
767b725ae77Skettenis   {
768b725ae77Skettenis     /* Process id */
769b725ae77Skettenis     int pid;
770b725ae77Skettenis 
771b725ae77Skettenis     /* Lightweight process id */
772b725ae77Skettenis     long lwp;
773b725ae77Skettenis 
774b725ae77Skettenis     /* Thread id */
775b725ae77Skettenis     long tid;
776b725ae77Skettenis   };
777b725ae77Skettenis 
778b725ae77Skettenis typedef struct ptid ptid_t;
779b725ae77Skettenis 
780e93f7393Sniklas 
781e93f7393Sniklas 
782b725ae77Skettenis /* Optional host machine definition.  Pure autoconf targets will not
783b725ae77Skettenis    need a "xm.h" file.  This will be a symlink to one of the xm-*.h
784b725ae77Skettenis    files, built by the `configure' script.  */
785b725ae77Skettenis 
786b725ae77Skettenis #ifdef GDB_XM_FILE
787e93f7393Sniklas #include "xm.h"
788b725ae77Skettenis #endif
789e93f7393Sniklas 
790b725ae77Skettenis /* Optional native machine support.  Non-native (and possibly pure
791b725ae77Skettenis    multi-arch) targets do not need a "nm.h" file.  This will be a
792b725ae77Skettenis    symlink to one of the nm-*.h files, built by the `configure'
793b725ae77Skettenis    script.  */
794e93f7393Sniklas 
795b725ae77Skettenis #ifdef GDB_NM_FILE
796e93f7393Sniklas #include "nm.h"
797b725ae77Skettenis #endif
798e93f7393Sniklas 
799b725ae77Skettenis /* Optional target machine definition.  Pure multi-arch configurations
800b725ae77Skettenis    do not need a "tm.h" file.  This will be a symlink to one of the
801e93f7393Sniklas    tm-*.h files, built by the `configure' script.  */
802e93f7393Sniklas 
803b725ae77Skettenis #ifdef GDB_TM_FILE
804e93f7393Sniklas #include "tm.h"
805b725ae77Skettenis #endif
806e93f7393Sniklas 
80763addd46Skettenis /* Assume that fopen accepts the letter "b" in the mode string.
80863addd46Skettenis    Support for is demanded by ISO C90, and should be supported on all
80963addd46Skettenis    platforms that claim to have a standards conforming C library.  On
81063addd46Skettenis    true POSIX systems it will be ignored and have no effect.  There
81163addd46Skettenis    may still be systems without a standards conforming C library where
81263addd46Skettenis    an ISO C90 compiler (GCC) is available.  Known examples are SunOS
81363addd46Skettenis    4.x and 4.3BSD.  This assumption means these systems are no longer
81463addd46Skettenis    supported.  */
815e93f7393Sniklas #ifndef FOPEN_RB
81663addd46Skettenis # include "fopen-bin.h"
817e93f7393Sniklas #endif
818e93f7393Sniklas 
819e93f7393Sniklas /* Defaults for system-wide constants (if not defined by xm.h, we fake it).
820e93f7393Sniklas    FIXME: Assumes 2's complement arithmetic */
821e93f7393Sniklas 
822e93f7393Sniklas #if !defined (UINT_MAX)
823e93f7393Sniklas #define	UINT_MAX ((unsigned int)(~0))	/* 0xFFFFFFFF for 32-bits */
824e93f7393Sniklas #endif
825e93f7393Sniklas 
826e93f7393Sniklas #if !defined (INT_MAX)
827e93f7393Sniklas #define	INT_MAX ((int)(UINT_MAX >> 1))	/* 0x7FFFFFFF for 32-bits */
828e93f7393Sniklas #endif
829e93f7393Sniklas 
830e93f7393Sniklas #if !defined (INT_MIN)
831e93f7393Sniklas #define INT_MIN ((int)((int) ~0 ^ INT_MAX))	/* 0x80000000 for 32-bits */
832e93f7393Sniklas #endif
833e93f7393Sniklas 
834e93f7393Sniklas #if !defined (ULONG_MAX)
835e93f7393Sniklas #define	ULONG_MAX ((unsigned long)(~0L))	/* 0xFFFFFFFF for 32-bits */
836e93f7393Sniklas #endif
837e93f7393Sniklas 
838e93f7393Sniklas #if !defined (LONG_MAX)
839e93f7393Sniklas #define	LONG_MAX ((long)(ULONG_MAX >> 1))	/* 0x7FFFFFFF for 32-bits */
840e93f7393Sniklas #endif
841e93f7393Sniklas 
842b725ae77Skettenis #if !defined (ULONGEST_MAX)
843b725ae77Skettenis #define	ULONGEST_MAX (~(ULONGEST)0)        /* 0xFFFFFFFFFFFFFFFF for 64-bits */
844e93f7393Sniklas #endif
845e93f7393Sniklas 
846b725ae77Skettenis #if !defined (LONGEST_MAX)                 /* 0x7FFFFFFFFFFFFFFF for 64-bits */
847b725ae77Skettenis #define	LONGEST_MAX ((LONGEST)(ULONGEST_MAX >> 1))
848b725ae77Skettenis #endif
849e93f7393Sniklas 
850e93f7393Sniklas /* Convert a LONGEST to an int.  This is used in contexts (e.g. number of
851e93f7393Sniklas    arguments to a function, number in a value history, register number, etc.)
852e93f7393Sniklas    where the value must not be larger than can fit in an int.  */
853e93f7393Sniklas 
854b725ae77Skettenis extern int longest_to_int (LONGEST);
855e93f7393Sniklas 
856e93f7393Sniklas /* Assorted functions we can declare, now that const and volatile are
857e93f7393Sniklas    defined.  */
858e93f7393Sniklas 
859b725ae77Skettenis extern char *savestring (const char *, size_t);
860e93f7393Sniklas 
861b725ae77Skettenis /* xmalloc(), xrealloc() and xcalloc() have already been declared in
862b725ae77Skettenis    "libiberty.h". */
863b725ae77Skettenis extern void xfree (void *);
864e93f7393Sniklas 
865b725ae77Skettenis /* Utility macros to allocate typed memory.  Avoids errors like:
866b725ae77Skettenis    struct foo *foo = xmalloc (sizeof struct bar); and memset (foo,
867b725ae77Skettenis    sizeof (struct foo), 0).  */
868b725ae77Skettenis #define XZALLOC(TYPE) ((TYPE*) memset (xmalloc (sizeof (TYPE)), 0, sizeof (TYPE)))
869b725ae77Skettenis #define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
870b725ae77Skettenis #define XCALLOC(NMEMB, TYPE) ((TYPE*) xcalloc ((NMEMB), sizeof (TYPE)))
871e93f7393Sniklas 
872b725ae77Skettenis /* Like asprintf/vasprintf but get an internal_error if the call
873b725ae77Skettenis    fails. */
874b725ae77Skettenis extern void xasprintf (char **ret, const char *format, ...) ATTR_FORMAT (printf, 2, 3);
875b725ae77Skettenis extern void xvasprintf (char **ret, const char *format, va_list ap);
876e93f7393Sniklas 
87763addd46Skettenis /* Like asprintf and vasprintf, but return the string, throw an error
87863addd46Skettenis    if no memory.  */
879b725ae77Skettenis extern char *xstrprintf (const char *format, ...) ATTR_FORMAT (printf, 1, 2);
88063addd46Skettenis extern char *xstrvprintf (const char *format, va_list ap);
881e93f7393Sniklas 
882*bb02a7f5Skettenis /* Like snprintf, but throw an error if the output buffer is too small.  */
883*bb02a7f5Skettenis extern int xsnprintf (char *str, size_t size, const char *format, ...)
884*bb02a7f5Skettenis      ATTR_FORMAT (printf, 3, 4);
885*bb02a7f5Skettenis 
886b725ae77Skettenis extern int parse_escape (char **);
887e93f7393Sniklas 
888e93f7393Sniklas /* Message to be printed before the error message, when an error occurs.  */
889e93f7393Sniklas 
890e93f7393Sniklas extern char *error_pre_print;
891e93f7393Sniklas 
892e93f7393Sniklas /* Message to be printed before the error message, when an error occurs.  */
893e93f7393Sniklas 
894e93f7393Sniklas extern char *quit_pre_print;
895e93f7393Sniklas 
896e93f7393Sniklas /* Message to be printed before the warning message, when a warning occurs.  */
897e93f7393Sniklas 
898e93f7393Sniklas extern char *warning_pre_print;
899e93f7393Sniklas 
900b725ae77Skettenis extern NORETURN void verror (const char *fmt, va_list ap) ATTR_NORETURN;
901e93f7393Sniklas 
902b725ae77Skettenis extern NORETURN void error (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
903e93f7393Sniklas 
904b725ae77Skettenis extern NORETURN void error_silent (const char *fmt, ...) ATTR_NORETURN ATTR_FORMAT (printf, 1, 2);
905e93f7393Sniklas 
906b725ae77Skettenis extern NORETURN void error_stream (struct ui_file *) ATTR_NORETURN;
907e93f7393Sniklas 
908b725ae77Skettenis /* Initialize the error buffer.  */
909b725ae77Skettenis extern void error_init (void);
910b725ae77Skettenis 
911b725ae77Skettenis /* Returns a freshly allocate buffer containing the last error
912b725ae77Skettenis    message.  */
913b725ae77Skettenis extern char *error_last_message (void);
914b725ae77Skettenis 
915b725ae77Skettenis /* Output arbitrary error message.  */
916b725ae77Skettenis extern void error_output_message (char *pre_print, char *msg);
917b725ae77Skettenis 
918b725ae77Skettenis extern NORETURN void internal_verror (const char *file, int line,
919b725ae77Skettenis 				      const char *, va_list ap) ATTR_NORETURN;
920b725ae77Skettenis 
921b725ae77Skettenis extern NORETURN void internal_error (const char *file, int line,
922b725ae77Skettenis 				     const char *, ...) ATTR_NORETURN ATTR_FORMAT (printf, 3, 4);
923b725ae77Skettenis 
924b725ae77Skettenis extern void internal_vwarning (const char *file, int line,
925b725ae77Skettenis 			       const char *, va_list ap);
926b725ae77Skettenis 
927b725ae77Skettenis extern void internal_warning (const char *file, int line,
928b725ae77Skettenis 			      const char *, ...) ATTR_FORMAT (printf, 3, 4);
929b725ae77Skettenis 
930b725ae77Skettenis extern NORETURN void nomem (long) ATTR_NORETURN;
931b725ae77Skettenis 
932b725ae77Skettenis /* Reasons for calling throw_exception().  NOTE: all reason values
933b725ae77Skettenis    must be less than zero.  enum value 0 is reserved for internal use
934b725ae77Skettenis    as the return value from an initial setjmp().  The function
935b725ae77Skettenis    catch_exceptions() reserves values >= 0 as legal results from its
936b725ae77Skettenis    wrapped function.  */
937b725ae77Skettenis 
938b725ae77Skettenis enum return_reason
939b725ae77Skettenis   {
940e93f7393Sniklas     /* User interrupt.  */
941b725ae77Skettenis     RETURN_QUIT = -2,
942e93f7393Sniklas     /* Any other error.  */
943e93f7393Sniklas     RETURN_ERROR
944e93f7393Sniklas   };
945e93f7393Sniklas 
946b725ae77Skettenis #define	ALL_CLEANUPS	((struct cleanup *)0)
947b725ae77Skettenis 
948b725ae77Skettenis #define RETURN_MASK(reason)	(1 << (int)(-reason))
949b725ae77Skettenis #define RETURN_MASK_QUIT	RETURN_MASK (RETURN_QUIT)
950b725ae77Skettenis #define RETURN_MASK_ERROR	RETURN_MASK (RETURN_ERROR)
951e93f7393Sniklas #define RETURN_MASK_ALL		(RETURN_MASK_QUIT | RETURN_MASK_ERROR)
952e93f7393Sniklas typedef int return_mask;
953e93f7393Sniklas 
954b725ae77Skettenis /* Throw an exception of type RETURN_REASON.  Will execute a LONG JUMP
955b725ae77Skettenis    to the inner most containing exception handler established using
956b725ae77Skettenis    catch_exceptions() (or the legacy catch_errors()).
957e93f7393Sniklas 
958b725ae77Skettenis    Code normally throws an exception using error() et.al.  For various
959b725ae77Skettenis    reaons, GDB also contains code that throws an exception directly.
960b725ae77Skettenis    For instance, the remote*.c targets contain CNTRL-C signal handlers
961b725ae77Skettenis    that propogate the QUIT event up the exception chain.  ``This could
962b725ae77Skettenis    be a good thing or a dangerous thing.'' -- the Existential Wombat.  */
963e93f7393Sniklas 
964b725ae77Skettenis extern NORETURN void throw_exception (enum return_reason) ATTR_NORETURN;
965e93f7393Sniklas 
966b725ae77Skettenis /* Call FUNC(UIOUT, FUNC_ARGS) but wrapped within an exception
967b725ae77Skettenis    handler.  If an exception (enum return_reason) is thrown using
968b725ae77Skettenis    throw_exception() than all cleanups installed since
969b725ae77Skettenis    catch_exceptions() was entered are invoked, the (-ve) exception
970b725ae77Skettenis    value is then returned by catch_exceptions.  If FUNC() returns
971b725ae77Skettenis    normally (with a postive or zero return value) then that value is
972b725ae77Skettenis    returned by catch_exceptions().  It is an internal_error() for
973b725ae77Skettenis    FUNC() to return a negative value.
974b725ae77Skettenis 
975b725ae77Skettenis    For the period of the FUNC() call: UIOUT is installed as the output
976b725ae77Skettenis    builder; ERRSTRING is installed as the error/quit message; and a
977b725ae77Skettenis    new cleanup_chain is established.  The old values are restored
978b725ae77Skettenis    before catch_exceptions() returns.
979b725ae77Skettenis 
980b725ae77Skettenis    The variant catch_exceptions_with_msg() is the same as
981b725ae77Skettenis    catch_exceptions() but adds the ability to return an allocated
982b725ae77Skettenis    copy of the gdb error message.  This is used when a silent error is
983b725ae77Skettenis    issued and the caller wants to manually issue the error message.
984b725ae77Skettenis 
985b725ae77Skettenis    FIXME; cagney/2001-08-13: The need to override the global UIOUT
986b725ae77Skettenis    builder variable should just go away.
987b725ae77Skettenis 
988b725ae77Skettenis    This function superseeds catch_errors().
989b725ae77Skettenis 
990b725ae77Skettenis    This function uses SETJMP() and LONGJUMP().  */
991b725ae77Skettenis 
992b725ae77Skettenis struct ui_out;
993b725ae77Skettenis typedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args);
994b725ae77Skettenis extern int catch_exceptions (struct ui_out *uiout,
995b725ae77Skettenis 			     catch_exceptions_ftype *func, void *func_args,
996b725ae77Skettenis 			     char *errstring, return_mask mask);
997b725ae77Skettenis extern int catch_exceptions_with_msg (struct ui_out *uiout,
998b725ae77Skettenis 			     	      catch_exceptions_ftype *func,
999b725ae77Skettenis 			     	      void *func_args,
1000b725ae77Skettenis 			     	      char *errstring, char **gdberrmsg,
1001b725ae77Skettenis 				      return_mask mask);
1002b725ae77Skettenis 
1003b725ae77Skettenis /* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero
1004b725ae77Skettenis    otherwize the result from CATCH_ERRORS_FTYPE is returned. It is
1005b725ae77Skettenis    probably useful for CATCH_ERRORS_FTYPE to always return a non-zero
1006b725ae77Skettenis    value. It's unfortunate that, catch_errors() does not return an
1007b725ae77Skettenis    indication of the exact exception that it caught - quit_flag might
1008b725ae77Skettenis    help.
1009b725ae77Skettenis 
1010b725ae77Skettenis    This function is superseeded by catch_exceptions().  */
1011b725ae77Skettenis 
1012b725ae77Skettenis typedef int (catch_errors_ftype) (void *);
1013b725ae77Skettenis extern int catch_errors (catch_errors_ftype *, void *, char *, return_mask);
1014b725ae77Skettenis 
1015b725ae77Skettenis /* Template to catch_errors() that wraps calls to command
1016b725ae77Skettenis    functions. */
1017b725ae77Skettenis 
1018b725ae77Skettenis typedef void (catch_command_errors_ftype) (char *, int);
1019b725ae77Skettenis extern int catch_command_errors (catch_command_errors_ftype *func, char *command, int from_tty, return_mask);
1020b725ae77Skettenis 
1021b725ae77Skettenis extern void warning (const char *, ...) ATTR_FORMAT (printf, 1, 2);
1022b725ae77Skettenis 
1023b725ae77Skettenis extern void vwarning (const char *, va_list args);
1024b725ae77Skettenis 
1025b725ae77Skettenis /* List of known OS ABIs.  If you change this, make sure to update the
1026b725ae77Skettenis    table in osabi.c.  */
1027b725ae77Skettenis enum gdb_osabi
1028b725ae77Skettenis {
1029b725ae77Skettenis   GDB_OSABI_UNINITIALIZED = -1, /* For struct gdbarch_info.  */
1030b725ae77Skettenis 
1031b725ae77Skettenis   GDB_OSABI_UNKNOWN = 0,	/* keep this zero */
1032b725ae77Skettenis 
1033b725ae77Skettenis   GDB_OSABI_SVR4,
1034b725ae77Skettenis   GDB_OSABI_HURD,
1035b725ae77Skettenis   GDB_OSABI_SOLARIS,
1036b725ae77Skettenis   GDB_OSABI_OSF1,
1037b725ae77Skettenis   GDB_OSABI_LINUX,
1038b725ae77Skettenis   GDB_OSABI_FREEBSD_AOUT,
1039b725ae77Skettenis   GDB_OSABI_FREEBSD_ELF,
1040b725ae77Skettenis   GDB_OSABI_NETBSD_AOUT,
1041b725ae77Skettenis   GDB_OSABI_NETBSD_ELF,
1042b725ae77Skettenis   GDB_OSABI_OPENBSD_ELF,
1043b725ae77Skettenis   GDB_OSABI_WINCE,
1044b725ae77Skettenis   GDB_OSABI_GO32,
1045b725ae77Skettenis   GDB_OSABI_NETWARE,
1046b725ae77Skettenis   GDB_OSABI_IRIX,
1047b725ae77Skettenis   GDB_OSABI_LYNXOS,
1048b725ae77Skettenis   GDB_OSABI_INTERIX,
1049b725ae77Skettenis   GDB_OSABI_HPUX_ELF,
1050b725ae77Skettenis   GDB_OSABI_HPUX_SOM,
1051b725ae77Skettenis 
1052b725ae77Skettenis   GDB_OSABI_ARM_EABI_V1,
1053b725ae77Skettenis   GDB_OSABI_ARM_EABI_V2,
1054b725ae77Skettenis   GDB_OSABI_ARM_APCS,
1055b725ae77Skettenis   GDB_OSABI_QNXNTO,
1056b725ae77Skettenis 
1057b725ae77Skettenis   GDB_OSABI_CYGWIN,
1058b725ae77Skettenis 
1059b725ae77Skettenis   GDB_OSABI_INVALID		/* keep this last */
1060b725ae77Skettenis };
1061e93f7393Sniklas 
1062e93f7393Sniklas /* Global functions from other, non-gdb GNU thingies.
1063e93f7393Sniklas    Libiberty thingies are no longer declared here.  We include libiberty.h
1064e93f7393Sniklas    above, instead.  */
1065e93f7393Sniklas 
1066e93f7393Sniklas /* From other system libraries */
1067e93f7393Sniklas 
1068e93f7393Sniklas #ifdef HAVE_STDDEF_H
1069e93f7393Sniklas #include <stddef.h>
1070e93f7393Sniklas #endif
1071e93f7393Sniklas 
1072e93f7393Sniklas #ifdef HAVE_STDLIB_H
1073e93f7393Sniklas #include <stdlib.h>
1074e93f7393Sniklas #endif
1075e93f7393Sniklas #ifndef min
1076e93f7393Sniklas #define min(a, b) ((a) < (b) ? (a) : (b))
1077e93f7393Sniklas #endif
1078e93f7393Sniklas #ifndef max
1079e93f7393Sniklas #define max(a, b) ((a) > (b) ? (a) : (b))
1080e93f7393Sniklas #endif
1081e93f7393Sniklas 
1082e93f7393Sniklas 
1083e93f7393Sniklas #ifndef atof
1084b725ae77Skettenis extern double atof (const char *);	/* X3.159-1989  4.10.1.1 */
1085e93f7393Sniklas #endif
1086e93f7393Sniklas 
1087e93f7393Sniklas /* Various possibilities for alloca.  */
1088e93f7393Sniklas #ifndef alloca
1089e93f7393Sniklas #ifdef __GNUC__
1090e93f7393Sniklas #define alloca __builtin_alloca
1091e93f7393Sniklas #else /* Not GNU C */
1092b725ae77Skettenis #ifdef HAVE_ALLOCA_H
1093b725ae77Skettenis #include <alloca.h>
1094b725ae77Skettenis #else
1095b725ae77Skettenis #ifdef _AIX
1096b725ae77Skettenis #pragma alloca
1097b725ae77Skettenis #else
1098e93f7393Sniklas 
1099e93f7393Sniklas /* We need to be careful not to declare this in a way which conflicts with
1100e93f7393Sniklas    bison.  Bison never declares it as char *, but under various circumstances
1101e93f7393Sniklas    (like __hpux) we need to use void *.  */
1102e93f7393Sniklas extern void *alloca ();
1103b725ae77Skettenis #endif /* Not _AIX */
1104b725ae77Skettenis #endif /* Not HAVE_ALLOCA_H */
1105e93f7393Sniklas #endif /* Not GNU C */
1106e93f7393Sniklas #endif /* alloca not defined */
1107e93f7393Sniklas 
1108b725ae77Skettenis /* Dynamic target-system-dependent parameters for GDB. */
1109b725ae77Skettenis #include "gdbarch.h"
1110e93f7393Sniklas 
1111b725ae77Skettenis /* Maximum size of a register.  Something small, but large enough for
1112b725ae77Skettenis    all known ISAs.  If it turns out to be too small, make it bigger.  */
1113e93f7393Sniklas 
1114b725ae77Skettenis enum { MAX_REGISTER_SIZE = 16 };
1115e93f7393Sniklas 
1116b725ae77Skettenis /* Static target-system-dependent parameters for GDB. */
1117e93f7393Sniklas 
1118e93f7393Sniklas /* Number of bits in a char or unsigned char for the target machine.
1119e93f7393Sniklas    Just like CHAR_BIT in <limits.h> but describes the target machine.  */
1120e93f7393Sniklas #if !defined (TARGET_CHAR_BIT)
1121e93f7393Sniklas #define TARGET_CHAR_BIT 8
1122e93f7393Sniklas #endif
1123e93f7393Sniklas 
1124e93f7393Sniklas /* If we picked up a copy of CHAR_BIT from a configuration file
1125e93f7393Sniklas    (which may get it by including <limits.h>) then use it to set
1126e93f7393Sniklas    the number of bits in a host char.  If not, use the same size
1127e93f7393Sniklas    as the target. */
1128e93f7393Sniklas 
1129e93f7393Sniklas #if defined (CHAR_BIT)
1130e93f7393Sniklas #define HOST_CHAR_BIT CHAR_BIT
1131e93f7393Sniklas #else
1132e93f7393Sniklas #define HOST_CHAR_BIT TARGET_CHAR_BIT
1133e93f7393Sniklas #endif
1134e93f7393Sniklas 
1135e93f7393Sniklas /* The bit byte-order has to do just with numbering of bits in
1136e93f7393Sniklas    debugging symbols and such.  Conceptually, it's quite separate
1137e93f7393Sniklas    from byte/word byte order.  */
1138e93f7393Sniklas 
1139e93f7393Sniklas #if !defined (BITS_BIG_ENDIAN)
1140b725ae77Skettenis #define BITS_BIG_ENDIAN (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
1141b725ae77Skettenis #endif
1142e93f7393Sniklas 
1143e93f7393Sniklas /* In findvar.c.  */
1144e93f7393Sniklas 
1145b725ae77Skettenis extern LONGEST extract_signed_integer (const void *, int);
1146e93f7393Sniklas 
1147b725ae77Skettenis extern ULONGEST extract_unsigned_integer (const void *, int);
1148e93f7393Sniklas 
1149b725ae77Skettenis extern int extract_long_unsigned_integer (const void *, int, LONGEST *);
1150e93f7393Sniklas 
1151b725ae77Skettenis extern CORE_ADDR extract_typed_address (const void *buf, struct type *type);
1152e93f7393Sniklas 
1153b725ae77Skettenis extern void store_signed_integer (void *, int, LONGEST);
1154e93f7393Sniklas 
1155b725ae77Skettenis extern void store_unsigned_integer (void *, int, ULONGEST);
1156e93f7393Sniklas 
1157b725ae77Skettenis extern void store_typed_address (void *buf, struct type *type, CORE_ADDR addr);
1158e93f7393Sniklas 
1159e93f7393Sniklas 
1160e93f7393Sniklas /* From valops.c */
1161e93f7393Sniklas 
1162b725ae77Skettenis extern CORE_ADDR push_bytes (CORE_ADDR, char *, int);
1163e93f7393Sniklas 
1164b725ae77Skettenis extern CORE_ADDR push_word (CORE_ADDR, ULONGEST);
1165e93f7393Sniklas 
1166e93f7393Sniklas extern int watchdog;
1167e93f7393Sniklas 
1168e93f7393Sniklas /* Hooks for alternate command interfaces.  */
1169e93f7393Sniklas 
1170b725ae77Skettenis /* The name of the interpreter if specified on the command line. */
1171b725ae77Skettenis extern char *interpreter_p;
1172b725ae77Skettenis 
1173b725ae77Skettenis /* If a given interpreter matches INTERPRETER_P then it should update
117463addd46Skettenis    deprecated_command_loop_hook and deprecated_init_ui_hook with the
117563addd46Skettenis    per-interpreter implementation.  */
117663addd46Skettenis /* FIXME: deprecated_command_loop_hook and deprecated_init_ui_hook
117763addd46Skettenis    should be moved here. */
1178b725ae77Skettenis 
1179e93f7393Sniklas struct target_waitstatus;
1180e93f7393Sniklas struct cmd_list_element;
1181e93f7393Sniklas 
118263addd46Skettenis extern void (*deprecated_pre_add_symbol_hook) (const char *);
118363addd46Skettenis extern void (*deprecated_post_add_symbol_hook) (void);
118463addd46Skettenis extern void (*selected_frame_level_changed_hook) (int);
118563addd46Skettenis extern int (*deprecated_ui_loop_hook) (int signo);
118663addd46Skettenis extern void (*deprecated_init_ui_hook) (char *argv0);
118763addd46Skettenis extern void (*deprecated_command_loop_hook) (void);
118863addd46Skettenis extern void (*deprecated_show_load_progress) (const char *section,
1189b725ae77Skettenis 					      unsigned long section_sent,
1190b725ae77Skettenis 					      unsigned long section_size,
1191b725ae77Skettenis 					      unsigned long total_sent,
1192b725ae77Skettenis 					      unsigned long total_size);
119363addd46Skettenis extern void (*deprecated_print_frame_info_listing_hook) (struct symtab * s,
1194e93f7393Sniklas 							 int line, int stopline,
1195b725ae77Skettenis 							 int noerror);
1196b725ae77Skettenis extern struct frame_info *parse_frame_specification (char *frame_exp);
119763addd46Skettenis extern int (*deprecated_query_hook) (const char *, va_list);
119863addd46Skettenis extern void (*deprecated_warning_hook) (const char *, va_list);
119963addd46Skettenis extern void (*deprecated_flush_hook) (struct ui_file * stream);
120063addd46Skettenis extern void (*deprecated_create_breakpoint_hook) (struct breakpoint * b);
120163addd46Skettenis extern void (*deprecated_delete_breakpoint_hook) (struct breakpoint * bpt);
120263addd46Skettenis extern void (*deprecated_modify_breakpoint_hook) (struct breakpoint * bpt);
120363addd46Skettenis extern void (*deprecated_interactive_hook) (void);
120463addd46Skettenis extern void (*deprecated_registers_changed_hook) (void);
120563addd46Skettenis extern void (*deprecated_readline_begin_hook) (char *,...);
120663addd46Skettenis extern char *(*deprecated_readline_hook) (char *);
120763addd46Skettenis extern void (*deprecated_readline_end_hook) (void);
120863addd46Skettenis extern void (*deprecated_register_changed_hook) (int regno);
120963addd46Skettenis extern void (*deprecated_memory_changed_hook) (CORE_ADDR addr, int len);
121063addd46Skettenis extern void (*deprecated_context_hook) (int);
121163addd46Skettenis extern ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
1212b725ae77Skettenis                                          struct target_waitstatus * status);
1213e93f7393Sniklas 
121463addd46Skettenis extern void (*deprecated_attach_hook) (void);
121563addd46Skettenis extern void (*deprecated_detach_hook) (void);
121663addd46Skettenis extern void (*deprecated_call_command_hook) (struct cmd_list_element * c,
1217b725ae77Skettenis 					     char *cmd, int from_tty);
1218e93f7393Sniklas 
121963addd46Skettenis extern void (*deprecated_set_hook) (struct cmd_list_element * c);
1220e93f7393Sniklas 
122163addd46Skettenis extern void (*deprecated_error_hook) (void);
1222e93f7393Sniklas 
122363addd46Skettenis extern void (*deprecated_error_begin_hook) (void);
1224b725ae77Skettenis 
122563addd46Skettenis extern int (*deprecated_ui_load_progress_hook) (const char *section,
122663addd46Skettenis 						unsigned long num);
1227e93f7393Sniklas 
1228e93f7393Sniklas 
1229e93f7393Sniklas /* Inhibit window interface if non-zero. */
1230e93f7393Sniklas 
1231e93f7393Sniklas extern int use_windows;
1232e93f7393Sniklas 
1233e93f7393Sniklas /* Symbolic definitions of filename-related things.  */
1234e93f7393Sniklas /* FIXME, this doesn't work very well if host and executable
1235e93f7393Sniklas    filesystems conventions are different.  */
1236e93f7393Sniklas 
1237e93f7393Sniklas #ifndef DIRNAME_SEPARATOR
1238e93f7393Sniklas #define DIRNAME_SEPARATOR ':'
1239e93f7393Sniklas #endif
1240e93f7393Sniklas 
1241e93f7393Sniklas #ifndef SLASH_STRING
1242e93f7393Sniklas #define SLASH_STRING "/"
1243e93f7393Sniklas #endif
1244b725ae77Skettenis 
1245b725ae77Skettenis #ifdef __MSDOS__
1246b725ae77Skettenis # define CANT_FORK
1247b725ae77Skettenis # define GLOBAL_CURDIR
1248e93f7393Sniklas #endif
1249e93f7393Sniklas 
1250b725ae77Skettenis /* Provide default definitions of PIDGET, TIDGET, and MERGEPID.
1251b725ae77Skettenis    The name ``TIDGET'' is a historical accident.  Many uses of TIDGET
1252b725ae77Skettenis    in the code actually refer to a lightweight process id, i.e,
1253b725ae77Skettenis    something that can be considered a process id in its own right for
1254b725ae77Skettenis    certain purposes.  */
1255b725ae77Skettenis 
1256b725ae77Skettenis #ifndef PIDGET
1257b725ae77Skettenis #define PIDGET(PTID) (ptid_get_pid (PTID))
1258b725ae77Skettenis #define TIDGET(PTID) (ptid_get_lwp (PTID))
1259b725ae77Skettenis #define MERGEPID(PID, TID) ptid_build (PID, TID, 0)
1260e93f7393Sniklas #endif
1261e93f7393Sniklas 
1262b725ae77Skettenis /* Define well known filenos if the system does not define them.  */
1263b725ae77Skettenis #ifndef STDIN_FILENO
1264b725ae77Skettenis #define STDIN_FILENO   0
1265b725ae77Skettenis #endif
1266b725ae77Skettenis #ifndef STDOUT_FILENO
1267b725ae77Skettenis #define STDOUT_FILENO  1
1268b725ae77Skettenis #endif
1269b725ae77Skettenis #ifndef STDERR_FILENO
1270b725ae77Skettenis #define STDERR_FILENO  2
1271b725ae77Skettenis #endif
1272b725ae77Skettenis 
1273b725ae77Skettenis /* If this definition isn't overridden by the header files, assume
1274b725ae77Skettenis    that isatty and fileno exist on this system.  */
1275b725ae77Skettenis #ifndef ISATTY
1276b725ae77Skettenis #define ISATTY(FP)	(isatty (fileno (FP)))
1277b725ae77Skettenis #endif
1278b725ae77Skettenis 
1279b725ae77Skettenis /* Ensure that V is aligned to an N byte boundary (B's assumed to be a
1280b725ae77Skettenis    power of 2).  Round up/down when necessary.  Examples of correct
1281b725ae77Skettenis    use include:
1282b725ae77Skettenis 
1283b725ae77Skettenis    addr = align_up (addr, 8); -- VALUE needs 8 byte alignment
1284b725ae77Skettenis    write_memory (addr, value, len);
1285b725ae77Skettenis    addr += len;
1286b725ae77Skettenis 
1287b725ae77Skettenis    and:
1288b725ae77Skettenis 
1289b725ae77Skettenis    sp = align_down (sp - len, 16); -- Keep SP 16 byte aligned
1290b725ae77Skettenis    write_memory (sp, value, len);
1291b725ae77Skettenis 
1292b725ae77Skettenis    Note that uses such as:
1293b725ae77Skettenis 
1294b725ae77Skettenis    write_memory (addr, value, len);
1295b725ae77Skettenis    addr += align_up (len, 8);
1296b725ae77Skettenis 
1297b725ae77Skettenis    and:
1298b725ae77Skettenis 
1299b725ae77Skettenis    sp -= align_up (len, 8);
1300b725ae77Skettenis    write_memory (sp, value, len);
1301b725ae77Skettenis 
1302b725ae77Skettenis    are typically not correct as they don't ensure that the address (SP
1303b725ae77Skettenis    or ADDR) is correctly aligned (relying on previous alignment to
1304b725ae77Skettenis    keep things right).  This is also why the methods are called
1305b725ae77Skettenis    "align_..." instead of "round_..." as the latter reads better with
1306b725ae77Skettenis    this incorrect coding style.  */
1307b725ae77Skettenis 
1308b725ae77Skettenis extern ULONGEST align_up (ULONGEST v, int n);
1309b725ae77Skettenis extern ULONGEST align_down (ULONGEST v, int n);
1310b725ae77Skettenis 
1311e93f7393Sniklas #endif /* #ifndef DEFS_H */
1312