Add configure test for the backtrace implementation
Improve robustness by testing explicitly; instead of assuming based on the OS, test first the libc and then test for libexecinfo. The assumption was wrong for FreeBSD (included since 2017) and for musl-based systems (not in libc). Also, remove INCLUDE_BACKTRACE and clean up a bit. Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220271 Change-Id: Ib4b7fd4fe2cdf5f76babe47a21bd2990fcf42649 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127538 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
This commit is contained in:
committed by
Jan-Marek Glogowski
parent
d7fb6b22cf
commit
c1be123960
@@ -33,6 +33,8 @@ export AVAHI_CFLAGS=$(gb_SPACE)@AVAHI_CFLAGS@
|
||||
export AVAHI_LIBS=$(gb_SPACE)@AVAHI_LIBS@
|
||||
export LIBATOMIC_OPS_CFLAGS=$(gb_SPACE)@LIBATOMIC_OPS_CFLAGS@
|
||||
export LIBATOMIC_OPS_LIBS=$(gb_SPACE)@LIBATOMIC_OPS_LIBS@
|
||||
export BACKTRACE_CFLAGS=@BACKTRACE_CFLAGS@
|
||||
export BACKTRACE_LIBS=@BACKTRACE_LIBS@
|
||||
export BINDIR=@BINDIR@
|
||||
export BISON=@BISON@
|
||||
export BOOST_CPPFLAGS=@BOOST_CPPFLAGS@
|
||||
|
||||
@@ -99,6 +99,10 @@
|
||||
*/
|
||||
#define HAVE_FEATURE_BREAKPAD 0
|
||||
|
||||
/* BACKTRACE - whether a GNU backtrace implementation is available.
|
||||
*/
|
||||
#define HAVE_FEATURE_BACKTRACE 0
|
||||
|
||||
/*
|
||||
* Whether OpenGL is enabled
|
||||
*/
|
||||
|
||||
@@ -1343,6 +1343,20 @@ if test $_os != "WINNT"; then
|
||||
fi
|
||||
AC_SUBST(DLOPEN_LIBS)
|
||||
|
||||
# Check for a (GNU) backtrace implementation
|
||||
AC_ARG_VAR([BACKTRACE_CFLAGS], [Compiler flags needed to use backtrace(3)])
|
||||
AC_ARG_VAR([BACKTRACE_LIBS], [Linker flags needed to use backtrace(3)])
|
||||
AS_IF([test "x$BACKTRACE_LIBS$BACKTRACE_CFLAGS" = x], [
|
||||
save_LIBS="$LIBS"
|
||||
AC_SEARCH_LIBS([backtrace], [libexecinfo],
|
||||
[case "$ac_cv_search_backtrace" in -l*) BACKTRACE_LIBS="$ac_cv_search_backtrace";; esac],
|
||||
[PKG_CHECK_MODULES([BACKTRACE], [libexecinfo], [ac_cv_search_backtrace=], [:])])
|
||||
LIBS="$save_LIBS"
|
||||
])
|
||||
AS_IF([test "x$ac_cv_search_backtrace" != xno ], [
|
||||
AC_DEFINE([HAVE_FEATURE_BACKTRACE])
|
||||
])
|
||||
|
||||
dnl ===================================================================
|
||||
dnl Sanity checks for Emscripten SDK setup
|
||||
dnl ===================================================================
|
||||
|
||||
@@ -19,6 +19,7 @@ $(eval $(call gb_Library_set_is_ure_library_or_dependency,sal))
|
||||
$(eval $(call gb_Library_set_include,sal,\
|
||||
$$(INCLUDE) \
|
||||
-I$(SRCDIR)/sal/inc \
|
||||
$(BACKTRACE_CFLAGS) \
|
||||
))
|
||||
|
||||
$(eval $(call gb_Library_add_defs,sal,\
|
||||
@@ -71,6 +72,7 @@ $(eval $(call gb_Library_add_libs,sal,\
|
||||
$(if $(filter HAIKU,$(OS)), \
|
||||
-lnetwork \
|
||||
) \
|
||||
$(BACKTRACE_LIBS) \
|
||||
))
|
||||
|
||||
ifeq ($(OS),MACOSX)
|
||||
|
||||
+15
-5
@@ -17,16 +17,19 @@
|
||||
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||
*/
|
||||
|
||||
#include "backtrace.h"
|
||||
|
||||
#if ! HAVE_FEATURE_BACKTRACE /* no GNU backtrace implementation available */
|
||||
|
||||
#include <sal/types.h>
|
||||
|
||||
#ifdef __sun
|
||||
#ifdef __sun /* Solaris */
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/frame.h>
|
||||
#include "backtrace.h"
|
||||
|
||||
#if defined(SPARC)
|
||||
|
||||
@@ -140,7 +143,12 @@ void backtrace_symbols_fd( void **buffer, int size, int fd )
|
||||
#include <setjmp.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include "backtrace.h"
|
||||
|
||||
/* no frame.h on FreeBSD */
|
||||
struct frame {
|
||||
struct frame *fr_savfp;
|
||||
long fr_savpc;
|
||||
};
|
||||
|
||||
#if defined(POWERPC) || defined(POWERPC64)
|
||||
|
||||
@@ -212,7 +220,7 @@ void backtrace_symbols_fd( void **buffer, int size, int fd )
|
||||
}
|
||||
}
|
||||
|
||||
#elif !defined LINUX && !defined MACOSX && !defined IOS
|
||||
#else /* not GNU/BSD/Solaris */
|
||||
|
||||
int backtrace( void **buffer, int max_frames )
|
||||
{
|
||||
@@ -231,6 +239,8 @@ void backtrace_symbols_fd( void **buffer, int size, int fd )
|
||||
(void)buffer; (void)size; (void)fd;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* not GNU/BSD/Solaris */
|
||||
|
||||
#endif /* ! HAVE_FEATURE_BACKTRACE */
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
+3
-10
@@ -20,7 +20,9 @@
|
||||
#ifndef INCLUDED_SAL_OSL_UNX_BACKTRACE_H
|
||||
#define INCLUDED_SAL_OSL_UNX_BACKTRACE_H
|
||||
|
||||
#if defined (LINUX)
|
||||
#include <config_features.h>
|
||||
|
||||
#if HAVE_FEATURE_BACKTRACE /* GNU backtrace implementation available */
|
||||
|
||||
#include <execinfo.h>
|
||||
|
||||
@@ -38,15 +40,6 @@ char ** backtrace_symbols(void * const * buffer, int size);
|
||||
|
||||
void backtrace_symbols_fd( void **buffer, int size, int fd );
|
||||
|
||||
/* no frame.h on FreeBSD */
|
||||
#if defined (FREEBSD) || defined (NETBSD) || defined (OPENBSD) || \
|
||||
defined (DRAGONFLY)
|
||||
struct frame {
|
||||
struct frame *fr_savfp;
|
||||
long fr_savpc;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
+3
-29
@@ -27,31 +27,9 @@
|
||||
/* system headers */
|
||||
#include "system.hxx"
|
||||
|
||||
#if defined( MACOSX )
|
||||
|
||||
#if defined( INTEL )
|
||||
#include "backtrace.h"
|
||||
#define INCLUDE_BACKTRACE
|
||||
#endif /* INTEL */
|
||||
|
||||
#endif /* MACOSX */
|
||||
|
||||
#ifdef LINUX
|
||||
#include <execinfo.h>
|
||||
#include <link.h>
|
||||
#define INCLUDE_BACKTRACE
|
||||
#endif
|
||||
|
||||
#ifdef __sun
|
||||
|
||||
#include "backtrace.h"
|
||||
#define INCLUDE_BACKTRACE
|
||||
|
||||
#endif /* defined __sun */
|
||||
|
||||
#if defined INCLUDE_BACKTRACE
|
||||
#define MAX_STACK_FRAMES 256
|
||||
#endif
|
||||
|
||||
#include <osl/diagnose.h>
|
||||
#include <osl/signal.h>
|
||||
@@ -304,24 +282,20 @@ namespace
|
||||
{
|
||||
void printStack(int sig)
|
||||
{
|
||||
#ifdef INCLUDE_BACKTRACE
|
||||
void *buffer[MAX_STACK_FRAMES];
|
||||
int size = backtrace( buffer, SAL_N_ELEMENTS(buffer) );
|
||||
#endif
|
||||
|
||||
fprintf( stderr, "\n\nFatal exception: Signal %d\n", sig );
|
||||
|
||||
#if defined( MACOSX ) && !defined( INCLUDE_BACKTRACE )
|
||||
#if ! HAVE_FEATURE_BACKTRACE && defined( MACOSX ) && !defined( INTEL )
|
||||
fprintf( stderr, "Please turn on Enable Crash Reporting and\nAutomatic Display of Crashlogs in the Console application\n" );
|
||||
#else
|
||||
#ifdef INCLUDE_BACKTRACE
|
||||
#endif
|
||||
|
||||
if ( size > 0 )
|
||||
{
|
||||
fputs( "Stack:\n", stderr );
|
||||
backtrace_symbols_fd( buffer, size, fileno(stderr) );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void callSystemHandler(int signal, siginfo_t * info, void * context)
|
||||
|
||||
Reference in New Issue
Block a user