summaryrefslogtreecommitdiff
path: root/src/helpers/MiscFunctions.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-10-11 22:27:53 +0100
committerGitHub <noreply@github.com>2023-10-11 22:27:53 +0100
commit06cc42441cd5b24444f7c79495851dedde8bc732 (patch)
treef923972dc0398dd45e0bc3c9de593ff6fc4e47a5 /src/helpers/MiscFunctions.cpp
parent5dc7161b1da7c9ad97122458c94c833b69eb5769 (diff)
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>
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
-rw-r--r--src/helpers/MiscFunctions.cpp12
1 files changed, 9 insertions, 3 deletions
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 <sys/utsname.h>
#include <iomanip>
#include <sstream>
+#ifdef HAS_EXECINFO
#include <execinfo.h>
+#endif
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#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> 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<SCallstackFrameInfo> 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;
}