From d71d2632b42c7253a2e6d873a78d4fb458036484 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 11 Jan 2020 10:23:14 +0000 Subject: limit monkey backtrace generation to libc where it is available --- frontends/monkey/main.c | 6 ++++-- utils/config.h | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c index a89314440..1aced80cf 100644 --- a/frontends/monkey/main.c +++ b/frontends/monkey/main.c @@ -316,7 +316,7 @@ static void monkey_run(void) } } -#ifndef NDEBUG +#if (!defined(NDEBUG) && defined(HAVE_EXECINFO)) #include static void *backtrace_buffer[4096]; @@ -325,7 +325,9 @@ __assert_fail(const char *__assertion, const char *__file, unsigned int __line, const char *__function) { int frames; - fprintf(stderr, "MONKEY: Assertion failure!\n%s:%d: %s: Assertion `%s` failed.\n", + fprintf(stderr, + "MONKEY: Assertion failure!\n" + "%s:%d: %s: Assertion `%s` failed.\n", __file, __line, __function, __assertion); frames = backtrace(&backtrace_buffer[0], 4096); diff --git a/utils/config.h b/utils/config.h index d3ec32628..0227f4177 100644 --- a/utils/config.h +++ b/utils/config.h @@ -151,6 +151,12 @@ char *realpath(const char *path, char *resolved_path); #undef HAVE_REGEX #endif +/* execinfo available for backtrace */ +#if ((defined(__linux__) && defined(__GLIBC__) && !defined(__UCLIBC__)) || \ + defined(__APPLE__)) +#define HAVE_EXECINFO +#endif + /* This section toggles build options on and off. * Simply undefine a symbol to turn the relevant feature off. * -- cgit v1.2.3