From 74ea3b51c3b76fc0ccd46cc755e6e85e4570515b Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Wed, 29 Sep 2021 10:26:59 +0100 Subject: [PATCH] gdb: fix build when libbacktrace and execinfo backtrace are not available In this commit: commit abbbd4a3e0ca51132e7fb31a43f896d29894dae0 Date: Wed Aug 11 13:24:33 2021 +0100 gdb: use libbacktrace to create a better backtrace for fatal signals The build of GDB was broken iff, the execinfo backtrace API is not available, and, libbacktrace is either disabled, or not usable. In this case you'll see build errors like this: CXX bt-utils.o /home/username/src/binutils-gdb/gdb/bt-utils.c: In function 'void gdb_internal_backtrace()': /home/username/src/binutils-gdb/gdb/bt-utils.c:165:5: error: 'gdb_internal_backtrace_1' was not declared in this scope gdb_internal_backtrace_1 (); ^~~~~~~~~~~~~~~~~~~~~~~~ This commit fixes the issue by guarding the call to gdb_internal_backtrace_1 with '#ifdef GDB_PRINT_INTERNAL_BACKTRACE', which is only defined when one of the backtrace libraries are available. --- gdb/bt-utils.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gdb/bt-utils.c b/gdb/bt-utils.c index 8f826bde6b4..79e6e090d42 100644 --- a/gdb/bt-utils.c +++ b/gdb/bt-utils.c @@ -161,9 +161,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"); -- 2.30.2