mirror of
https://github.com/Trensa-Organization/Hyprland.git
synced 2025-03-15 18:53:39 +01:00
build: guard execinfo.h via build systems (#3547)
* guard execinfo via cmake * libexecinfo -> execinfo macro name * meson: add execinfo check * move check in cmake up --------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
This commit is contained in:
parent
5dc7161b1d
commit
06cc42441c
4 changed files with 32 additions and 17 deletions
|
@ -97,6 +97,12 @@ if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
add_link_options(-pg -no-pie -fno-builtin)
|
add_link_options(-pg -no-pie -fno-builtin)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
check_include_file("execinfo.h" EXECINFOH)
|
||||||
|
if(EXECINFOH)
|
||||||
|
message(STATUS "Configuration supports execinfo")
|
||||||
|
add_compile_definitions(HAS_EXECINFO)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CheckLibraryExists)
|
include(CheckLibraryExists)
|
||||||
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
|
check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO)
|
||||||
if(HAVE_LIBEXECINFO)
|
if(HAVE_LIBEXECINFO)
|
||||||
|
|
|
@ -29,6 +29,10 @@ add_project_arguments(
|
||||||
],
|
],
|
||||||
language: 'cpp')
|
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'])
|
wlroots = subproject('wlroots', default_options: ['examples=false', 'renderers=gles2'])
|
||||||
have_xwlr = wlroots.get_variable('features').get('xwayland')
|
have_xwlr = wlroots.get_variable('features').get('xwayland')
|
||||||
xcb_dep = dependency('xcb', required: get_option('xwayland'))
|
xcb_dep = dependency('xcb', required: get_option('xwayland'))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "CrashReporter.hpp"
|
#include "CrashReporter.hpp"
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <execinfo.h>
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
@ -14,19 +13,19 @@
|
||||||
std::string getRandomMessage() {
|
std::string getRandomMessage() {
|
||||||
|
|
||||||
const std::vector<std::string> MESSAGES = {"Sorry, didn't mean to...",
|
const std::vector<std::string> MESSAGES = {"Sorry, didn't mean to...",
|
||||||
"This was an accident, I swear!",
|
"This was an accident, I swear!",
|
||||||
"Calm down, it was a misinput! MISINPUT!",
|
"Calm down, it was a misinput! MISINPUT!",
|
||||||
"Oops",
|
"Oops",
|
||||||
"Vaxry is going to be upset.",
|
"Vaxry is going to be upset.",
|
||||||
"Who tried dividing by zero?!",
|
"Who tried dividing by zero?!",
|
||||||
"Maybe you should try dusting your PC in the meantime?",
|
"Maybe you should try dusting your PC in the meantime?",
|
||||||
"I tried so hard, and got so far...",
|
"I tried so hard, and got so far...",
|
||||||
"I don't feel so good...",
|
"I don't feel so good...",
|
||||||
"*thud*",
|
"*thud*",
|
||||||
"Well this is awkward.",
|
"Well this is awkward.",
|
||||||
"\"stable\"",
|
"\"stable\"",
|
||||||
"I hope you didn't have any unsaved progress.",
|
"I hope you didn't have any unsaved progress.",
|
||||||
"All these computers..."};
|
"All these computers..."};
|
||||||
|
|
||||||
std::random_device dev;
|
std::random_device dev;
|
||||||
std::mt19937 engine(dev());
|
std::mt19937 engine(dev());
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#ifdef HAS_EXECINFO
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
@ -689,9 +691,10 @@ std::string replaceInString(std::string subject, const std::string& search, cons
|
||||||
std::vector<SCallstackFrameInfo> getBacktrace() {
|
std::vector<SCallstackFrameInfo> getBacktrace() {
|
||||||
std::vector<SCallstackFrameInfo> callstack;
|
std::vector<SCallstackFrameInfo> callstack;
|
||||||
|
|
||||||
void* bt[1024];
|
#ifdef HAS_EXECINFO
|
||||||
size_t btSize;
|
void* bt[1024];
|
||||||
char** btSymbols;
|
size_t btSize;
|
||||||
|
char** btSymbols;
|
||||||
|
|
||||||
btSize = backtrace(bt, 1024);
|
btSize = backtrace(bt, 1024);
|
||||||
btSymbols = backtrace_symbols(bt, btSize);
|
btSymbols = backtrace_symbols(bt, btSize);
|
||||||
|
@ -699,6 +702,9 @@ std::vector<SCallstackFrameInfo> getBacktrace() {
|
||||||
for (size_t i = 0; i < btSize; ++i) {
|
for (size_t i = 0; i < btSize; ++i) {
|
||||||
callstack.emplace_back(SCallstackFrameInfo{bt[i], std::string{btSymbols[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;
|
return callstack;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue