From 5f1a93bb29085c288149e144786d333db68cde0c Mon Sep 17 00:00:00 2001 From: Timo Lotterbach Date: Thu, 22 Nov 2012 03:47:25 -0800 Subject: [PATCH] LayerManagerService: stacktraces only enabled, if system supports it the used backtrace functions used to print a stackdump on crashes is not available on all platforms. the build system now checks, if the system supports backtrace and enables support if possible. Otherwise the stacktrace feature is disabled. Signed-off-by: Timo Lotterbach --- LayerManagerService/CMakeLists.txt | 10 ++++++++++ LayerManagerService/src/SignalHandler.cpp | 13 +++++++++++-- config/res/config.h.cmake | 11 +++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/LayerManagerService/CMakeLists.txt b/LayerManagerService/CMakeLists.txt index 8d21649..bb4d149 100644 --- a/LayerManagerService/CMakeLists.txt +++ b/LayerManagerService/CMakeLists.txt @@ -93,3 +93,13 @@ target_link_libraries(LayerManagerService_Test ${LIBS} gtest gmock) add_test(LayerManagerService LayerManagerService_Test ) endif(WITH_TESTS) + + +#============================================================= +# configuration depending on system +#============================================================= +include(CheckFunctionExists) +check_function_exists(backtrace_symbols HAVE_BACKTRACE) + +include(CheckIncludeFiles) +check_include_files(execinfo.h HAVE_EXECINFO_H) diff --git a/LayerManagerService/src/SignalHandler.cpp b/LayerManagerService/src/SignalHandler.cpp index bbea156..5c8f41a 100644 --- a/LayerManagerService/src/SignalHandler.cpp +++ b/LayerManagerService/src/SignalHandler.cpp @@ -19,10 +19,17 @@ #include "SignalHandler.h" #include "Log.h" +#include "config.h" + #include -#include // stacktrace #include // exit +#ifdef HAVE_EXECINFO_H + #include +#endif + + + //=========================================================================== // Prototypes //=========================================================================== @@ -66,6 +73,7 @@ t_ilm_bool SignalHandler::shutdownSignalReceived() //=========================================================================== void printStackTrace() { +#ifdef HAVE_BACKTRACE const int maxStackSize = 64; void* stack[maxStackSize]; @@ -78,7 +86,8 @@ void printStackTrace() LOG_INFO("LayerManagerService", "Stack-Trace [" << i << "]: " << lines[i]); } LOG_INFO("LayerManagerService", "--------------------------------------------------"); - +#endif + LOG_INFO("LayerManagerService", "Exiting application.") exit(-1); } diff --git a/config/res/config.h.cmake b/config/res/config.h.cmake index 3931338..ead108b 100644 --- a/config/res/config.h.cmake +++ b/config/res/config.h.cmake @@ -96,6 +96,17 @@ // build with native systemd support #cmakedefine WITH_SYSTEMD + +//----------------------------------------------------------------------------- +// platform configuration +//----------------------------------------------------------------------------- +// execinfo header file +#cmakedefine HAVE_EXECINFO_H + +// backtrace available +#cmakedefine HAVE_BACKTRACE + + //----------------------------------------------------------------------------- // human readable report //----------------------------------------------------------------------------- -- 2.7.4