bt-utils.h revision 1.1.1.3 1 1.1.1.2 christos /* Copyright (C) 2021-2024 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos This file is part of GDB.
4 1.1 christos
5 1.1 christos This program is free software; you can redistribute it and/or modify
6 1.1 christos it under the terms of the GNU General Public License as published by
7 1.1 christos the Free Software Foundation; either version 3 of the License, or
8 1.1 christos (at your option) any later version.
9 1.1 christos
10 1.1 christos This program is distributed in the hope that it will be useful,
11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 1.1 christos GNU General Public License for more details.
14 1.1 christos
15 1.1 christos You should have received a copy of the GNU General Public License
16 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 1.1 christos
18 1.1 christos /* Support for printing a backtrace when GDB hits an error. This is not
19 1.1 christos for printing backtraces of the inferior, but backtraces of GDB itself. */
20 1.1 christos
21 1.1.1.3 christos #ifndef GDB_BT_UTILS_H
22 1.1.1.3 christos #define GDB_BT_UTILS_H
23 1.1 christos
24 1.1 christos #ifdef HAVE_LIBBACKTRACE
25 1.1 christos # include "backtrace.h"
26 1.1 christos # include "backtrace-supported.h"
27 1.1 christos # if BACKTRACE_SUPPORTED && (! BACKTRACE_USES_MALLOC)
28 1.1 christos # define GDB_PRINT_INTERNAL_BACKTRACE
29 1.1 christos # define GDB_PRINT_INTERNAL_BACKTRACE_USING_LIBBACKTRACE
30 1.1 christos # endif
31 1.1 christos #endif
32 1.1 christos
33 1.1 christos #if defined HAVE_EXECINFO_H \
34 1.1 christos && defined HAVE_EXECINFO_BACKTRACE \
35 1.1.1.2 christos && !defined GDB_PRINT_INTERNAL_BACKTRACE_USING_LIBBACKTRACE
36 1.1 christos # include <execinfo.h>
37 1.1 christos # define GDB_PRINT_INTERNAL_BACKTRACE
38 1.1 christos # define GDB_PRINT_INTERNAL_BACKTRACE_USING_EXECINFO
39 1.1 christos #endif
40 1.1 christos
41 1.1 christos /* Define GDB_PRINT_INTERNAL_BACKTRACE_INIT_ON. This is a boolean value
42 1.1 christos that can be used as an initial value for a set/show user setting, where
43 1.1 christos the setting controls printing a GDB internal backtrace.
44 1.1 christos
45 1.1 christos If backtrace printing is supported then this will have the value true,
46 1.1 christos but if backtrace printing is not supported then this has the value
47 1.1 christos false. */
48 1.1 christos #ifdef GDB_PRINT_INTERNAL_BACKTRACE
49 1.1 christos # define GDB_PRINT_INTERNAL_BACKTRACE_INIT_ON true
50 1.1 christos #else
51 1.1 christos # define GDB_PRINT_INTERNAL_BACKTRACE_INIT_ON false
52 1.1 christos #endif
53 1.1 christos
54 1.1 christos /* Print a backtrace of the current GDB process to the current
55 1.1 christos gdb_stderr. The output is done in a signal async manner, so it is safe
56 1.1 christos to call from signal handlers. */
57 1.1 christos
58 1.1 christos extern void gdb_internal_backtrace ();
59 1.1 christos
60 1.1 christos /* A generic function that can be used as the set function for any set
61 1.1 christos command that enables printing of an internal backtrace. Command C must
62 1.1 christos be a boolean set command.
63 1.1 christos
64 1.1 christos If GDB doesn't support printing a backtrace, and the user has tried to
65 1.1 christos set the variable associated with command C to true, then the associated
66 1.1 christos variable will be set back to false, and an error thrown.
67 1.1 christos
68 1.1 christos If GDB does support printing a backtrace then this function does
69 1.1 christos nothing. */
70 1.1 christos
71 1.1 christos extern void gdb_internal_backtrace_set_cmd (const char *args, int from_tty,
72 1.1 christos cmd_list_element *c);
73 1.1 christos
74 1.1.1.3 christos /* Initialize language specific strings. */
75 1.1.1.3 christos
76 1.1.1.3 christos extern void gdb_internal_backtrace_init_str ();
77 1.1.1.3 christos
78 1.1.1.3 christos #endif /* GDB_BT_UTILS_H */
79