Don't fail if execinfo is not available
Previously, cmake aborted when execinfo was not found. With this commit the backtrace code is just disabled when execinfo is not available. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
ce814b4dbf
commit
46048332b0
|
@ -167,14 +167,23 @@ endmacro()
|
|||
a_find_library(LIB_EV ev)
|
||||
# GNU libc has <execinfo.h> and backtrace() stuff. If this is not available, we
|
||||
# need libexecinfo.
|
||||
message(STATUS "checking for execinfo")
|
||||
try_compile(HAS_EXECINFO
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/build-tests/execinfo.c)
|
||||
if(NOT HAS_EXECINFO)
|
||||
a_find_library(LIB_EXECINFO execinfo)
|
||||
find_library(LIB_EXECINFO execinfo)
|
||||
if(LIB_EXECINFO)
|
||||
set(HAS_EXECINFO 1)
|
||||
set(AWESOME_REQUIRED_LIBRARIES
|
||||
${AWESOME_REQUIRED_LIBRARIES}
|
||||
${LIB_EXECINFO})
|
||||
endif()
|
||||
endif()
|
||||
if(HAS_EXECINFO)
|
||||
message(STATUS "checking for execinfo -- found")
|
||||
else()
|
||||
message(STATUS "checking for execinfo -- not found")
|
||||
endif()
|
||||
|
||||
# Error check
|
||||
|
|
|
@ -19,9 +19,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <execinfo.h>
|
||||
#include "config.h"
|
||||
#include "common/backtrace.h"
|
||||
|
||||
#ifdef HAS_EXECINFO
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
#define MAX_STACK_SIZE 32
|
||||
|
||||
/** Get a backtrace.
|
||||
|
@ -30,6 +34,9 @@
|
|||
void
|
||||
backtrace_get(buffer_t *buf)
|
||||
{
|
||||
buffer_init(buf);
|
||||
|
||||
#ifdef HAS_EXECINFO
|
||||
void *stack[MAX_STACK_SIZE];
|
||||
char **bt;
|
||||
int stack_size;
|
||||
|
@ -37,7 +44,6 @@ backtrace_get(buffer_t *buf)
|
|||
stack_size = backtrace(stack, countof(stack));
|
||||
bt = backtrace_symbols(stack, stack_size);
|
||||
|
||||
buffer_init(buf);
|
||||
if(bt)
|
||||
{
|
||||
for(int i = 0; i < stack_size; i++)
|
||||
|
@ -49,6 +55,7 @@ backtrace_get(buffer_t *buf)
|
|||
p_delete(&bt);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
buffer_addsl(buf, "Cannot get backtrace symbols.");
|
||||
}
|
||||
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
#define AWESOME_IS_BIG_ENDIAN @AWESOME_IS_BIG_ENDIAN@
|
||||
|
||||
#cmakedefine WITH_DBUS
|
||||
#cmakedefine HAS_EXECINFO
|
||||
|
||||
#endif //_CONFIG_H_
|
||||
|
|
Loading…
Reference in New Issue