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 /* * Languages represented in the symbol table and elsewhere.
98 This should probably be in language.h, but since enum's can't
99 be forward declared to satisfy opaque references before their
100 actual definition, needs to be here.
102 The constants here are in priority order. In particular,
103 demangling is attempted according to this order.
105 Note that there's ambiguity between the mangling schemes of some of
106 these languages, so some symbols could be successfully demangled by
107 several languages. For that reason, the constants here are sorted
108 in the order we'll attempt demangling them. For example: Rust uses
109 a C++-compatible mangling, so must come before C++; Ada must come
110 last (see ada_sniff_from_mangled_name). */
114 language_unknown
, /* Language not known */
116 language_objc
, /* Objective-C */
117 language_rust
, /* Rust */
118 language_cplus
, /* C++ */
120 language_go
, /* Go */
121 language_fortran
, /* Fortran */
122 language_m2
, /* Modula-2 */
123 language_asm
, /* Assembly language */
124 language_pascal
, /* Pascal */
125 language_opencl
, /* OpenCL */
126 language_minimal
, /* All other languages, minimal support only */
127 language_ada
, /* Ada */
131 /* The number of bits needed to represent all languages, with enough
132 padding to allow for reasonable growth. */
133 #define LANGUAGE_BITS 5
134 static_assert (nr_languages
<= (1 << LANGUAGE_BITS
));
136 /* The number of bytes needed to represent all languages. */
137 #define LANGUAGE_BYTES ((LANGUAGE_BITS + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT)
139 /* * A generic, not quite boolean, enumeration. This is used for
140 set/show commands in which the options are on/off/automatic. */
148 /* * Potential ways that a function can return a value of a given
151 enum return_value_convention
153 /* * Where the return value has been squeezed into one or more
155 RETURN_VALUE_REGISTER_CONVENTION
,
156 /* * Commonly known as the "struct return convention". The caller
157 passes an additional hidden first parameter to the caller. That
158 parameter contains the address at which the value being returned
159 should be stored. While typically, and historically, used for
160 large structs, this is convention is applied to values of many
162 RETURN_VALUE_STRUCT_CONVENTION
,
163 /* * Like the "struct return convention" above, but where the ABI
164 guarantees that the called function stores the address at which
165 the value being returned is stored in a well-defined location,
166 such as a register or memory slot in the stack frame. Don't use
167 this if the ABI doesn't explicitly guarantees this. */
168 RETURN_VALUE_ABI_RETURNS_ADDRESS
,
169 /* * Like the "struct return convention" above, but where the ABI
170 guarantees that the address at which the value being returned is
171 stored will be available in a well-defined location, such as a
172 register or memory slot in the stack frame. Don't use this if
173 the ABI doesn't explicitly guarantees this. */
174 RETURN_VALUE_ABI_PRESERVES_ADDRESS
,
177 /* Needed for various prototypes */
181 class frame_info_ptr
;
187 /* This really belong in utils.c (path-utils.c?), but it references some
188 globals that are currently only available to main.c. */
189 extern std::string
relocate_gdb_directory (const char *initial
, bool relocatable
);
193 typedef void initialize_file_ftype (void);
195 extern char *gdb_readline_wrapper (const char *);
197 extern const char *command_line_input (std::string
&cmd_line_buffer
,
198 const char *, const char *);
200 extern void print_prompt (void);
204 extern bool info_verbose
;
206 /* From printcmd.c */
208 extern void set_next_address (struct gdbarch
*, CORE_ADDR
);
210 extern int print_address_symbolic (struct gdbarch
*, CORE_ADDR
,
211 struct ui_file
*, int,
214 extern void print_address (struct gdbarch
*, CORE_ADDR
, struct ui_file
*);
215 extern const char *pc_prefix (CORE_ADDR
);
219 /* * Process memory area starting at ADDR with length SIZE. Area is
220 readable iff READ is non-zero, writable if WRITE is non-zero,
221 executable if EXEC is non-zero. Area is possibly changed against
222 its original file based copy if MODIFIED is non-zero.
224 MEMORY_TAGGED is true if the memory region contains memory tags, false
227 DATA is passed without changes from a caller. */
229 typedef int (*find_memory_region_ftype
) (CORE_ADDR addr
, unsigned long size
,
230 int read
, int write
, int exec
,
231 int modified
, bool memory_tagged
,
234 /* * Possible lvalue types. Like enum language, this should be in
235 value.h, but needs to be here for the same reason. */
243 /* * In a register. Registers are relative to a frame. */
245 /* * In a gdb internal variable. */
247 /* * Value encapsulates a callable defined in an extension language. */
249 /* * Part of a gdb internal variable (structure field). */
250 lval_internalvar_component
,
251 /* * Value's bits are fetched and stored using functions provided
256 /* * Parameters of the "info proc" command. */
260 /* * Display the default cmdline, cwd and exe outputs. */
263 /* * Display `info proc mappings'. */
266 /* * Display `info proc status'. */
269 /* * Display `info proc stat'. */
272 /* * Display `info proc cmdline'. */
275 /* * Display `info proc exe'. */
278 /* * Display `info proc cwd'. */
281 /* * Display `info proc files'. */
284 /* * Display all of the above. */
288 /* * Default radixes for input and output. Only some values supported. */
289 extern unsigned input_radix
;
290 extern unsigned output_radix
;
292 /* * Optional native machine support. Non-native (and possibly pure
293 multi-arch) targets do not need a "nm.h" file. This will be a
294 symlink to one of the nm-*.h files, built by the `configure'
301 /* Assume that fopen accepts the letter "b" in the mode string.
302 It is demanded by ISO C9X, and should be supported on all
303 platforms that claim to have a standard-conforming C library. On
304 true POSIX systems it will be ignored and have no effect. There
305 may still be systems without a standard-conforming C library where
306 an ISO C9X compiler (GCC) is available. Known examples are SunOS
307 4.x and 4.3BSD. This assumption means these systems are no longer
310 # include "fopen-bin.h"
313 /* * Convert a LONGEST to an int. This is used in contexts (e.g. number of
314 arguments to a function, number in a value history, register number, etc.)
315 where the value must not be larger than can fit in an int. */
317 extern int longest_to_int (LONGEST
);
319 /* Enumerate the requirements a symbol has in order to be evaluated.
320 These are listed in order of "strength" -- a later entry subsumes
321 earlier ones. This fine-grained distinction is important because
322 it allows for the evaluation of a TLS symbol during unwinding --
323 when unwinding one has access to registers, but not the frame
324 itself, because that is being constructed. */
326 enum symbol_needs_kind
328 /* No special requirements -- just memory. */
331 /* The symbol needs registers. */
332 SYMBOL_NEEDS_REGISTERS
,
334 /* The symbol needs a frame. */
338 /* Hooks for alternate command interfaces. */
340 struct target_waitstatus
;
341 struct cmd_list_element
;
343 extern void (*deprecated_pre_add_symbol_hook
) (const char *);
344 extern void (*deprecated_post_add_symbol_hook
) (void);
345 extern void (*selected_frame_level_changed_hook
) (int);
346 extern int (*deprecated_ui_loop_hook
) (int signo
);
347 extern void (*deprecated_show_load_progress
) (const char *section
,
348 unsigned long section_sent
,
349 unsigned long section_size
,
350 unsigned long total_sent
,
351 unsigned long total_size
);
352 extern void (*deprecated_print_frame_info_listing_hook
) (struct symtab
* s
,
356 extern int (*deprecated_query_hook
) (const char *, va_list)
357 ATTRIBUTE_FPTR_PRINTF(1,0);
358 extern void (*deprecated_readline_begin_hook
) (const char *, ...)
359 ATTRIBUTE_FPTR_PRINTF_1
;
360 extern char *(*deprecated_readline_hook
) (const char *);
361 extern void (*deprecated_readline_end_hook
) (void);
362 extern void (*deprecated_context_hook
) (int);
363 extern ptid_t (*deprecated_target_wait_hook
) (ptid_t ptid
,
364 struct target_waitstatus
*status
,
367 extern void (*deprecated_attach_hook
) (void);
368 extern void (*deprecated_detach_hook
) (void);
369 extern void (*deprecated_call_command_hook
) (struct cmd_list_element
* c
,
370 const char *cmd
, int from_tty
);
372 extern int (*deprecated_ui_load_progress_hook
) (const char *section
,
375 /* If this definition isn't overridden by the header files, assume
376 that isatty and fileno exist on this system. */
378 #define ISATTY(FP) (isatty (fileno (FP)))
381 /* * A width that can achieve a better legibility for GDB MI mode. */
382 #define GDB_MI_MSG_WIDTH 80
384 /* * Special block numbers */
390 FIRST_LOCAL_BLOCK
= 2
393 /* User selection used in observable.h and multiple print functions. */
395 enum user_selected_what_flag
397 /* Inferior selected. */
398 USER_SELECTED_INFERIOR
= 1 << 1,
400 /* Thread selected. */
401 USER_SELECTED_THREAD
= 1 << 2,
403 /* Frame selected. */
404 USER_SELECTED_FRAME
= 1 << 3
406 DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag
, user_selected_what
);
410 #endif /* #ifndef DEFS_H */