The current implementation uses Vectored Exception Handlers. This implementation is too greedy, and invokes _objc_unexpected_exception for (certain) exceptions which would be handled by the application itself.
libsupc++ is more aggressive about internal consistency checks than
libcxxrt, so we need to be more careful in the interop. The tests from
PR #138 now pass for me on Debian with libsupc++.
* Make sure the unwind state is synchronised between the Objective-C
and C++ exception objects.
* Reintroduce the is-pointer callback so that `__cxa_begin_catch`
adjusts the pointer correctly. Objective-C++ code uses
`__cxa_begin_catch` without the `objc_begin_catch` wrapper and the
runtime does not call the `__do_catch` method on the type info if the
type info is an exact match, so the caught object ended up being a
pointer to the object. This also meant that we needed to remove the
double dereference in the `__do_catch` methods.
* Introduce a subclass of `std::type_info` for all Objective-C types
and move the `virtual` functions there. This should simplify
supporting libc++abi.
We now, the first time we encounter a foreign exception, throw a C++
exception through a frame that has a custom personality function and
probe the layout of the __cxa_exception structure.
We then use the offsets learned from this along with the public ABI
functions for allocating the structure.
At the same time, add a test that we are correctly setting the count of
uncaught exceptions.
Fixes#146
We need to #include <exception> for this to work, but this brings in the
public definition of `std::type_info` and, unfortunately, that breaks
the private definition that we need in this compilation unit.
Recent versions of libstdc++ appear to have lost the clean layering
between libstdc++ and libsupc++, so use the high-level APIs and some
pointer evilness to fudge the low-level ones...
We were only doing it to get two definitions, which are both mandated by
the spec, so we may as well avoid all of the headaches involved.
Also remove the extern "C" from the runtime.h include while we're here,
as it is no longer needed.
Fixes#69
clang trunk if -fobjc-runtime-1.7 is specified and provides significantly
better interoperability with foreign exceptions.
Note: Most of the exception tests will not pass with gcc or clang < 3.3. They
test things that are impossible to implement quite correctly with the
GCC-compatible exception ABI.
Also updated the release notes to reflect recent improvements.
Remove the dependency on <typeinfo> containing the vtable layout for
std::type_info. This allows libobjc2 to be built against libc++ and libcxxrt
and still provide working a unified exception model.
Note: This is broken on FreeBSD < 9.1, because it ships a libsupc++ with a
broken ABI.
catching Objective-C objects in C++ catch statements (i.e. they follow
Objective-C semantics, not C++ semantics, irrespective of whether you use C++
or ObjC syntax). We now default to Apple-compatible behaviour, but provide a
function that allows users to select the sane semantics if they prefer.
Added a capability bit for the unified exception model, so code can require it.
This is not really required, since any code using it will link against the
ObjC++ personality function and will get a linker failure if it isn't supported.
Also enabled Objective-C++ stuff by default. This adds a dependency on the C++
standard library (actually on libsupc++, but GNUstep Make wants to link against
libstd++ anyway), which is not ideal. It can be disabled with:
$ gmake objectiver-cxx=no
I suggest that this is only done by people who know that they will never want
Objective-C++ support.