mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-10 12:31:04 +08:00
re PR libobjc/27466 (RFE: Support for libobjc equivalent of std::set_unexpected)
libobjc/ 2009-03-12 Richard Frith-Macdonald <rfm@gnu.org> David Ayers <ayers@fsfe.org> PR libobjc/27466 * objc/objc-api.h (_objc_unexpected_exception): Declare new hook. Update copyright dates. * exception.c (objc_exception_throw): Use hook. Update copyright dates. * libobjc.def (_objc_unexpected_exception): Export hook. Update copyright dates. gcc/testsuite/ 2009-03-12 David Ayers <ayers@fsfe.org> PR libobjc/27466 * objc/execute/exceptions/handler-1.m. New test. From-SVN: r144826
This commit is contained in:
parent
03a181983d
commit
faef499bdf
@ -1,3 +1,8 @@
|
||||
2009-03-12 David Ayers <ayers@fsfe.org>
|
||||
|
||||
PR libobjc/27466
|
||||
* objc/execute/exceptions/handler-1.m. New test.
|
||||
|
||||
2008-03-12 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR target/39431
|
||||
|
38
gcc/testsuite/objc/execute/exceptions/handler-1.m
Normal file
38
gcc/testsuite/objc/execute/exceptions/handler-1.m
Normal file
@ -0,0 +1,38 @@
|
||||
/* Test custom exception handlers */
|
||||
/* Author: David Ayers */
|
||||
|
||||
#include <objc/objc-api.h>
|
||||
#include <objc/Object.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static unsigned int handlerExpected = 0;
|
||||
|
||||
void
|
||||
my_exception_handler(id excp)
|
||||
{
|
||||
/* Returning from the handler would abort. */
|
||||
if (handlerExpected)
|
||||
exit(0);
|
||||
|
||||
abort();
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
_objc_unexpected_exception = my_exception_handler;
|
||||
|
||||
@try
|
||||
{
|
||||
@throw [Object new];
|
||||
}
|
||||
@catch (id exc)
|
||||
{
|
||||
handlerExpected = 1;
|
||||
}
|
||||
|
||||
@throw [Object new];
|
||||
abort();
|
||||
return 0;
|
||||
}
|
@ -1,3 +1,14 @@
|
||||
2009-03-12 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
David Ayers <ayers@fsfe.org>
|
||||
|
||||
PR libobjc/27466
|
||||
* objc/objc-api.h (_objc_unexpected_exception): Declare
|
||||
new hook. Update copyright dates.
|
||||
* exception.c (objc_exception_throw): Use hook. Update
|
||||
copyright dates.
|
||||
* libobjc.def (_objc_unexpected_exception): Export hook.
|
||||
Update copyright dates.
|
||||
|
||||
2009-03-01 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
|
||||
|
||||
* configure: Regenerate.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* The implementation of exception handling primitives for Objective-C.
|
||||
Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
@ -86,6 +86,11 @@ struct lsda_header_info
|
||||
unsigned char call_site_encoding;
|
||||
};
|
||||
|
||||
/* This hook allows libraries to sepecify special actions when an
|
||||
exception is thrown without a handler in place.
|
||||
*/
|
||||
void (*_objc_unexpected_exception) (id exception); /* !T:SAFE */
|
||||
|
||||
static const unsigned char *
|
||||
parse_lsda_header (struct _Unwind_Context *context, const unsigned char *p,
|
||||
struct lsda_header_info *info)
|
||||
@ -486,5 +491,9 @@ objc_exception_throw (id value)
|
||||
#endif
|
||||
|
||||
/* Some sort of unwinding error. */
|
||||
if (_objc_unexpected_exception != 0)
|
||||
{
|
||||
(*_objc_unexpected_exception) (value);
|
||||
}
|
||||
abort ();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
; GNU Objective C Runtime DLL Export Definitions
|
||||
; Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
; Copyright (C) 1997, 2001, 2003, 2005, 2009 Free Software Foundation, Inc.
|
||||
; Contributed by Scott Christley <scottc@net-community.com>
|
||||
;
|
||||
; This file is part of GCC.
|
||||
@ -38,6 +38,7 @@ objc_mutex_deallocate
|
||||
objc_mutex_lock
|
||||
objc_mutex_trylock
|
||||
objc_mutex_unlock
|
||||
_objc_unexpected_exception
|
||||
objc_thread_detach
|
||||
objc_thread_exit
|
||||
objc_thread_get_data
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* GNU Objective-C Runtime API.
|
||||
Copyright (C) 1993, 1995, 1996, 1997, 2002, 2004 Free Software Foundation, Inc.
|
||||
Copyright (C) 1993, 1995, 1996, 1997, 2001, 2002, 2003, 2004, 2005,
|
||||
2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
@ -430,6 +431,15 @@ objc_EXPORT void (*_objc_free)(void *);
|
||||
objc_EXPORT IMP (*__objc_msg_forward)(SEL);
|
||||
objc_EXPORT IMP (*__objc_msg_forward2)(id, SEL);
|
||||
|
||||
/*
|
||||
** Hook for uncaught exceptions. This hook is called when an exception
|
||||
** is thrown and no valid exception handler is in place. The function
|
||||
** is expected never to return. If the function returns the result is
|
||||
** currently undefined.
|
||||
*/
|
||||
objc_EXPORT void (*_objc_unexpected_exception)(id);
|
||||
|
||||
|
||||
Method_t class_get_class_method(MetaClass _class, SEL aSel);
|
||||
|
||||
Method_t class_get_instance_method(Class _class, SEL aSel);
|
||||
|
Loading…
x
Reference in New Issue
Block a user