Commit b50b6c97 by kollo

print backtrace information in crash handler

parent 6106da45
......@@ -206,6 +206,9 @@
/* Define to 1 if you have the `strstr' function. */
#undef HAVE_STRSTR
/* Define to 1 if you have the `backtrace' function. */
#undef HAVE_BACKTRACE
/* Define to 1 if you have the `memfrob' function. */
#undef HAVE_MEMFROB
......
......@@ -7450,7 +7450,7 @@ _ACEOF
fi
done
for ac_func in socket strchr strdup strerror strstr
for ac_func in socket strchr strdup strerror strstr backtrace
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
......@@ -7464,6 +7464,7 @@ done
# Versioning
cat >>confdefs.h <<_ACEOF
......
......@@ -534,7 +534,8 @@ AC_FUNC_UTIME_NULL
AC_CHECK_FUNCS([nanosleep inotify_init memfrob utime execvp execvpe futimens])
AC_CHECK_FUNCS([alarm atexit bzero dup2 getcwd gethostbyname gettimeofday])
AC_CHECK_FUNCS([inet_ntoa localtime_r memmove memset mkdir munmap rmdir select])
AC_CHECK_FUNCS([socket strchr strdup strerror strstr])
AC_CHECK_FUNCS([socket strchr strdup strerror strstr backtrace])
# Versioning
......
......@@ -16,6 +16,9 @@
#include <string.h>
#include <signal.h>
#include "defs.h"
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#endif
#include "x11basic.h"
#include "xbasic.h"
#include "memory.h"
......@@ -114,6 +117,25 @@ static void break_handler( int signum) {
#ifdef ANDROID
extern void android_sigaction(int signum, siginfo_t *info, void *reserved);
#endif
#ifdef HAVE_BACKTRACE
/* Get some information about the crash... */
static void print_trace() {
void *array[16];
size_t size;
char **strings;
size_t i;
size=backtrace(array,16);
strings=backtrace_symbols(array,size);
printf("Obtained %zd stack frames.\n",size);
for(i=0;i<size;i++) printf("%02zd %s\n",i,strings[i]);
free (strings);
}
#endif
static void fatal_error_handler( int signum) {
int obatch=batch;
switch(signum) {
......@@ -150,6 +172,10 @@ static void fatal_error_handler( int signum) {
c_dump(NULL,0);
puts("** fatal error ** X11BASIC-QUIT");
}
#ifdef HAVE_BACKTRACE
print_trace();
#endif
#ifdef ANDROID
invalidate_screen();
backlog("** X11BASIC-QUIT (fatal)");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment