From 0b26c83fd6c485b6686244a41647324fcf1a1843 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 8 Mar 2017 23:00:29 +0300 Subject: Enable stack generation if target platform support this. --- src/Makefile.am | 8 ++++++++ src/catch.hpp | 6 ++---- src/utils/checkutils.cpp | 24 ++++++++---------------- 3 files changed, 18 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index b18ee6d06..f3dae8c8e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,6 +52,11 @@ dyecmd_LDFLAGS = -rdynamic endif endif +if HAVE_EXECINFO +manaplus_CXXFLAGS += -DHAVE_EXECINFO +dyecmd_CXXFLAGS += -DHAVE_EXECINFO +endif + if ENABLE_PUGIXML manaplus_CXXFLAGS += -DENABLE_PUGIXML dyecmd_CXXFLAGS += -DENABLE_PUGIXML @@ -1954,6 +1959,9 @@ if HAVE_RDYNAMIC manaplustests_LDFLAGS += -rdynamic endif endif +if HAVE_EXECINFO +manaplustests_CXXFLAGS += -DHAVE_EXECINFO +endif if ENABLE_GLIBCDEBUG manaplustests_CXXFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC endif diff --git a/src/catch.hpp b/src/catch.hpp index a5563d7a7..07ffcc7b1 100644 --- a/src/catch.hpp +++ b/src/catch.hpp @@ -6073,8 +6073,7 @@ namespace Catch { resultBuilder.setResultType( ResultWas::FatalErrorCondition ); resultBuilder << message; // stack -#ifndef ANDROID -#if defined __linux__ || defined __linux +#ifdef HAVE_EXECINFO { void *array[15]; const int size = static_cast(backtrace(array, 15)); @@ -6083,8 +6082,7 @@ namespace Catch { resultBuilder << strings[i]; free(strings); } -#endif // defined __linux__ || defined __linux -#endif // ANDROID +#endif // HAVE_EXECINFO // stack resultBuilder.captureExpression(); diff --git a/src/utils/checkutils.cpp b/src/utils/checkutils.cpp index 10214f0eb..8e72dbf7d 100644 --- a/src/utils/checkutils.cpp +++ b/src/utils/checkutils.cpp @@ -24,11 +24,9 @@ #include "logger.h" -#ifndef ANDROID -#if defined __linux__ || defined __linux +#ifdef HAVE_EXECINFO #include -#endif // defined __linux__ || defined __linux -#endif // ANDROID +#endif // HAVE_EXECINFO #include "debug.h" @@ -45,11 +43,9 @@ void reportAssertStack(const char *const file, line, text, func); -#ifndef ANDROID -#if defined __linux__ || defined __linux +#ifdef HAVE_EXECINFO reportStack(); -#endif // defined __linux__ || defined __linux -#endif // ANDROID +#endif // HAVE_EXECINFO } void reportLogStack(const char *const file, @@ -60,25 +56,21 @@ void reportLogStack(const char *const file, file, line, func); -#ifndef ANDROID -#if defined __linux__ || defined __linux +#ifdef HAVE_EXECINFO reportStack(); -#endif // defined __linux__ || defined __linux -#endif // ANDROID +#endif // HAVE_EXECINFO } void reportStack() { -#ifndef ANDROID -#if defined __linux__ || defined __linux +#ifdef HAVE_EXECINFO void *array[15]; const int size = static_cast(backtrace(array, 15)); char **strings = backtrace_symbols(array, size); for (int i = 0; i < size; i++) logger->log1(strings[i]); free(strings); -#endif // defined __linux__ || defined __linux -#endif // ANDROID +#endif // HAVE_EXECINFO } #endif // ENABLE_ASSERTS -- cgit v1.2.3-70-g09d2