1 /* Basic, host-specific, and target-specific definitions for GDB.
2 Copyright (C) 1986-2024 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 # error gdbserver should not include gdb/defs.h
26 #include "gdbsupport/common-defs.h"
30 #undef PACKAGE_VERSION
32 #undef PACKAGE_TARNAME
37 #include <sys/types.h>
40 /* The libdecnumber library, on which GDB depends, includes a header file
41 called gstdint.h instead of relying directly on stdint.h. GDB, on the
42 other hand, includes stdint.h directly, relying on the fact that gnulib
43 generates a copy if the system doesn't provide one or if it is missing
44 some features. Unfortunately, gstdint.h and stdint.h cannot be included
45 at the same time, which may happen when we include a file from
48 The following macro definition effectively prevents the inclusion of
49 gstdint.h, as all the definitions it provides are guarded against
50 the GCC_GENERATED_STDINT_H macro. We already have gnulib/stdint.h
51 included, so it's ok to blank out gstdint.h. */
52 #define GCC_GENERATED_STDINT_H 1
58 #include "gdb_wchar.h"
62 #include "gdbsupport/host-defs.h"
63 #include "gdbsupport/enum-flags.h"
65 /* Just in case they're not defined in stdio.h. */
74 /* The O_BINARY flag is defined in fcntl.h on some non-Posix platforms.
75 It is used as an access modifier in calls to open(), where it acts
76 similarly to the "b" character in fopen()'s MODE argument. On Posix
77 platforms it should be a no-op, so it is defined as 0 here. This
78 ensures that the symbol may be used freely elsewhere in gdb. */
84 /* * System root path, used to find libraries etc. */
85 extern std::string gdb_sysroot
;
87 /* * GDB datadir, used to store data files. */
88 extern std::string gdb_datadir
;
90 /* * If not empty, the possibly relocated path to python's "lib" directory
91 specified with --with-python. */
92 extern std::string python_libdir
;
94 /* * Search path for separate debug files. */
95 extern std::string debug_file_directory
;
97 /* GDB's SIGINT handler basically sets a flag; code that might take a
98 long time before it gets back to the event loop, and which ought to
99 be interruptible, checks this flag using the QUIT macro, which, if
100 GDB has the terminal, throws a quit exception.
102 In addition to setting a flag, the SIGINT handler also marks a
103 select/poll-able file descriptor as read-ready. That is used by
104 interruptible_select in order to support interrupting blocking I/O
105 in a race-free manner.
107 These functions use the extension_language_ops API to allow extension
108 language(s) and GDB SIGINT handling to coexist seamlessly. */
110 /* * Evaluate to non-zero if the quit flag is set, zero otherwise. This
111 will clear the quit flag as a side effect. */
112 extern int check_quit_flag (void);
113 /* * Set the quit flag. */
114 extern void set_quit_flag (void);
116 /* The current quit handler (and its type). This is called from the
117 QUIT macro. See default_quit_handler below for default behavior.
118 Parts of GDB temporarily override this to e.g., completely suppress
119 Ctrl-C because it would not be safe to throw. E.g., normally, you
120 wouldn't want to quit between a RSP command and its response, as
121 that would break the communication with the target, but you may
122 still want to intercept the Ctrl-C and offer to disconnect if the
123 user presses Ctrl-C multiple times while the target is stuck
124 waiting for the wedged remote stub. */
125 typedef void (quit_handler_ftype
) (void);
126 extern quit_handler_ftype
*quit_handler
;
128 /* The default quit handler. Checks whether Ctrl-C was pressed, and
131 - If GDB owns the terminal, throws a quit exception.
133 - If GDB does not own the terminal, forwards the Ctrl-C to the
136 extern void default_quit_handler (void);
138 /* Flag that function quit should call quit_force. */
139 extern volatile bool sync_quit_force_run
;
141 /* Set sync_quit_force_run and also call set_quit_flag(). */
142 extern void set_force_quit_flag ();
144 extern void quit (void);
146 /* Helper for the QUIT macro. */
148 extern void maybe_quit (void);
150 /* Check whether a Ctrl-C was typed, and if so, call the current quit
152 #define QUIT maybe_quit ()
154 /* Set the serial event associated with the quit flag. */
155 extern void quit_serial_event_set (void);
157 /* Clear the serial event associated with the quit flag. */
158 extern void quit_serial_event_clear (void);
160 /* * Languages represented in the symbol table and elsewhere.
161 This should probably be in language.h, but since enum's can't
162 be forward declared to satisfy opaque references before their
163 actual definition, needs to be here.
165 The constants here are in priority order. In particular,
166 demangling is attempted according to this order.
168 Note that there's ambiguity between the mangling schemes of some of
169 these languages, so some symbols could be successfully demangled by
170 several languages. For that reason, the constants here are sorted
171 in the order we'll attempt demangling them. For example: Rust uses
172 a C++-compatible mangling, so must come before C++; Ada must come
173 last (see ada_sniff_from_mangled_name). */
177 language_unknown
, /* Language not known */
179 language_objc
, /* Objective-C */
180 language_rust
, /* Rust */
181 language_cplus
, /* C++ */
183 language_go
, /* Go */
184 language_fortran
, /* Fortran */
185 language_m2
, /* Modula-2 */
186 language_asm
, /* Assembly language */
187 language_pascal
, /* Pascal */
188 language_opencl
, /* OpenCL */
189 language_minimal
, /* All other languages, minimal support only */
190 language_ada
, /* Ada */
194 /* The number of bits needed to represent all languages, with enough
195 padding to allow for reasonable growth. */
196 #define LANGUAGE_BITS 5
197 static_assert (nr_languages
<= (1 << LANGUAGE_BITS
));
199 /* The number of bytes needed to represent all languages. */
200 #define LANGUAGE_BYTES ((LANGUAGE_BITS + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT)
206 unspecified_precision
209 /* * A generic, not quite boolean, enumeration. This is used for
210 set/show commands in which the options are on/off/automatic. */
218 /* * Potential ways that a function can return a value of a given
221 enum return_value_convention
223 /* * Where the return value has been squeezed into one or more
225 RETURN_VALUE_REGISTER_CONVENTION
,
226 /* * Commonly known as the "struct return convention". The caller
227 passes an additional hidden first parameter to the caller. That
228 parameter contains the address at which the value being returned
229 should be stored. While typically, and historically, used for
230 large structs, this is convention is applied to values of many
232 RETURN_VALUE_STRUCT_CONVENTION
,
233 /* * Like the "struct return convention" above, but where the ABI
234 guarantees that the called function stores the address at which
235 the value being returned is stored in a well-defined location,
236 such as a register or memory slot in the stack frame. Don't use
237 this if the ABI doesn't explicitly guarantees this. */
238 RETURN_VALUE_ABI_RETURNS_ADDRESS
,
239 /* * Like the "struct return convention" above, but where the ABI
240 guarantees that the address at which the value being returned is
241 stored will be available in a well-defined location, such as a
242 register or memory slot in the stack frame. Don't use this if
243 the ABI doesn't explicitly guarantees this. */
244 RETURN_VALUE_ABI_PRESERVES_ADDRESS
,
247 /* Needed for various prototypes */
251 class frame_info_ptr
;
257 /* This really belong in utils.c (path-utils.c?), but it references some
258 globals that are currently only available to main.c. */
259 extern std::string
relocate_gdb_directory (const char *initial
, bool relocatable
);
262 /* Annotation stuff. */
264 extern int annotation_level
; /* in stack.c */
269 extern void symbol_file_command (const char *, int);
273 typedef void initialize_file_ftype (void);
275 extern char *gdb_readline_wrapper (const char *);
277 extern const char *command_line_input (std::string
&cmd_line_buffer
,
278 const char *, const char *);
280 extern void print_prompt (void);
284 extern bool info_verbose
;
286 /* From printcmd.c */
288 extern void set_next_address (struct gdbarch
*, CORE_ADDR
);
290 extern int print_address_symbolic (struct gdbarch
*, CORE_ADDR
,
291 struct ui_file
*, int,
294 extern void print_address (struct gdbarch
*, CORE_ADDR
, struct ui_file
*);
295 extern const char *pc_prefix (CORE_ADDR
);
299 /* * Process memory area starting at ADDR with length SIZE. Area is
300 readable iff READ is non-zero, writable if WRITE is non-zero,
301 executable if EXEC is non-zero. Area is possibly changed against
302 its original file based copy if MODIFIED is non-zero.
304 MEMORY_TAGGED is true if the memory region contains memory tags, false
307 DATA is passed without changes from a caller. */
309 typedef int (*find_memory_region_ftype
) (CORE_ADDR addr
, unsigned long size
,
310 int read
, int write
, int exec
,
311 int modified
, bool memory_tagged
,
314 /* * Possible lvalue types. Like enum language, this should be in
315 value.h, but needs to be here for the same reason. */
323 /* * In a register. Registers are relative to a frame. */
325 /* * In a gdb internal variable. */
327 /* * Value encapsulates a callable defined in an extension language. */
329 /* * Part of a gdb internal variable (structure field). */
330 lval_internalvar_component
,
331 /* * Value's bits are fetched and stored using functions provided
336 /* * Parameters of the "info proc" command. */
340 /* * Display the default cmdline, cwd and exe outputs. */
343 /* * Display `info proc mappings'. */
346 /* * Display `info proc status'. */
349 /* * Display `info proc stat'. */
352 /* * Display `info proc cmdline'. */
355 /* * Display `info proc exe'. */
358 /* * Display `info proc cwd'. */
361 /* * Display `info proc files'. */
364 /* * Display all of the above. */
368 /* * Default radixes for input and output. Only some values supported. */
369 extern unsigned input_radix
;
370 extern unsigned output_radix
;
372 /* * Optional native machine support. Non-native (and possibly pure
373 multi-arch) targets do not need a "nm.h" file. This will be a
374 symlink to one of the nm-*.h files, built by the `configure'
381 /* Assume that fopen accepts the letter "b" in the mode string.
382 It is demanded by ISO C9X, and should be supported on all
383 platforms that claim to have a standard-conforming C library. On
384 true POSIX systems it will be ignored and have no effect. There
385 may still be systems without a standard-conforming C library where
386 an ISO C9X compiler (GCC) is available. Known examples are SunOS
387 4.x and 4.3BSD. This assumption means these systems are no longer
390 # include "fopen-bin.h"
393 /* * Convert a LONGEST to an int. This is used in contexts (e.g. number of
394 arguments to a function, number in a value history, register number, etc.)
395 where the value must not be larger than can fit in an int. */
397 extern int longest_to_int (LONGEST
);
399 /* Enumerate the requirements a symbol has in order to be evaluated.
400 These are listed in order of "strength" -- a later entry subsumes
401 earlier ones. This fine-grained distinction is important because
402 it allows for the evaluation of a TLS symbol during unwinding --
403 when unwinding one has access to registers, but not the frame
404 itself, because that is being constructed. */
406 enum symbol_needs_kind
408 /* No special requirements -- just memory. */
411 /* The symbol needs registers. */
412 SYMBOL_NEEDS_REGISTERS
,
414 /* The symbol needs a frame. */
418 /* Hooks for alternate command interfaces. */
420 struct target_waitstatus
;
421 struct cmd_list_element
;
423 extern void (*deprecated_pre_add_symbol_hook
) (const char *);
424 extern void (*deprecated_post_add_symbol_hook
) (void);
425 extern void (*selected_frame_level_changed_hook
) (int);
426 extern int (*deprecated_ui_loop_hook
) (int signo
);
427 extern void (*deprecated_show_load_progress
) (const char *section
,
428 unsigned long section_sent
,
429 unsigned long section_size
,
430 unsigned long total_sent
,
431 unsigned long total_size
);
432 extern void (*deprecated_print_frame_info_listing_hook
) (struct symtab
* s
,
436 extern int (*deprecated_query_hook
) (const char *, va_list)
437 ATTRIBUTE_FPTR_PRINTF(1,0);
438 extern void (*deprecated_readline_begin_hook
) (const char *, ...)
439 ATTRIBUTE_FPTR_PRINTF_1
;
440 extern char *(*deprecated_readline_hook
) (const char *);
441 extern void (*deprecated_readline_end_hook
) (void);
442 extern void (*deprecated_context_hook
) (int);
443 extern ptid_t (*deprecated_target_wait_hook
) (ptid_t ptid
,
444 struct target_waitstatus
*status
,
447 extern void (*deprecated_attach_hook
) (void);
448 extern void (*deprecated_detach_hook
) (void);
449 extern void (*deprecated_call_command_hook
) (struct cmd_list_element
* c
,
450 const char *cmd
, int from_tty
);
452 extern int (*deprecated_ui_load_progress_hook
) (const char *section
,
455 /* If this definition isn't overridden by the header files, assume
456 that isatty and fileno exist on this system. */
458 #define ISATTY(FP) (isatty (fileno (FP)))
461 /* * A width that can achieve a better legibility for GDB MI mode. */
462 #define GDB_MI_MSG_WIDTH 80
464 /* * Special block numbers */
470 FIRST_LOCAL_BLOCK
= 2
473 /* User selection used in observable.h and multiple print functions. */
475 enum user_selected_what_flag
477 /* Inferior selected. */
478 USER_SELECTED_INFERIOR
= 1 << 1,
480 /* Thread selected. */
481 USER_SELECTED_THREAD
= 1 << 2,
483 /* Frame selected. */
484 USER_SELECTED_FRAME
= 1 << 3
486 DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag
, user_selected_what
);
490 #endif /* #ifndef DEFS_H */