From e7210521acb15b2e863ade6e4f54f13603c04008 Mon Sep 17 00:00:00 2001 From: Jay Sigbrandt Date: Wed, 25 Jun 2014 14:45:18 +0200 Subject: [PATCH 1/2] Many platforms don't support backtraces. Fix compile for Solaris platform. This change was tested with Solaris 10 on X86 and SPARC. More information on Unix Backtrace Support - http://www.gnu.org/software/libc/manual/html_node/Backtraces.html It is not supported on the following platforms: - https://www.gnu.org/software/gnulib/manual/html_node/execinfo_002eh.html Mac OS X 10.3, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin, mingw, MSVC 9, Interix 3.5, BeOS. --- cli/cppcheckexecutor.cpp | 8 ++++++-- cli/threadexecutor.cpp | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 7220a0f04..566d57484 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -34,12 +34,16 @@ #if !defined(NO_UNIX_SIGNAL_HANDLING) && defined(__GNUC__) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__) #define USE_UNIX_SIGNAL_HANDLING -#include #include #include #include #endif +#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(USE_UNIX_SIGNAL_HANDLING) && !defined(__SVR4) +#define USE_UNIX_BACKTRACE_SUPPORT +#include +#endif + #if defined(_MSC_VER) #define USE_WINDOWS_SEH #include @@ -237,7 +241,7 @@ static const char *signal_name(int signo) */ static void print_stacktrace(FILE* f, bool demangling) { -#if defined(__GNUC__) +#if defined(USE_UNIX_BACKTRACE_SUPPORT) void *array[32]= {0}; // the less resources the better... const int depth = backtrace(array, (int)GetArrayLength(array)); char **symbolstrings = backtrace_symbols(array, depth); diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 32cdc8ea1..aed99fe8f 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -20,6 +20,9 @@ #include "cppcheck.h" #include "cppcheckexecutor.h" #include +#ifdef __SVR4 // Solaris +#include +#endif #ifdef THREADING_MODEL_FORK #include #include From 51fdf3f14f4135b01b5c45ebb0c4325553ee0908 Mon Sep 17 00:00:00 2001 From: Jay Sigbrandt Date: Fri, 27 Jun 2014 08:03:05 +0200 Subject: [PATCH 2/2] Simplify defines. --- cli/cppcheckexecutor.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index 566d57484..ac6d6a37f 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -32,18 +32,14 @@ #include #include -#if !defined(NO_UNIX_SIGNAL_HANDLING) && defined(__GNUC__) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__) +#if !defined(NO_UNIX_SIGNAL_HANDLING) && defined(__GNUC__) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(__OS2__) && !defined(__SVR4) #define USE_UNIX_SIGNAL_HANDLING +#include #include #include #include #endif -#if !defined(NO_UNIX_BACKTRACE_SUPPORT) && defined(USE_UNIX_SIGNAL_HANDLING) && !defined(__SVR4) -#define USE_UNIX_BACKTRACE_SUPPORT -#include -#endif - #if defined(_MSC_VER) #define USE_WINDOWS_SEH #include @@ -241,7 +237,7 @@ static const char *signal_name(int signo) */ static void print_stacktrace(FILE* f, bool demangling) { -#if defined(USE_UNIX_BACKTRACE_SUPPORT) +#if defined(USE_UNIX_SIGNAL_SUPPORT) void *array[32]= {0}; // the less resources the better... const int depth = backtrace(array, (int)GetArrayLength(array)); char **symbolstrings = backtrace_symbols(array, depth);