mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 17:10:48 +00:00
Add uncaught exception handler for native objc exceptions
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27168 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
908370d2fd
commit
1459f45289
7 changed files with 7316 additions and 7395 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2008-11-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* config/config.unexpected.m: Add check for objc_set_unexpected
|
||||
* configure.ac: Use new check
|
||||
* configure: Regenerate
|
||||
* Headers/Additions/GNUstepBase/config.h.in: Regenerate
|
||||
* Source/GSSocketStream.m: Fix reliabce on expression evaluation order
|
||||
* Source/NSException.m: Implement uncaught exception handler for
|
||||
when native objc exceptions are enabled.
|
||||
|
||||
2008-11-27 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* configure.ac: Correct typing error in last change.
|
||||
|
|
|
@ -561,6 +561,9 @@
|
|||
/* Define to 1 if the system has the type `uintmax_t'. */
|
||||
#undef HAVE_UINTMAX_T
|
||||
|
||||
/* Define if libobjc has the objc_set_unexpected() function */
|
||||
#undef HAVE_UNEXPECTED
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
|
|
|
@ -1141,8 +1141,10 @@ static NSString * const GSSOCKSAckConn = @"GSSOCKSAckConn";
|
|||
|
||||
while (i < rwant)
|
||||
{
|
||||
int val = rbuffer[i++] * 256 + rbuffer[i++];
|
||||
int val;
|
||||
|
||||
val = rbuffer[i++];
|
||||
val = val * 256 + rbuffer[i++];
|
||||
if (i > 4)
|
||||
{
|
||||
buf[j++] = ':';
|
||||
|
|
|
@ -724,17 +724,31 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
|
|||
_terminate();
|
||||
}
|
||||
|
||||
static void
|
||||
callUncaughtHandler(id value)
|
||||
{
|
||||
if (_NSUncaughtExceptionHandler != NULL)
|
||||
{
|
||||
(*_NSUncaughtExceptionHandler)(value);
|
||||
}
|
||||
_NSFoundationUncaughtExceptionHandler(value);
|
||||
}
|
||||
|
||||
@implementation NSException
|
||||
|
||||
#if defined(STACKSYMBOLS)
|
||||
+ (void) initialize
|
||||
{
|
||||
#if defined(STACKSYMBOLS)
|
||||
if (modLock == nil)
|
||||
{
|
||||
modLock = [NSRecursiveLock new];
|
||||
}
|
||||
}
|
||||
#endif /* STACKSYMBOLS */
|
||||
#if defined(_NATIVE_OBJC_EXCEPTIONS) && defined(HAVE_UNEXPECTED)
|
||||
objc_set_unexpected(callUncaughtHandler);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
+ (NSException*) exceptionWithName: (NSString*)name
|
||||
reason: (NSString*)reason
|
||||
|
@ -850,10 +864,7 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
|
|||
/*
|
||||
* Call the uncaught exception handler (if there is one).
|
||||
*/
|
||||
if (_NSUncaughtExceptionHandler != NULL)
|
||||
{
|
||||
(*_NSUncaughtExceptionHandler)(self);
|
||||
}
|
||||
callUncaughtHandler(self);
|
||||
|
||||
/*
|
||||
* The uncaught exception handler which is set has not
|
||||
|
|
7
config/config.unexpected.m
Normal file
7
config/config.unexpected.m
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include <objc/objc-api.h>
|
||||
|
||||
int main (void)
|
||||
{
|
||||
objc_set_unexpected(0);
|
||||
return 0;
|
||||
}
|
22
configure.ac
22
configure.ac
|
@ -1925,10 +1925,32 @@ case "$target_cpu" in
|
|||
*) ;;
|
||||
esac
|
||||
|
||||
have_unexpected=yes
|
||||
saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $OBJCFLAGS -x objective-c"
|
||||
AC_MSG_CHECKING(for objc_set_unexpected() in runtime)
|
||||
AC_COMPILE_IFELSE([#include "$srcdir/config/config.unexpected.m"],
|
||||
have_unexpected=yes, have_unexpected=no)
|
||||
if test $have_unexpected = yes; then
|
||||
AC_DEFINE(HAVE_UNEXPECTED,1,
|
||||
[Define if libobjc has the objc_set_unexpected() function])
|
||||
fi
|
||||
AC_MSG_RESULT($have_unexpected)
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
|
||||
if test "$exceptions" = "yes"; then
|
||||
# ffcall will mess up native exceptions, so we must disable it.
|
||||
do_broken_libffcall=yes
|
||||
do_enable_libffcall=no
|
||||
|
||||
if test "$have_unexpected" = "no"; then
|
||||
echo
|
||||
echo "Your gnustep-make is configured to use native objc exceptions, but"
|
||||
echo "the objc runtime does not appear to support setting an uncaught"
|
||||
echo "exception handler. This means that any uncaught exception will"
|
||||
echo "cause a program to abort immediately."
|
||||
echo "Consider reconfiguring gnustep-make or updating libobjc to fix this."
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(libffi,
|
||||
|
|
Loading…
Reference in a new issue