From 4fddc8fec71d9c6fd4915895b00fb6b20f6d4622 Mon Sep 17 00:00:00 2001 From: Logan Aerl Arias Date: Tue, 2 Jan 2024 22:23:52 -0500 Subject: [PATCH] Update i_system.c backtrace() doesn't exist in non-glibc systems --- src/sdl/i_system.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 6e6031f4e..bc21134da 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -290,10 +290,12 @@ static void write_backtrace(INT32 signal) int fd = -1; time_t rawtime; struct tm timeinfo; - size_t bt_size; enum { BT_SIZE = 1024, STR_SIZE = 32 }; +#ifndef NOEXECINFO void *funcptrs[BT_SIZE]; + size_t bt_size; +#endif char timestr[STR_SIZE]; const char *filename = va("%s" PATHSEP "%s", srb2home, "crash-log.txt"); @@ -327,12 +329,16 @@ static void write_backtrace(INT32 signal) bt_write_file(fd, strsignal(signal)); bt_write_file(fd, "\n"); // Newline for the signal name +#ifdef NOEXECINFO + bt_write_all(fd, "\nNo Backtrace support\n"); +#else bt_write_all(fd, "\nBacktrace:\n"); // Flood the output and log with the backtrace bt_size = backtrace(funcptrs, BT_SIZE); backtrace_symbols_fd(funcptrs, bt_size, fd); backtrace_symbols_fd(funcptrs, bt_size, STDERR_FILENO); +#endif bt_write_file(fd, "\n"); // Write another newline to the log so it looks nice :) if (fd != -1) {