Commit faef499b by David Ayers

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
parent 03a18198
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
......
/* 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;
}
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.
......
/* 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 ();
}
; 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
......
/* 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment