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