mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 20:46:50 +03:00
monkey: On assert failure, print a backtrace
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
parent
5632c9c8c0
commit
ccffb95f03
@ -316,6 +316,29 @@ static void monkey_run(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include <execinfo.h>
|
||||
static void *backtrace_buffer[4096];
|
||||
|
||||
void
|
||||
__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",
|
||||
__file, __line, __function, __assertion);
|
||||
|
||||
frames = backtrace(&backtrace_buffer[0], 4096);
|
||||
if (frames > 0 && frames < 4096) {
|
||||
fprintf(stderr, "Backtrace:\n");
|
||||
fflush(stderr);
|
||||
backtrace_symbols_fd(&backtrace_buffer[0], frames, 2);
|
||||
}
|
||||
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user