From 95126a283c054273ca881e2f1d9fc5febb22742c Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 27 Apr 2016 19:20:31 +0200 Subject: [PATCH] fix the detection of backtrace: not all linuxes have it In particular, this is not implemented on armhf. --- CMakeLists.txt | 4 ++-- src/xbt/ex.c | 7 +------ src/xbt/xbt_log_layout_format.c | 2 +- tools/cmake/MakeLib.cmake | 4 ++-- tools/cmake/src/internal_config.h.in | 1 + 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ac8d05efb..0afc6957cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -275,7 +275,7 @@ endif() #endif() # Checks for header libraries functions. -CHECK_LIBRARY_EXISTS(execinfo backtrace "" HAVE_BACKTRACE_IN_LIBEXECINFO) +CHECK_LIBRARY_EXISTS(execinfo backtrace "" HAVE_BACKTRACE) CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_POSIX_GETTIME) CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_PTHREAD) @@ -632,7 +632,7 @@ endif() # So we include only where needed, and compile with -Wundef to notice the missing includes. # But cmake sometimes defines to the empty definition (#define HAVE_VALGRIND_H). # So we have to make sure that everything got a decent value before generating the files. -foreach(var HAVE_EXECINFO_H HAVE_FUTEX_H HAVE_GETDTABLESIZE HAVE_GETTIMEOFDAY HAVE_MMAP HAVE_NANOSLEEP HAVE_POPEN +foreach(var HAVE_BACKTRACE HAVE_EXECINFO_H HAVE_FUTEX_H HAVE_GETDTABLESIZE HAVE_GETTIMEOFDAY HAVE_MMAP HAVE_NANOSLEEP HAVE_POPEN HAVE_POSIX_GETTIME HAVE_PROCESS_VM_READV HAVE_SIGNAL_H HAVE_SYS_PARAM_H HAVE_SYS_SYSCTL_H HAVE_SYSCONF HAVE_UCONTEXT_H HAVE_UNISTD_H HAVE_VALGRIND_H HAVE_VASPRINTF) if(${var}) diff --git a/src/xbt/ex.c b/src/xbt/ex.c index 313f5f3056..0ae19680e7 100644 --- a/src/xbt/ex.c +++ b/src/xbt/ex.c @@ -56,11 +56,6 @@ #include "simgrid/simix.h" /* SIMIX_process_self_get_name() */ -#undef HAVE_BACKTRACE -#if HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE) -# define HAVE_BACKTRACE 1 /* Hello linux box */ -#endif - XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_ex, xbt, "Exception mecanism"); XBT_EXPORT_NO_IMPORT(const xbt_running_ctx_t) __xbt_ex_ctx_initializer = XBT_RUNNING_CTX_INITIALIZER; @@ -115,7 +110,7 @@ void xbt_backtrace_display_current(void) xbt_backtrace_display(&e); } -#if HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE) +#if HAVE_BACKTRACE && HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE) # include "src/xbt/backtrace_linux.c" #else # include "src/xbt/backtrace_dummy.c" diff --git a/src/xbt/xbt_log_layout_format.c b/src/xbt/xbt_log_layout_format.c index 64162da8a1..7e2c46833c 100644 --- a/src/xbt/xbt_log_layout_format.c +++ b/src/xbt/xbt_log_layout_format.c @@ -157,7 +157,7 @@ static int xbt_log_layout_format_doit(xbt_log_layout_t l, xbt_log_event_t ev, co break; case 'b': /* backtrace; called %throwable in LOG4J */ case 'B': /* short backtrace; called %throwable{short} in LOG4J */ -#if HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE) +#if HAVE_BACKTRACE && HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE) { xbt_ex_t e; diff --git a/tools/cmake/MakeLib.cmake b/tools/cmake/MakeLib.cmake index 6b825b2a37..496c93548f 100644 --- a/tools/cmake/MakeLib.cmake +++ b/tools/cmake/MakeLib.cmake @@ -95,9 +95,9 @@ if(HAVE_POSIX_GETTIME) SET(SIMGRID_DEP "${SIMGRID_DEP} -lrt") endif() -if(HAVE_BACKTRACE_IN_LIBEXECINFO) +if(HAVE_BACKTRACE) SET(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo") -endif(HAVE_BACKTRACE_IN_LIBEXECINFO) +endif() # Compute the dependencies of SMPI ################################## diff --git a/tools/cmake/src/internal_config.h.in b/tools/cmake/src/internal_config.h.in index e632714e1a..0b8d91baf5 100644 --- a/tools/cmake/src/internal_config.h.in +++ b/tools/cmake/src/internal_config.h.in @@ -57,6 +57,7 @@ #define HAVE_PRIVATIZATION @HAVE_PRIVATIZATION@ /* We have mmap and objdump to handle privatization */ /* Other function checks */ +#define HAVE_BACKTRACE @HAVE_BACKTRACE@ /* Function backtrace */ #define HAVE_MMAP @HAVE_MMAP@ /* Function mmap */ #define HAVE_SEM_INIT @HAVE_SEM_INIT@ /* Function sem_init (part of XPG6 standard only) */ #define HAVE_POPEN @HAVE_POPEN@ /* Function popen */ -- 2.20.1