diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2021-09-15 22:18:04 +0200 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2021-09-23 17:11:30 +0900 |
commit | 443e9d7cf59bb88f8920628405b2e1c6aaf770d0 (patch) | |
tree | ae5ebcd9f4142c171550884de6157877bb3a43ae | |
parent | 08cea68d1ac6b82ce7fb7aa3c152c272afb5a135 (diff) | |
download | tdesdk-443e9d7cf59bb88f8920628405b2e1c6aaf770d0.tar.gz tdesdk-443e9d7cf59bb88f8920628405b2e1c6aaf770d0.zip |
Add a backtrace function and library detection.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit cf63191672fff12cd57892ba4642ed4f01e9c6a4)
-rw-r--r-- | config.h.cmake | 6 | ||||
-rw-r--r-- | kmtrace/CMakeLists.txt | 8 | ||||
-rw-r--r-- | kmtrace/ConfigureChecks.cmake | 18 | ||||
-rw-r--r-- | kmtrace/ktrace.c | 6 |
4 files changed, 36 insertions, 2 deletions
diff --git a/config.h.cmake b/config.h.cmake index f1ac1ba4..d9eac5e5 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -5,3 +5,9 @@ // kbabeldict/modules/dbsearchengine #cmakedefine USE_DB_H_PATH <@USE_DB_H_PATH@> + +/* Define to 1 if GLIBC >= 2.1 compatible backtrace facility exists */ +#cmakedefine HAVE_BACKTRACE 1 +#ifdef HAVE_BACKTRACE +#define BACKTRACE_H <@Backtrace_HEADER@> +#endif diff --git a/kmtrace/CMakeLists.txt b/kmtrace/CMakeLists.txt index c2551b0e..126a1013 100644 --- a/kmtrace/CMakeLists.txt +++ b/kmtrace/CMakeLists.txt @@ -12,6 +12,7 @@ include_directories( ${TDE_INCLUDE_DIR} ${TQT_INCLUDE_DIRS} + ${CMAKE_BINARY_DIR} ) link_directories( @@ -21,6 +22,11 @@ link_directories( set( LD_FLAGS "-Wl,-Bstatic -liberty -Wl,-Bdynamic" ) +##### configure checks ########################## + +include( ConfigureChecks.cmake ) + + ##### other data ################################ configure_file( kminspector.cmake kminspector @ONLY ) @@ -48,7 +54,7 @@ tde_add_library( ktrace_s STATIC tde_add_library( ktrace SHARED SOURCES ksotrace.cpp ktrace.c - LINK dl + LINK ${DL_LIBRARIES} ${Backtrace_LIBRARY} DESTINATION ${LIB_INSTALL_DIR}/kmtrace ) diff --git a/kmtrace/ConfigureChecks.cmake b/kmtrace/ConfigureChecks.cmake new file mode 100644 index 00000000..5c06aac6 --- /dev/null +++ b/kmtrace/ConfigureChecks.cmake @@ -0,0 +1,18 @@ + +##### check if GLIBC >= 2.1 compatible backtrace facility exists + +if ( CMAKE_MAJOR_VERSION LESS "3" ) + check_symbol_exists( backtrace "execinfo.h" HAVE_BACKTRACE ) + if ( HAVE_BACKTRACE ) + set ( Backtrace_LIBRARY "" ) + set ( Backtrace_HEADER "execinfo.h" ) + endif () +else () + find_package( Backtrace ) + if ( Backtrace_FOUND ) + set ( HAVE_BACKTRACE 1 CACHE INTERNAL "" ) + endif () +endif () +if( NOT HAVE_BACKTRACE ) + tde_message_fatal( "bactrace function is required but not available on your system") +endif() diff --git a/kmtrace/ktrace.c b/kmtrace/ktrace.c index e7eee47b..dcc321e5 100644 --- a/kmtrace/ktrace.c +++ b/kmtrace/ktrace.c @@ -25,6 +25,10 @@ or (US mail) as Mike Haertel c/o Free Software Foundation. */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + #define MALLOC_HOOKS #define _GNU_SOURCE @@ -35,8 +39,8 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <execinfo.h> #include <unistd.h> +#include BACKTRACE_H #ifdef USE_IN_LIBIO # include <libio/iolibio.h> |