From b2886dd2e93bbef174e57855d3d77368344372db Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 5 Mar 2026 02:56:38 +0500 Subject: [PATCH] engine: platform: remove support for glibc's backtrace(), as it's unused --- engine/platform/posix/crash.h | 4 -- engine/platform/posix/crash_glibc.c | 49 ---------------------- engine/platform/posix/crash_libbacktrace.c | 2 +- engine/platform/posix/crash_posix.c | 8 ---- engine/wscript | 9 ---- 5 files changed, 1 insertion(+), 71 deletions(-) delete mode 100644 engine/platform/posix/crash_glibc.c diff --git a/engine/platform/posix/crash.h b/engine/platform/posix/crash.h index 69f86f19..9f91245e 100644 --- a/engine/platform/posix/crash.h +++ b/engine/platform/posix/crash.h @@ -19,7 +19,3 @@ GNU General Public License for more details. int Sys_CrashDetailsLibbacktrace( int logfd, char *message, int len, size_t max_len ); qboolean Sys_SetupLibbacktrace( const char *argv0 ); -// -// crash_glibc.c -// -int Sys_CrashDetailsExecinfo( int logfd, char *message, int len, size_t max_len ); diff --git a/engine/platform/posix/crash_glibc.c b/engine/platform/posix/crash_glibc.c deleted file mode 100644 index 6805caf4..00000000 --- a/engine/platform/posix/crash_glibc.c +++ /dev/null @@ -1,49 +0,0 @@ -/* -crash_glibc.c - advanced crashhandler based on glibc's execinfo API -Copyright (C) 2016 Mittorn -Copyright (C) 2025 Alibek Omarov - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -*/ - -// on Glibc (which potentially might not be only Linux) systems we -// have backtrace() and backtrace_symbols() calls, which replace for us -// platform-specific code -#if HAVE_EXECINFO -#include -#include -#include "common.h" -#include "input.h" -#include "crash.h" - -int Sys_CrashDetailsExecinfo( int logfd, char *message, int len, size_t max_len ) -{ - void *addrs[16]; - int size = backtrace( addrs, sizeof( addrs ) / sizeof( addrs[0] )); - char **syms = backtrace_symbols( addrs, size ); - - for( int i = 0; i < size && syms; i++ ) - { - size_t symlen = Q_strlen( syms[i] ); - char ch = '\n'; - - write( logfd, syms[i], symlen ); - write( logfd, &ch, 1 ); - - write( STDERR_FILENO, syms[i], symlen ); - write( STDERR_FILENO, &ch, 1 ); - - len += Q_snprintf( message + len, max_len - len, "%2d: %s\n", i, syms[i] ); - } - - return len; -} -#endif // HAVE_EXECINFO diff --git a/engine/platform/posix/crash_libbacktrace.c b/engine/platform/posix/crash_libbacktrace.c index 6f2cdbbf..e3dff2c5 100644 --- a/engine/platform/posix/crash_libbacktrace.c +++ b/engine/platform/posix/crash_libbacktrace.c @@ -153,4 +153,4 @@ qboolean Sys_SetupLibbacktrace( const char *argv0 ) return g_bt_state != NULL && enable_libbacktrace; } -#endif // HAVE_EXECINFO +#endif // HAVE_LIBBACKTRACE diff --git a/engine/platform/posix/crash_posix.c b/engine/platform/posix/crash_posix.c index 4e39781a..5d6f87d3 100644 --- a/engine/platform/posix/crash_posix.c +++ b/engine/platform/posix/crash_posix.c @@ -61,14 +61,6 @@ static void Sys_Crash( int signal, siginfo_t *si, void *context ) } #endif // HAVE_LIBBACKTRACE -#if HAVE_EXECINFO - if( !detailed_message ) - { - len = Sys_CrashDetailsExecinfo( logfd, message, len, sizeof( message )); - detailed_message = true; - } -#endif // HAVE_EXECINFO - #if !XASH_DEDICATED IN_SetMouseGrab( false ); #endif diff --git a/engine/wscript b/engine/wscript index 48a5ac3e..ab6d4072 100644 --- a/engine/wscript +++ b/engine/wscript @@ -9,13 +9,6 @@ from copy import copy top = '.' -EXECINFO_TEST = '''#include -int main(int argc, char **argv) -{ - backtrace(0, 0); - backtrace_symbols(0, 0); -}''' - FFMPEG_CHECK_FRAGMENT=''' #include #include @@ -152,8 +145,6 @@ def configure(conf): for i in frameworks : conf.check(features='c cprogram', framework=i, uselib_store=i, msg='Checking for %s framework' % i) - conf.check_cc(fragment=EXECINFO_TEST, msg='Checking for glibc backtrace()', mandatory=False, define_name='HAVE_EXECINFO') - conf.define('ENGINE_DLL', 1) conf.define_cond('XASH_ENGINE_TESTS', conf.options.ENGINE_TESTS)