70 lines
2.0 KiB
Diff
70 lines
2.0 KiB
Diff
From f6b65fb4b1ab174b4aab898f4bb83d0b83a2bcb1 Mon Sep 17 00:00:00 2001
|
|
From: John <johnz@posteo.net>
|
|
Date: Fri, 29 Nov 2019 10:41:03 +0100
|
|
Subject: [PATCH 2/3] Check for backtrace function in cmake
|
|
|
|
---
|
|
src/cpp/core/Backtrace.cpp | 8 +++++---
|
|
src/cpp/core/CMakeLists.txt | 1 +
|
|
src/cpp/core/config.h.in | 1 +
|
|
3 files changed, 7 insertions(+), 3 deletions(-)
|
|
|
|
diff --git src/cpp/core/Backtrace.cpp src/cpp/core/Backtrace.cpp
|
|
index a345648371..def1189eb0 100644
|
|
--- src/cpp/core/Backtrace.cpp
|
|
+++ src/cpp/core/Backtrace.cpp
|
|
@@ -16,7 +16,9 @@
|
|
#include <core/Backtrace.hpp>
|
|
#include <core/RegexUtils.hpp>
|
|
|
|
-#ifndef _WIN32
|
|
+#include "config.h"
|
|
+
|
|
+#ifdef HAVE_BACKTRACE
|
|
# include <core/Algorithm.hpp>
|
|
# include <iostream>
|
|
# include <boost/regex.hpp>
|
|
@@ -32,7 +34,7 @@ std::string demangle(const std::string& name)
|
|
{
|
|
std::string result = name;
|
|
|
|
-#ifndef _WIN32
|
|
+#ifdef HAVE_BACKTRACE
|
|
int status = -1;
|
|
char* demangled = ::abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status);
|
|
if (status == 0) {
|
|
@@ -46,7 +48,7 @@ std::string demangle(const std::string& name)
|
|
|
|
void printBacktrace(std::ostream& os)
|
|
{
|
|
-#ifndef _WIN32
|
|
+#ifdef HAVE_BACKTRACE
|
|
|
|
os << "Backtrace (most recent calls first):" << std::endl << std::endl;
|
|
|
|
diff --git src/cpp/core/CMakeLists.txt src/cpp/core/CMakeLists.txt
|
|
index 8cd1080ae8..9a18bcae77 100644
|
|
--- src/cpp/core/CMakeLists.txt
|
|
+++ src/cpp/core/CMakeLists.txt
|
|
@@ -156,6 +156,7 @@ if (UNIX)
|
|
check_function_exists(getpeereid HAVE_GETPEEREID)
|
|
check_function_exists(setresuid HAVE_SETRESUID)
|
|
check_function_exists(group_member HAVE_GROUP_MEMBER)
|
|
+ check_function_exists(backtrace HAVE_BACKTRACE)
|
|
if(EXISTS "/proc/self")
|
|
set(HAVE_PROCSELF TRUE)
|
|
endif()
|
|
diff --git src/cpp/core/config.h.in src/cpp/core/config.h.in
|
|
index cb4ef42be0..a2ec47c51f 100644
|
|
--- src/cpp/core/config.h.in
|
|
+++ src/cpp/core/config.h.in
|
|
@@ -25,4 +25,5 @@
|
|
#cmakedefine HAVE_SETRESUID
|
|
#cmakedefine HAVE_SCANDIR_POSIX
|
|
#cmakedefine HAVE_GROUP_MEMBER
|
|
+#cmakedefine HAVE_BACKTRACE
|
|
#cmakedefine RSTUDIO_SERVER
|
|
--
|
|
2.24.0
|
|
|