]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/defs.h
gdb: remove enum precision_type
[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 /* * 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.
101
102 The constants here are in priority order. In particular,
103 demangling is attempted according to this order.
104
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). */
111
112 enum language
113 {
114 language_unknown, /* Language not known */
115 language_c, /* C */
116 language_objc, /* Objective-C */
117 language_rust, /* Rust */
118 language_cplus, /* C++ */
119 language_d, /* D */
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 */
128 nr_languages
129 };
130
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));
135
136 /* The number of bytes needed to represent all languages. */
137 #define LANGUAGE_BYTES ((LANGUAGE_BITS + HOST_CHAR_BIT - 1) / HOST_CHAR_BIT)
138
139 /* * A generic, not quite boolean, enumeration. This is used for
140 set/show commands in which the options are on/off/automatic. */
141 enum auto_boolean
142 {
143 AUTO_BOOLEAN_TRUE,
144 AUTO_BOOLEAN_FALSE,
145 AUTO_BOOLEAN_AUTO
146 };
147
148 /* * Potential ways that a function can return a value of a given
149 type. */
150
151 enum return_value_convention
152 {
153 /* * Where the return value has been squeezed into one or more
154 registers. */
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
161 different types. */
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,
175 };
176
177 /* Needed for various prototypes */
178
179 struct symtab;
180 struct breakpoint;
181 class frame_info_ptr;
182 struct gdbarch;
183 struct value;
184
185 /* From main.c. */
186
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);
190
191 /* From symfile.c */
192
193 extern void symbol_file_command (const char *, int);
194
195 /* From top.c */
196
197 typedef void initialize_file_ftype (void);
198
199 extern char *gdb_readline_wrapper (const char *);
200
201 extern const char *command_line_input (std::string &cmd_line_buffer,
202 const char *, const char *);
203
204 extern void print_prompt (void);
205
206 struct ui;
207
208 extern bool info_verbose;
209
210 /* From printcmd.c */
211
212 extern void set_next_address (struct gdbarch *, CORE_ADDR);
213
214 extern int print_address_symbolic (struct gdbarch *, CORE_ADDR,
215 struct ui_file *, int,
216 const char *);
217
218 extern void print_address (struct gdbarch *, CORE_ADDR, struct ui_file *);
219 extern const char *pc_prefix (CORE_ADDR);
220
221 /* From exec.c */
222
223 /* * Process memory area starting at ADDR with length SIZE. Area is
224 readable iff READ is non-zero, writable if WRITE is non-zero,
225 executable if EXEC is non-zero. Area is possibly changed against
226 its original file based copy if MODIFIED is non-zero.
227
228 MEMORY_TAGGED is true if the memory region contains memory tags, false
229 otherwise.
230
231 DATA is passed without changes from a caller. */
232
233 typedef int (*find_memory_region_ftype) (CORE_ADDR addr, unsigned long size,
234 int read, int write, int exec,
235 int modified, bool memory_tagged,
236 void *data);
237
238 /* * Possible lvalue types. Like enum language, this should be in
239 value.h, but needs to be here for the same reason. */
240
241 enum lval_type
242 {
243 /* * Not an lval. */
244 not_lval,
245 /* * In memory. */
246 lval_memory,
247 /* * In a register. Registers are relative to a frame. */
248 lval_register,
249 /* * In a gdb internal variable. */
250 lval_internalvar,
251 /* * Value encapsulates a callable defined in an extension language. */
252 lval_xcallable,
253 /* * Part of a gdb internal variable (structure field). */
254 lval_internalvar_component,
255 /* * Value's bits are fetched and stored using functions provided
256 by its creator. */
257 lval_computed
258 };
259
260 /* * Parameters of the "info proc" command. */
261
262 enum info_proc_what
263 {
264 /* * Display the default cmdline, cwd and exe outputs. */
265 IP_MINIMAL,
266
267 /* * Display `info proc mappings'. */
268 IP_MAPPINGS,
269
270 /* * Display `info proc status'. */
271 IP_STATUS,
272
273 /* * Display `info proc stat'. */
274 IP_STAT,
275
276 /* * Display `info proc cmdline'. */
277 IP_CMDLINE,
278
279 /* * Display `info proc exe'. */
280 IP_EXE,
281
282 /* * Display `info proc cwd'. */
283 IP_CWD,
284
285 /* * Display `info proc files'. */
286 IP_FILES,
287
288 /* * Display all of the above. */
289 IP_ALL
290 };
291
292 /* * Default radixes for input and output. Only some values supported. */
293 extern unsigned input_radix;
294 extern unsigned output_radix;
295
296 /* * Optional native machine support. Non-native (and possibly pure
297 multi-arch) targets do not need a "nm.h" file. This will be a
298 symlink to one of the nm-*.h files, built by the `configure'
299 script. */
300
301 #ifdef GDB_NM_FILE
302 #include "nm.h"
303 #endif
304
305 /* Assume that fopen accepts the letter "b" in the mode string.
306 It is demanded by ISO C9X, and should be supported on all
307 platforms that claim to have a standard-conforming C library. On
308 true POSIX systems it will be ignored and have no effect. There
309 may still be systems without a standard-conforming C library where
310 an ISO C9X compiler (GCC) is available. Known examples are SunOS
311 4.x and 4.3BSD. This assumption means these systems are no longer
312 supported. */
313 #ifndef FOPEN_RB
314 # include "fopen-bin.h"
315 #endif
316
317 /* * Convert a LONGEST to an int. This is used in contexts (e.g. number of
318 arguments to a function, number in a value history, register number, etc.)
319 where the value must not be larger than can fit in an int. */
320
321 extern int longest_to_int (LONGEST);
322
323 /* Enumerate the requirements a symbol has in order to be evaluated.
324 These are listed in order of "strength" -- a later entry subsumes
325 earlier ones. This fine-grained distinction is important because
326 it allows for the evaluation of a TLS symbol during unwinding --
327 when unwinding one has access to registers, but not the frame
328 itself, because that is being constructed. */
329
330 enum symbol_needs_kind
331 {
332 /* No special requirements -- just memory. */
333 SYMBOL_NEEDS_NONE,
334
335 /* The symbol needs registers. */
336 SYMBOL_NEEDS_REGISTERS,
337
338 /* The symbol needs a frame. */
339 SYMBOL_NEEDS_FRAME
340 };
341
342 /* Hooks for alternate command interfaces. */
343
344 struct target_waitstatus;
345 struct cmd_list_element;
346
347 extern void (*deprecated_pre_add_symbol_hook) (const char *);
348 extern void (*deprecated_post_add_symbol_hook) (void);
349 extern void (*selected_frame_level_changed_hook) (int);
350 extern int (*deprecated_ui_loop_hook) (int signo);
351 extern void (*deprecated_show_load_progress) (const char *section,
352 unsigned long section_sent,
353 unsigned long section_size,
354 unsigned long total_sent,
355 unsigned long total_size);
356 extern void (*deprecated_print_frame_info_listing_hook) (struct symtab * s,
357 int line,
358 int stopline,
359 int noerror);
360 extern int (*deprecated_query_hook) (const char *, va_list)
361 ATTRIBUTE_FPTR_PRINTF(1,0);
362 extern void (*deprecated_readline_begin_hook) (const char *, ...)
363 ATTRIBUTE_FPTR_PRINTF_1;
364 extern char *(*deprecated_readline_hook) (const char *);
365 extern void (*deprecated_readline_end_hook) (void);
366 extern void (*deprecated_context_hook) (int);
367 extern ptid_t (*deprecated_target_wait_hook) (ptid_t ptid,
368 struct target_waitstatus *status,
369 int options);
370
371 extern void (*deprecated_attach_hook) (void);
372 extern void (*deprecated_detach_hook) (void);
373 extern void (*deprecated_call_command_hook) (struct cmd_list_element * c,
374 const char *cmd, int from_tty);
375
376 extern int (*deprecated_ui_load_progress_hook) (const char *section,
377 unsigned long num);
378
379 /* If this definition isn't overridden by the header files, assume
380 that isatty and fileno exist on this system. */
381 #ifndef ISATTY
382 #define ISATTY(FP) (isatty (fileno (FP)))
383 #endif
384
385 /* * A width that can achieve a better legibility for GDB MI mode. */
386 #define GDB_MI_MSG_WIDTH 80
387
388 /* * Special block numbers */
389
390 enum block_enum
391 {
392 GLOBAL_BLOCK = 0,
393 STATIC_BLOCK = 1,
394 FIRST_LOCAL_BLOCK = 2
395 };
396
397 /* User selection used in observable.h and multiple print functions. */
398
399 enum user_selected_what_flag
400 {
401 /* Inferior selected. */
402 USER_SELECTED_INFERIOR = 1 << 1,
403
404 /* Thread selected. */
405 USER_SELECTED_THREAD = 1 << 2,
406
407 /* Frame selected. */
408 USER_SELECTED_FRAME = 1 << 3
409 };
410 DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
411
412 #include "utils.h"
413
414 #endif /* #ifndef DEFS_H */