forked from Mirrors/openclonk
autotools: Also check for the backtrace function before using execinfo.h
Also, install the crash handler even without backtrace. That way, at least the signal name gets written to the log.
parent
7b7414a8bb
commit
c01422d3ce
|
@ -6,7 +6,7 @@
|
|||
/* Define to 1 if you have the <direct.h> header file. */
|
||||
#undef HAVE_DIRECT_H
|
||||
|
||||
/* Define to 1 if you have the <execinfo.h> header file. */
|
||||
/* The backtrace function is declared in execinfo.h and works */
|
||||
#undef HAVE_EXECINFO_H
|
||||
|
||||
/* Define to 1 if you have FreeType2. */
|
||||
|
|
16
configure.ac
16
configure.ac
|
@ -56,13 +56,27 @@ AM_CONDITIONAL(MACOSX, [test $osx = true])
|
|||
|
||||
# various used headers
|
||||
dnl the whitespace is there to prevent AC_INCLUDES_DEFAULT
|
||||
AC_CHECK_HEADERS([stdint.h unistd.h poll.h sys/stat.h sys/types.h locale.h sys/socket.h signal.h langinfo.h execinfo.h sys/inotify.h sys/syscall.h], , , [[ ]])
|
||||
AC_CHECK_HEADERS([stdint.h unistd.h poll.h sys/stat.h sys/types.h locale.h sys/socket.h signal.h langinfo.h sys/inotify.h sys/syscall.h], , , [[ ]])
|
||||
# Mingw does not ship with multimon.h
|
||||
AC_CHECK_HEADERS([multimon.h io.h direct.h share.h], [], [], [[#include <windows.h>]])
|
||||
# iconv
|
||||
AX_ICONV
|
||||
# vasprintf is a GNU extension
|
||||
AC_CHECK_FUNCS(vasprintf)
|
||||
# so is execinfo.h - and some systems have the header despite the functions not being in the c library
|
||||
AC_CHECK_HEADER(execinfo.h)
|
||||
if test "x$ac_cv_header_execinfo_h" = xyes; then
|
||||
AC_CHECK_FUNC(backtrace, [], [
|
||||
AC_CHECK_LIB(execinfo, backtrace, [
|
||||
CLONK_LIBS="-lexecinfo $CLONK_LIBS"
|
||||
], [
|
||||
ac_cv_header_execinfo_h=no
|
||||
])
|
||||
])
|
||||
fi
|
||||
if test "x$ac_cv_header_execinfo_h" = xyes; then
|
||||
AC_DEFINE(HAVE_EXECINFO_H, 1, [The backtrace function is declared in execinfo.h and works])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([debug],
|
||||
[AC_HELP_STRING([--enable-debug], [debugging options [default=no]])],
|
||||
|
|
|
@ -131,7 +131,6 @@ int main()
|
|||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
|
@ -143,8 +142,11 @@ int main()
|
|||
# include <gtk/gtkwindow.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
||||
static void crash_handler(int signo)
|
||||
{
|
||||
|
@ -170,6 +172,7 @@ static void crash_handler(int signo)
|
|||
else break;
|
||||
if (logfd < 0) break;
|
||||
}
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
// Get the backtrace
|
||||
void *stack[100];
|
||||
int count = backtrace(stack, 100);
|
||||
|
@ -178,10 +181,11 @@ static void crash_handler(int signo)
|
|||
// Also to the log file
|
||||
if (logfd >= 0)
|
||||
backtrace_symbols_fd (stack, count, logfd);
|
||||
#endif
|
||||
// Bye.
|
||||
_exit(C4XRV_Failure);
|
||||
}
|
||||
#endif
|
||||
#endif // HAVE_SIGNAL_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
void restart(char* args[]) {
|
||||
|
@ -206,7 +210,7 @@ int main (int argc, char * argv[])
|
|||
printf("Do not run %s as root!\n", argc ? argv[0] : "this program");
|
||||
return C4XRV_Failure;
|
||||
}
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
// Set up debugging facilities
|
||||
signal(SIGBUS, crash_handler);
|
||||
signal(SIGILL, crash_handler);
|
||||
|
|
Loading…
Reference in New Issue