Simplify bfd code

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39763 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2016-05-14 14:47:43 +00:00
parent 71941dd24d
commit f5288bdf6b
5 changed files with 69 additions and 59 deletions

View file

@ -1,3 +1,12 @@
2016-05-14 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/GNUstepBase/config.h.in:
* Source/NSException.m:
* configure.ac:
* configure:
Make USE_BFD control usage of libbfd and replace runtime warning with
a configure time warning about the license issue.
2016-05-14 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Foundation/NSNotification.h:

View file

@ -842,6 +842,9 @@
/* Define if the compiler provides builtins for atomic operations */
#undef USE_ATOMIC_BUILTINS
/* Define to use bfd library for stack traces */
#undef USE_BFD
/* Define if using the ffcall library for invocations */
#undef USE_FFCALL

View file

@ -62,25 +62,18 @@
#ifdef HAVE_BACKTRACE
#include <execinfo.h>
#ifdef USE_BINUTILS
#undef USE_BINUTILS
#endif
#else
#ifndef USE_BINUTILS
#define USE_BINUTILS 1
#endif
#endif
/*
* Turn off USE_BINUTILS if we don't have bfd support for it.
* Turn off USE_BFD if we don't have bfd support for it.
*/
#if !(defined(HAVE_BFD_H) && defined(HAVE_LIBBFD) && defined(HAVE_LIBIBERTY))
#if defined(USE_BINUTILS)
#undef USE_BINUTILS
#endif
# if defined(USE_BFD)
# undef USE_BFD
# endif
#endif
#if defined(_WIN32) && !defined(USE_BINUTILS)
#if defined(_WIN32) && !defined(USE_BFD)
#include <windows.h>
#if defined(HAVE_DBGHELP_H)
#include <dbghelp.h>
@ -132,7 +125,7 @@ static NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler = 0;
#if defined(_WIN32)
#if defined(USE_BINUTILS)
#if defined(USE_BFD)
static NSString *
GSPrivateBaseAddress(void *addr, void **base)
{
@ -158,12 +151,12 @@ GSPrivateBaseAddress(void *addr, void **base)
}
return nil;
}
#endif /* USE_BINUTILS */
#endif /* USE_BFD */
#else /* _WIN32 */
#include <dlfcn.h>
#if defined(USE_BINUTILS)
#if defined(USE_BFD)
static NSString *
GSPrivateBaseAddress(void *addr, void **base)
{
@ -180,10 +173,10 @@ GSPrivateBaseAddress(void *addr, void **base)
return nil;
#endif
}
#endif /* USE_BINUTILS */
#endif /* USE_BFD */
#endif /* _WIN32 */
#if defined(USE_BINUTILS)
#if defined(USE_BFD)
// GSStackTrace inspired by FYStackTrace.m
// created by Wim Oudshoorn on Mon 11-Apr-2006
@ -578,14 +571,14 @@ GSListModules()
return result;
}
#endif /* USE_BINUTILS */
#endif /* USE_BFD */
@implementation GSStackTrace : NSObject
static NSRecursiveLock *traceLock = nil;
#if defined(_WIN32) && !defined(USE_BINUTILS)
#if defined(_WIN32) && !defined(USE_BFD)
typedef USHORT (WINAPI *CaptureStackBackTraceType)(ULONG,ULONG,PVOID*,PULONG);
typedef BOOL (WINAPI *SymInitializeType)(HANDLE,char*,BOOL);
typedef DWORD (WINAPI *SymSetOptionsType)(DWORD);
@ -642,7 +635,7 @@ static HANDLE hProcess = 0;
// grab the current stack
- (id) init
{
#if defined(USE_BINUTILS)
#if defined(USE_BFD)
addresses = [GSPrivateStackAddresses() copy];
#elif defined(_WIN32)
uint16_t frames;
@ -770,7 +763,7 @@ static HANDLE hProcess = 0;
if (count > 0)
{
#if defined(USE_BINUTILS)
#if defined(USE_BFD)
NSMutableArray *a;
NSUInteger i;
@ -988,13 +981,12 @@ callUncaughtHandler(id value)
+ (void) initialize
{
#if defined(USE_BINUTILS)
#if defined(USE_BFD)
if (modLock == nil)
{
modLock = [NSRecursiveLock new];
}
NSLog(@"WARNING this copy of gnustep-base has been built with libbfd to provide symbolic stacktrace support. This means that the license of this copy of gnustep-base is GPL rather than the normal LGPL license (since libbfd is released under the GPL license). If this is not what you want, please obtain a copy of gnustep-base which was not configured with the --enable-bfd option");
#endif /* USE_BINUTILS */
#endif /* USE_BFD */
#if defined(_NATIVE_OBJC_EXCEPTIONS)
# ifdef HAVE_SET_UNCAUGHT_EXCEPTION_HANDLER
objc_setUncaughtExceptionHandler(callUncaughtHandler);

45
configure vendored
View file

@ -5418,7 +5418,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -5464,7 +5464,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -5488,7 +5488,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -5533,7 +5533,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -5557,7 +5557,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@ -8673,17 +8673,22 @@ fi
#--------------------------------------------------------------------
# These headers/functions needed for stacktrace in NSException.m
#--------------------------------------------------------------------
PASS_ARG=no
# Check whether --enable-bfd was given.
if test "${enable_bfd+set}" = set; then :
enableval=$enable_bfd;
else
enable_bfd=$PASS_ARG
enable_bfd=no
fi
if test $enable_bfd = yes ; then
if test $enable_bfd = yes; then
for ac_header in bfd.h
$as_echo "#define USE_BFD 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You enabled bfd, which causes gnustep-base to link with libbfd. This makes the license GPL rather than the normal LGPL." >&5
$as_echo "$as_me: WARNING: You enabled bfd, which causes gnustep-base to link with libbfd. This makes the license GPL rather than the normal LGPL." >&2;}
fi
for ac_header in bfd.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "bfd.h" "ac_cv_header_bfd_h" "$ac_includes_default"
if test "x$ac_cv_header_bfd_h" = xyes; then :
@ -8695,7 +8700,7 @@ fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libintl_fprintf in -lintl" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libintl_fprintf in -lintl" >&5
$as_echo_n "checking for libintl_fprintf in -lintl... " >&6; }
if ${ac_cv_lib_intl_libintl_fprintf+:} false; then :
$as_echo_n "(cached) " >&6
@ -8740,7 +8745,7 @@ _ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dyn_string_append in -liberty" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dyn_string_append in -liberty" >&5
$as_echo_n "checking for dyn_string_append in -liberty... " >&6; }
if ${ac_cv_lib_iberty_dyn_string_append+:} false; then :
$as_echo_n "(cached) " >&6
@ -8785,7 +8790,7 @@ _ACEOF
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bfd_openr in -lbfd" >&5
$as_echo_n "checking for bfd_openr in -lbfd... " >&6; }
if ${ac_cv_lib_bfd_bfd_openr+:} false; then :
$as_echo_n "(cached) " >&6
@ -8830,9 +8835,8 @@ _ACEOF
fi
else
if test $ismingw = yes ; then
for ac_header in dbghelp.h
if test $ismingw = yes ; then
for ac_header in dbghelp.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "dbghelp.h" "ac_cv_header_dbghelp_h" "$ac_includes_default"
if test "x$ac_cv_header_dbghelp_h" = xyes; then :
@ -8844,8 +8848,8 @@ fi
done
else
for ac_header in execinfo.h
else
for ac_header in execinfo.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "execinfo.h" "ac_cv_header_execinfo_h" "$ac_includes_default"
if test "x$ac_cv_header_execinfo_h" = xyes; then :
@ -8857,7 +8861,7 @@ fi
done
for ac_func in backtrace
for ac_func in backtrace
do :
ac_fn_c_check_func "$LINENO" "backtrace" "ac_cv_func_backtrace"
if test "x$ac_cv_func_backtrace" = xyes; then :
@ -8868,8 +8872,8 @@ _ACEOF
fi
done
fi
fi
for ac_func in __builtin_extract_return_address
do :
ac_fn_c_check_func "$LINENO" "__builtin_extract_return_address" "ac_cv_func___builtin_extract_return_address"
@ -12345,7 +12349,8 @@ fi
if test $HAVE_LIBDISPATCH = 1; then
# We check whether we
# We check whether we have a variant of libdispatch that allows runloop
# integration
for ac_func in dispatch_main_queue_drain_np dispatch_get_main_queue_handle_np
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`

View file

@ -2242,7 +2242,6 @@ dnl AC_REPLACE_FUNCS(recvfrom)
#--------------------------------------------------------------------
# These headers/functions needed for stacktrace in NSException.m
#--------------------------------------------------------------------
PASS_ARG=no
AC_ARG_ENABLE(bfd,
[ --enable-bfd
Enables the use of libbfd to provide symbolic stack traces.
@ -2251,21 +2250,23 @@ AC_ARG_ENABLE(bfd,
available or does not work properly.
Enabling this option also has the effect of changing the license
of gnustep-base from LGPL to GPL since libbfd uses the GPL license],,
enable_bfd=$PASS_ARG)
if test $enable_bfd = yes; then
AC_CHECK_HEADERS(bfd.h)
AC_CHECK_LIB(intl, libintl_fprintf)
AC_CHECK_LIB(iberty, dyn_string_append)
AC_CHECK_LIB(bfd, bfd_openr)
else
if test $ismingw = yes ; then
AC_CHECK_HEADERS(dbghelp.h)
else
AC_CHECK_HEADERS(execinfo.h)
AC_CHECK_FUNCS(backtrace)
fi
enable_bfd=no)
if test $enable_bfd = yes ; then
AC_DEFINE(USE_BFD,1, [Define to use bfd library for stack traces])
AC_MSG_WARN([You enabled bfd, which causes gnustep-base to link with libbfd. This makes the license GPL rather than the normal LGPL.])
fi
AC_CHECK_HEADERS(bfd.h)
AC_CHECK_LIB(intl, libintl_fprintf)
AC_CHECK_LIB(iberty, dyn_string_append)
AC_CHECK_LIB(bfd, bfd_openr)
if test $ismingw = yes ; then
AC_CHECK_HEADERS(dbghelp.h)
else
AC_CHECK_HEADERS(execinfo.h)
AC_CHECK_FUNCS(backtrace)
fi
AC_CHECK_FUNCS(__builtin_extract_return_address)
#--------------------------------------------------------------------