diff --git a/CMakeLists.txt b/CMakeLists.txt index 29eccd64..b67314bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,12 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) add_link_options(-pg -no-pie -fno-builtin) endif() +check_include_file("execinfo.h" EXECINFOH) +if(EXECINFOH) + message(STATUS "Configuration supports execinfo") + add_compile_definitions(HAS_EXECINFO) +endif() + include(CheckLibraryExists) check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO) if(HAVE_LIBEXECINFO) diff --git a/meson.build b/meson.build index 726933bc..1d2c7f9f 100644 --- a/meson.build +++ b/meson.build @@ -29,6 +29,10 @@ add_project_arguments( ], language: 'cpp') +if cpp_compiler.check_header('execinfo.h') + add_project_arguments('-DHAS_EXECINFO', language: 'cpp') +endif + wlroots = subproject('wlroots', default_options: ['examples=false', 'renderers=gles2']) have_xwlr = wlroots.get_variable('features').get('xwayland') xcb_dep = dependency('xcb', required: get_option('xwayland')) diff --git a/src/debug/CrashReporter.cpp b/src/debug/CrashReporter.cpp index 1a28a780..ddc52561 100644 --- a/src/debug/CrashReporter.cpp +++ b/src/debug/CrashReporter.cpp @@ -1,7 +1,6 @@ #include "CrashReporter.hpp" #include #include -#include #include #include @@ -14,19 +13,19 @@ std::string getRandomMessage() { const std::vector MESSAGES = {"Sorry, didn't mean to...", - "This was an accident, I swear!", - "Calm down, it was a misinput! MISINPUT!", - "Oops", - "Vaxry is going to be upset.", - "Who tried dividing by zero?!", - "Maybe you should try dusting your PC in the meantime?", - "I tried so hard, and got so far...", - "I don't feel so good...", - "*thud*", - "Well this is awkward.", - "\"stable\"", - "I hope you didn't have any unsaved progress.", - "All these computers..."}; + "This was an accident, I swear!", + "Calm down, it was a misinput! MISINPUT!", + "Oops", + "Vaxry is going to be upset.", + "Who tried dividing by zero?!", + "Maybe you should try dusting your PC in the meantime?", + "I tried so hard, and got so far...", + "I don't feel so good...", + "*thud*", + "Well this is awkward.", + "\"stable\"", + "I hope you didn't have any unsaved progress.", + "All these computers..."}; std::random_device dev; std::mt19937 engine(dev()); diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index e54e93ac..47c1180a 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -6,7 +6,9 @@ #include #include #include +#ifdef HAS_EXECINFO #include +#endif #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include @@ -689,9 +691,10 @@ std::string replaceInString(std::string subject, const std::string& search, cons std::vector getBacktrace() { std::vector callstack; - void* bt[1024]; - size_t btSize; - char** btSymbols; +#ifdef HAS_EXECINFO + void* bt[1024]; + size_t btSize; + char** btSymbols; btSize = backtrace(bt, 1024); btSymbols = backtrace_symbols(bt, btSize); @@ -699,6 +702,9 @@ std::vector getBacktrace() { for (size_t i = 0; i < btSize; ++i) { callstack.emplace_back(SCallstackFrameInfo{bt[i], std::string{btSymbols[i]}}); } +#else + callstack.emplace_back(SCallstackFrameInfo{nullptr, "configuration does not support execinfo.h"}); +#endif return callstack; }