Do not print anything when self-backtrace unavailable

Right now, gdb's self-backtrace feature will still print something
when a backtrace is unavailable:

   sig_write (_("----- Backtrace -----\n"));
[...]
     sig_write (_("Backtrace unavailable\n"));
    sig_write ("---------------------\n");

However, if GDB_PRINT_INTERNAL_BACKTRACE is undefined, it seems better
to me to print nothing at all.

This patch implements this change.  It also makes a couple of other
small changes in this same module: it adds a header guard to
bt-utils.h, and it protects the definitions of
gdb_internal_backtrace_1 with a check of GDB_PRINT_INTERNAL_BACKTRACE.
This commit is contained in:
Tom Tromey
2022-01-05 08:43:59 -07:00
parent 93f3b8eeaa
commit ffcc2b69d1
2 changed files with 11 additions and 2 deletions

View File

@@ -18,6 +18,9 @@
/* Support for printing a backtrace when GDB hits an error. This is not
for printing backtraces of the inferior, but backtraces of GDB itself. */
#ifndef BT_UTILS_H
#define BT_UTILS_H
#ifdef HAVE_LIBBACKTRACE
# include "backtrace.h"
# include "backtrace-supported.h"
@@ -67,3 +70,5 @@ extern void gdb_internal_backtrace ();
extern void gdb_internal_backtrace_set_cmd (const char *args, int from_tty,
cmd_list_element *c);
#endif /* BT_UTILS_H */