diff options
author | Tom Tromey <tromey@adacore.com> | 2022-01-05 08:43:59 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2022-01-05 10:08:15 -0700 |
commit | ffcc2b69d1a516f55ede0e12a8847913651ea588 (patch) | |
tree | a221b92aa9db5edd6a51845338a5ae71dd067fca /gdb/bt-utils.c | |
parent | 93f3b8eeaac14fe1d9343ce1b8eca87be2ce5843 (diff) | |
download | fsf-binutils-gdb-ffcc2b69d1a516f55ede0e12a8847913651ea588.zip fsf-binutils-gdb-ffcc2b69d1a516f55ede0e12a8847913651ea588.tar.gz fsf-binutils-gdb-ffcc2b69d1a516f55ede0e12a8847913651ea588.tar.bz2 |
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.
Diffstat (limited to 'gdb/bt-utils.c')
-rw-r--r-- | gdb/bt-utils.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/gdb/bt-utils.c b/gdb/bt-utils.c index d456315..681f02c 100644 --- a/gdb/bt-utils.c +++ b/gdb/bt-utils.c @@ -41,6 +41,7 @@ gdb_internal_backtrace_set_cmd (const char *args, int from_tty, #endif } +#ifdef GDB_PRINT_INTERNAL_BACKTRACE #ifdef GDB_PRINT_INTERNAL_BACKTRACE_USING_LIBBACKTRACE /* Callback used by libbacktrace if it encounters an error. */ @@ -142,7 +143,10 @@ gdb_internal_backtrace_1 () sig_write (_("Backtrace might be incomplete.\n")); } +#else +#error "unexpected internal backtrace policy" #endif +#endif /* GDB_PRINT_INTERNAL_BACKTRACE */ /* See bt-utils.h. */ @@ -152,6 +156,7 @@ gdb_internal_backtrace () if (current_ui == nullptr) return; +#ifdef GDB_PRINT_INTERNAL_BACKTRACE const auto sig_write = [] (const char *msg) -> void { gdb_stderr->write_async_safe (msg, strlen (msg)); @@ -159,12 +164,11 @@ gdb_internal_backtrace () sig_write (_("----- Backtrace -----\n")); -#ifdef GDB_PRINT_INTERNAL_BACKTRACE if (gdb_stderr->fd () > -1) gdb_internal_backtrace_1 (); else -#endif sig_write (_("Backtrace unavailable\n")); sig_write ("---------------------\n"); +#endif } |