limit monkey backtrace generation to libc where it is available

This commit is contained in:
Vincent Sanders 2020-01-11 10:23:14 +00:00
parent ed6c326b1c
commit d71d2632b4
2 changed files with 10 additions and 2 deletions

View File

@ -316,7 +316,7 @@ static void monkey_run(void)
}
}
#ifndef NDEBUG
#if (!defined(NDEBUG) && defined(HAVE_EXECINFO))
#include <execinfo.h>
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);

View File

@ -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.
*