diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-03-08 23:00:29 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-03-08 23:03:29 +0300 |
commit | 0b26c83fd6c485b6686244a41647324fcf1a1843 (patch) | |
tree | d8fe2e447d46287cc0d9e71cc96d5c677ae1eddb | |
parent | 308ce845d53c6544f9577982eef26cd252ec2f79 (diff) | |
download | mv-0b26c83fd6c485b6686244a41647324fcf1a1843.tar.gz mv-0b26c83fd6c485b6686244a41647324fcf1a1843.tar.bz2 mv-0b26c83fd6c485b6686244a41647324fcf1a1843.tar.xz mv-0b26c83fd6c485b6686244a41647324fcf1a1843.zip |
Enable stack generation if target platform support this.
-rwxr-xr-x | configure.ac | 16 | ||||
-rw-r--r-- | src/Makefile.am | 8 | ||||
-rw-r--r-- | src/catch.hpp | 6 | ||||
-rw-r--r-- | src/utils/checkutils.cpp | 24 |
4 files changed, 34 insertions, 20 deletions
diff --git a/configure.ac b/configure.ac index 4ee915424..f68adfb59 100755 --- a/configure.ac +++ b/configure.ac @@ -638,6 +638,22 @@ fi AC_CHECK_LD_FLAG(-rdynamic, have_rdynamic) AM_CONDITIONAL(HAVE_RDYNAMIC, test x$have_rdynamic = xyes) +AC_CHECK_HEADERS([execinfo.h], + [ + AC_SEARCH_LIBS([backtrace], + [execinfo], + [ + have_execinfo=yes + ], + [ + have_execinfo=no + ] + ) + ], + [] +) +AM_CONDITIONAL(HAVE_EXECINFO, test x$have_execinfo = xyes) + AC_CONFIG_FILES([ manaplus.spec Makefile 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<int>(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 <execinfo.h> -#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<int>(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 |