]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/defs.h
gdb: don't include gdbsupport/array-view.h in defs.h
[thirdparty/binutils-gdb.git] / gdb / defs.h
1 /* Basic, host-specific, and target-specific definitions for GDB.
2 Copyright (C) 1986-2024 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
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.
10
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.
15
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/>. */
18
19 #ifndef DEFS_H
20 #define DEFS_H
21
22 #ifdef GDBSERVER
23 # error gdbserver should not include gdb/defs.h
24 #endif
25
26 #include "gdbsupport/common-defs.h"
27
28 #undef PACKAGE
29 #undef PACKAGE_NAME
30 #undef PACKAGE_VERSION
31 #undef PACKAGE_STRING
32 #undef PACKAGE_TARNAME
33
34 #include <config.h>
35 #include "bfd.h"
36
37 #include <sys/types.h>
38 #include <climits>
39
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
46 libdecnumber.
47
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
53
54 #include <unistd.h>
55
56 #include <fcntl.h>
57
58 #include "gdb_wchar.h"
59
60 #include "ui-file.h"
61
62 #include "gdbsupport/host-defs.h"
63 #include "gdbsupport/enum-flags.h"
64
65 /* Just in case they're not defined in stdio.h. */
66
67 #ifndef SEEK_SET
68 #define SEEK_SET 0
69 #endif
70 #ifndef SEEK_CUR
71 #define SEEK_CUR 1
72 #endif
73
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. */
79
80 #ifndef O_BINARY
81 #define O_BINARY 0
82 #endif
83
84 /* * System root path, used to find libraries etc. */
85 extern std::string gdb_sysroot;
86
87 /* * GDB datadir, used to store data files. */
88 extern std::string gdb_datadir;
89
90 /* * If not empty, the possibly relocated path to python's "lib" directory
91 specified with --with-python. */
92 extern std::string python_libdir;
93
94 /* * Search path for separate debug files. */
95 extern std::string debug_file_directory;
96
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.
101
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.
106
107 These functions use the extension_language_ops API to allow extension
108 language(s) and GDB SIGINT handling to coexist seamlessly. */
109
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);
115
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;
127
128 /* The default quit handler. Checks whether Ctrl-C was pressed, and
129 if so:
130
131 - If GDB owns the terminal, throws a quit exception.
132
133 - If GDB does not own the terminal, forwards the Ctrl-C to the
134 target.
135 */
136 extern void default_quit_handler (void);
137
138 /* Flag that function quit should call quit_force. */
139 extern volatile bool sync_quit_force_run;
140
141 /* Set sync_quit_force_run and also call set_quit_flag(). */
142 extern void set_force_quit_flag ();
143
144 extern void quit (void);
145
146 /* Helper for the QUIT macro. */
147
148 extern void maybe_quit (void);
149
150 /* Check whether a Ctrl-C was typed, and if so, call the current quit
151 handler. */
152 #define QUIT maybe_quit ()
153
154 /* Set the serial event associated with the quit flag. */
155 extern void quit_serial_event_set (void);
156
157 /* Clear the serial event associated with the quit flag. */
158 extern void quit_serial_event_clear (void);
159
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.
164
165 The constants here are in priority order. In particular,
166 demangling is attempted according to this order.
167
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). */
174
175 enum language
176 {
177 language_unknown, /* Language not known */
178 language_c, /* C */
179 language_objc, /* Objective-C */
180 language_rust, /* Rust */
181 language_cplus, /* C++ */
182 language_d, /* D */
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 */
191 nr_languages
192 };
193
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));
198
199 /* The number of bytes needed to represent all languages. */
200 #define LANGUAGE_BYTES ((LANGUAGE_BITS + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT)
201
202 enum precision_type
203 {
204 single_precision,
205 double_precision,
206 unspecified_precision
207 };
208
209 /* * A generic, not quite boolean, enumeration. This is used for
210 set/show commands in which the options are on/off/automatic. */
211 enum auto_boolean
212 {
213 AUTO_BOOLEAN_TRUE,
214 AUTO_BOOLEAN_FALSE,
215 AUTO_BOOLEAN_AUTO
216 };
217
218 /* * Potential ways that a function can return a value of a given
219 type. */
220
221 enum return_value_convention
222 {
223 /* * Where the return value has been squeezed into one or more
224 registers. */
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
231 different types. */
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,
245 };
246
247 /* Needed for various prototypes */
248
249 struct symtab;
250 struct breakpoint;
251 class frame_info_ptr;
252 struct gdbarch;
253 struct value;
254
255 /* From main.c. */
256
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);
260
261 \f
262 /* Annotation stuff. */
263
264 extern int annotation_level; /* in stack.c */
265 \f
266
267 /* From symfile.c */
268
269 extern void symbol_file_command (const char *, int);
270
271 /* From top.c */
272
273 typedef void initialize_file_ftype (void);
274
275 extern char *gdb_readline_wrapper (const char *);
276
277 extern const char *command_line_input (std::string &cmd_line_buffer,
278 const char *, const char *);
279
280 extern void print_prompt (void);
281
282 struct ui;
283
284 extern bool info_verbose;
285
286 /* From printcmd.c */
287
288 extern void set_next_address (struct gdbarch *, CORE_ADDR);
289
290 extern int print_address_symbolic (struct gdbarch *, CORE_ADDR,
291 struct ui_file *, int,
292 const char *);
293
294 extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *);
295 extern const char *pc_prefix (CORE_ADDR);
296
297 /* From exec.c */
298
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.
303
304 MEMORY_TAGGED is true if the memory region contains memory tags, false
305 otherwise.
306
307 DATA is passed without changes from a caller. */
308
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,
312 void *data);
313
314 /* * Possible lvalue types. Like enum language, this should be in
315 value.h, but needs to be here for the same reason. */
316
317 enum lval_type
318 {
319 /* * Not an lval. */
320 not_lval,
321 /* * In memory. */
322 lval_memory,
323 /* * In a register. Registers are relative to a frame. */
324 lval_register,
325 /* * In a gdb internal variable. */
326 lval_internalvar,
327 /* * Value encapsulates a callable defined in an extension language. */
328 lval_xcallable,
329 /* * Part of a gdb internal variable (structure field). */
330 lval_internalvar_component,
331 /* * Value's bits are fetched and stored using functions provided
332 by its creator. */
333 lval_computed
334 };
335
336 /* * Parameters of the "info proc" command. */
337
338 enum info_proc_what
339 {
340 /* * Display the default cmdline, cwd and exe outputs. */
341 IP_MINIMAL,
342
343 /* * Display `info proc mappings'. */
344 IP_MAPPINGS,
345
346 /* * Display `info proc status'. */
347 IP_STATUS,
348
349 /* * Display `info proc stat'. */
350 IP_STAT,
351
352 /* * Display `info proc cmdline'. */
353 IP_CMDLINE,
354
355 /* * Display `info proc exe'. */
356 IP_EXE,
357
358 /* * Display `info proc cwd'. */
359 IP_CWD,
360
361 /* * Display `info proc files'. */
362 IP_FILES,
363
364 /* * Display all of the above. */
365 IP_ALL
366 };
367
368 /* * Default radixes for input and output. Only some values supported. */
369 extern unsigned input_radix;
370 extern unsigned output_radix;
371
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'
375 script. */
376
377 #ifdef GDB_NM_FILE
378 #include "nm.h"
379 #endif
380
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
388 supported. */
389 #ifndef FOPEN_RB
390 # include "fopen-bin.h"
391 #endif
392
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. */
396
397 extern int longest_to_int (LONGEST);
398
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. */
405
406 enum symbol_needs_kind
407 {
408 /* No special requirements -- just memory. */
409 SYMBOL_NEEDS_NONE,
410
411 /* The symbol needs registers. */
412 SYMBOL_NEEDS_REGISTERS,
413
414 /* The symbol needs a frame. */
415 SYMBOL_NEEDS_FRAME
416 };
417
418 /* Hooks for alternate command interfaces. */
419
420 struct target_waitstatus;
421 struct cmd_list_element;
422
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,
433 int line,
434 int stopline,
435 int noerror);
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,
445 int options);
446
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);
451
452 extern int (*deprecated_ui_load_progress_hook) (const char *section,
453 unsigned long num);
454
455 /* If this definition isn't overridden by the header files, assume
456 that isatty and fileno exist on this system. */
457 #ifndef ISATTY
458 #define ISATTY(FP) (isatty (fileno (FP)))
459 #endif
460
461 /* * A width that can achieve a better legibility for GDB MI mode. */
462 #define GDB_MI_MSG_WIDTH 80
463
464 /* * Special block numbers */
465
466 enum block_enum
467 {
468 GLOBAL_BLOCK = 0,
469 STATIC_BLOCK = 1,
470 FIRST_LOCAL_BLOCK = 2
471 };
472
473 /* User selection used in observable.h and multiple print functions. */
474
475 enum user_selected_what_flag
476 {
477 /* Inferior selected. */
478 USER_SELECTED_INFERIOR = 1 << 1,
479
480 /* Thread selected. */
481 USER_SELECTED_THREAD = 1 << 2,
482
483 /* Frame selected. */
484 USER_SELECTED_FRAME = 1 << 3
485 };
486 DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
487
488 #include "utils.h"
489
490 #endif /* #ifndef DEFS_H */