Bug 27466 - RFE: Support for libobjc equivalent of std::set_unexpected
Summary: RFE: Support for libobjc equivalent of std::set_unexpected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libobjc (show other bugs)
Version: 4.0.3
: P3 enhancement
Target Milestone: 4.4.0
Assignee: ayers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-07 03:27 UTC by Landon Fuller
Modified: 2009-03-14 17:05 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-07-09 08:06:53


Attachments
An implementation of objc_set_unexpected function (2.89 KB, patch)
2008-11-28 15:56 UTC, rfm
Details | Diff
Updated patch (using and accessor function) inlcuding a test case (852 bytes, patch)
2009-02-26 05:16 UTC, David Ayers
Details | Diff
Alternative patch using a callback hook (911 bytes, patch)
2009-02-26 05:24 UTC, David Ayers
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Landon Fuller 2006-05-07 03:27:54 UTC
libobjc's exception implementation doesn't support a user-supplied default uncaught exception handler, and this would be a very handy feature to have.

With the equivalent of std:set_unexpected, one could implement the NSSetUncaughtExceptionHandler() Foundation API.
Comment 1 Andrew Pinski 2006-05-07 06:24:10 UTC
It will most likely be called objc_set_unexpected like all other libobjc functions and then GNUStep will implement NSSetUncaughtExceptionHandler.
Comment 2 rfm 2008-11-28 15:56:40 UTC
Created attachment 16787 [details]
An implementation of objc_set_unexpected function

We really need this function to use native objective-c in GNUstep.
The tiny attached patch does what the gnustep-base library needs ... providing a function to set a hanlder to be called if an exception is not caught.  Please could you apply it or something similar.
Comment 3 rfm 2008-12-08 08:29:07 UTC
Any news on when this can be done?  The path is tiny/trivial, so even though it might be judged low priority I'd have hoped it could be fitted in quickly.
Comment 4 rfm 2008-12-17 09:36:05 UTC
Is anyone monitoring/progressing this bug?
Comment 5 rfm 2009-01-01 15:08:55 UTC
I just checked up on this again ... 
The problem was initially reported two and a half years ago.
I supplied a (very very simple) patch to fix it a month ago.
Could someone please apply the patch so it gets into the next release?
Comment 6 David Ayers 2009-02-26 05:16:56 UTC
Created attachment 17364 [details]
Updated patch (using and accessor function) inlcuding a test case

For the record:

This is an update of the existing patch which includes a test case.  This was posted as an RFA: http://gcc.gnu.org/ml/gcc-patches/2009-02/msg01085.html with the following ChangeLog entries:

2009-02-23  Richard Frith-Macdonald  <rfm@gnu.org>

       PR libobjc/27466
       * objc/objc-api.h: declare objc_set_unexpected function.
       * exception.c: implement objc_set_unexpected function.
       * libobjc.def: export objc_set_unexpected

2009-02-23  David Ayers  <ayers@fsfe.org>

       PR libobjc/27466
       * objc/execute/exceptions/handler-1.m. New.
Comment 7 David Ayers 2009-02-26 05:24:34 UTC
Created attachment 17365 [details]
Alternative patch using a callback hook

This patch was posted as an RFA:
http://gcc.gnu.org/ml/gcc-patches/2009-02/msg01086.html

With the following ChangeLog entry:

2009-02-23  Richard Frith-Macdonald  <rfm@gnu.org>
            David Ayers  <ayers@fsfe.org>

        PR libobjc/27466
        * objc/objc-api.h (_objc_unexpected_exception): Declare new
	  hook.
        * exception.c (objc_exception_throw): Use hook.
        * libobjc.def (_objc_unexpected_exception): Export hook.

2009-02-23  David Ayers  <ayers@fsfe.org>

        PR libobjc/27466
        * objc/execute/exceptions/handler-1.m. New.
Comment 8 ayers 2009-03-12 22:28:27 UTC
Subject: Bug 27466

Author: ayers
Date: Thu Mar 12 22:28:15 2009
New Revision: 144826

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144826
Log:
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.


Added:
    trunk/gcc/testsuite/objc/execute/exceptions/handler-1.m
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libobjc/ChangeLog
    trunk/libobjc/exception.c
    trunk/libobjc/libobjc.def
    trunk/libobjc/objc/objc-api.h

Comment 9 ayers 2009-03-14 17:05:36 UTC
Fixed for 4.4.0