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
23d5b27206
commit
0116d739b5
|
@ -167,14 +167,23 @@ endmacro()
|
||||||
a_find_library(LIB_EV ev)
|
a_find_library(LIB_EV ev)
|
||||||
# GNU libc has <execinfo.h> and backtrace() stuff. If this is not available, we
|
# GNU libc has <execinfo.h> and backtrace() stuff. If this is not available, we
|
||||||
# need libexecinfo.
|
# need libexecinfo.
|
||||||
|
message(STATUS "checking for execinfo")
|
||||||
try_compile(HAS_EXECINFO
|
try_compile(HAS_EXECINFO
|
||||||
${CMAKE_BINARY_DIR}
|
${CMAKE_BINARY_DIR}
|
||||||
${CMAKE_SOURCE_DIR}/build-tests/execinfo.c)
|
${CMAKE_SOURCE_DIR}/build-tests/execinfo.c)
|
||||||
if(NOT HAS_EXECINFO)
|
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
|
set(AWESOME_REQUIRED_LIBRARIES
|
||||||
${AWESOME_REQUIRED_LIBRARIES}
|
${AWESOME_REQUIRED_LIBRARIES}
|
||||||
${LIB_EXECINFO})
|
${LIB_EXECINFO})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
if(HAS_EXECINFO)
|
||||||
|
message(STATUS "checking for execinfo -- found")
|
||||||
|
else()
|
||||||
|
message(STATUS "checking for execinfo -- not found")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Error check
|
# Error check
|
||||||
|
|
|
@ -19,9 +19,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <execinfo.h>
|
#include "config.h"
|
||||||
#include "common/backtrace.h"
|
#include "common/backtrace.h"
|
||||||
|
|
||||||
|
#ifdef HAS_EXECINFO
|
||||||
|
#include <execinfo.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MAX_STACK_SIZE 32
|
#define MAX_STACK_SIZE 32
|
||||||
|
|
||||||
/** Get a backtrace.
|
/** Get a backtrace.
|
||||||
|
@ -30,6 +34,9 @@
|
||||||
void
|
void
|
||||||
backtrace_get(buffer_t *buf)
|
backtrace_get(buffer_t *buf)
|
||||||
{
|
{
|
||||||
|
buffer_init(buf);
|
||||||
|
|
||||||
|
#ifdef HAS_EXECINFO
|
||||||
void *stack[MAX_STACK_SIZE];
|
void *stack[MAX_STACK_SIZE];
|
||||||
char **bt;
|
char **bt;
|
||||||
int stack_size;
|
int stack_size;
|
||||||
|
@ -37,7 +44,6 @@ backtrace_get(buffer_t *buf)
|
||||||
stack_size = backtrace(stack, countof(stack));
|
stack_size = backtrace(stack, countof(stack));
|
||||||
bt = backtrace_symbols(stack, stack_size);
|
bt = backtrace_symbols(stack, stack_size);
|
||||||
|
|
||||||
buffer_init(buf);
|
|
||||||
if(bt)
|
if(bt)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < stack_size; i++)
|
for(int i = 0; i < stack_size; i++)
|
||||||
|
@ -49,6 +55,7 @@ backtrace_get(buffer_t *buf)
|
||||||
p_delete(&bt);
|
p_delete(&bt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
buffer_addsl(buf, "Cannot get backtrace symbols.");
|
buffer_addsl(buf, "Cannot get backtrace symbols.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
#define AWESOME_IS_BIG_ENDIAN @AWESOME_IS_BIG_ENDIAN@
|
#define AWESOME_IS_BIG_ENDIAN @AWESOME_IS_BIG_ENDIAN@
|
||||||
|
|
||||||
#cmakedefine WITH_DBUS
|
#cmakedefine WITH_DBUS
|
||||||
|
#cmakedefine HAS_EXECINFO
|
||||||
|
|
||||||
#endif //_CONFIG_H_
|
#endif //_CONFIG_H_
|
||||||
|
|
Loading…
Reference in New Issue