From 77efebd5049ca16c6127bf3477fb5876ce29c54d Mon Sep 17 00:00:00 2001 From: erysdren Date: Fri, 23 Aug 2024 06:44:18 -0500 Subject: [PATCH 1/2] Use execinfo/backtrace lookup from YQ2 --- CMakeLists.txt | 15 +++++++++++++++ rott/dosutil.c | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e2d124..4d16a3a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,21 @@ target_link_libraries(${TARADINO_EXEC} PRIVATE SDL2::Main SDL2::Mixer) target_compile_definitions(${TARADINO_EXEC} PRIVATE PACKAGE_STRING="${TARADINO_TITLE} ${CMAKE_PROJECT_VERSION}") target_compile_definitions(${TARADINO_EXEC} PRIVATE PACKAGE_TARNAME="${CMAKE_PROJECT_NAME}") +# backtrace lookup from Yamagi Quake II +# https://github.com/yquake2/yquake2/blob/master/CMakeLists.txt +include(CheckFunctionExists) +include(CheckLibraryExists) +check_function_exists(backtrace HAVE_EXECINFO_SYS) +IF (NOT HAVE_EXECINFO_SYS) + check_library_exists(execinfo backtrace "" HAVE_EXECINFO_LIB) + if (HAVE_EXECINFO_LIB) + target_link_libraries(${TARADINO_EXEC} PRIVATE execinfo) + target_compile_definitions(${TARADINO_EXEC} PRIVATE HAVE_EXECINFO) + endif() +else() + target_compile_definitions(${TARADINO_EXEC} PRIVATE HAVE_EXECINFO) +endif() + if(MSVC) set_property(TARGET ${TARADINO_EXEC} PROPERTY C_STANDARD 17) # silence warnings about POSIX functions diff --git a/rott/dosutil.c b/rott/dosutil.c index 297e3a2..9961bc3 100644 --- a/rott/dosutil.c +++ b/rott/dosutil.c @@ -163,7 +163,7 @@ void DisplayTextSplash(byte *text, int l) printf ("\033[m"); } -#if !defined(__CYGWIN__) && !defined(__MINGW32__) && !defined(__HAIKU__) && !defined(_MSC_VER) +#if defined(HAVE_EXECINFO) #include void print_stack (int level) From ef023237b3ed3e697e6cbf28f7a3c5d047f9bfb6 Mon Sep 17 00:00:00 2001 From: erysdren Date: Mon, 26 Aug 2024 01:08:23 -0500 Subject: [PATCH 2/2] Remove crash_print() and associated stuff --- CMakeLists.txt | 15 --------------- rott/dosutil.c | 43 ------------------------------------------- rott/rt_main.c | 4 ---- 3 files changed, 62 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d16a3a..9e2d124 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,21 +42,6 @@ target_link_libraries(${TARADINO_EXEC} PRIVATE SDL2::Main SDL2::Mixer) target_compile_definitions(${TARADINO_EXEC} PRIVATE PACKAGE_STRING="${TARADINO_TITLE} ${CMAKE_PROJECT_VERSION}") target_compile_definitions(${TARADINO_EXEC} PRIVATE PACKAGE_TARNAME="${CMAKE_PROJECT_NAME}") -# backtrace lookup from Yamagi Quake II -# https://github.com/yquake2/yquake2/blob/master/CMakeLists.txt -include(CheckFunctionExists) -include(CheckLibraryExists) -check_function_exists(backtrace HAVE_EXECINFO_SYS) -IF (NOT HAVE_EXECINFO_SYS) - check_library_exists(execinfo backtrace "" HAVE_EXECINFO_LIB) - if (HAVE_EXECINFO_LIB) - target_link_libraries(${TARADINO_EXEC} PRIVATE execinfo) - target_compile_definitions(${TARADINO_EXEC} PRIVATE HAVE_EXECINFO) - endif() -else() - target_compile_definitions(${TARADINO_EXEC} PRIVATE HAVE_EXECINFO) -endif() - if(MSVC) set_property(TARGET ${TARADINO_EXEC} PROPERTY C_STANDARD 17) # silence warnings about POSIX functions diff --git a/rott/dosutil.c b/rott/dosutil.c index 9961bc3..396cc31 100644 --- a/rott/dosutil.c +++ b/rott/dosutil.c @@ -162,46 +162,3 @@ void DisplayTextSplash(byte *text, int l) printf ("\033[m"); } - -#if defined(HAVE_EXECINFO) -#include - -void print_stack (int level) -{ - void *array[64]; - char **syms; - int size, i; - - printf ("Stack dump:\n"); - printf ("{\n"); - size = backtrace (array, (sizeof (array))/(sizeof (array[0]))); - syms = backtrace_symbols (array, size); - for (i=level+1; i