43 Commits (71e38a048fc06fea0c2015662540d46a33b5c45d)

Author SHA1 Message Date
Frederik Seiffert a357cb999c
tests: Test that we can throw and catch the same exception multiple times sequentially. (#188)
This originally came up as an issue with libc++abi support (#152), but is not specific to that ABI.

* Use the C++ runtime to check for uncaught C++ exceptions.

As discussed in #152, use the function defined in the Itanium C++ ABI to
check whether the thrown exception is the current caught C++ exception
and needs rethrowing via `__cxa_rethrow()`.

Co-authored-by: Niels Grewe <grewe@ocean-insights.com>
Co-authored-by: David Chisnall <gnustep@theravensnest.org>
4 years ago
Frederik Seiffert 06da6a91c3 Suppress EH debug logs in release builds. 5 years ago
Frederik Seiffert cca84b183c Fix building without ObjC++ support. 6 years ago
Frederik Seiffert ed8eec6c6a Add unwind COPY_EXCEPTION macro. 6 years ago
David Chisnall 3b8879720c More EH fixes.
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++.
6 years ago
David Chisnall ec5c0bcae2 More C++ exception fixes.
* 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.
6 years ago
David Chisnall 65d6b279a0 Rework C++ exception interop again.
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
6 years ago
David Chisnall 76e081dc48 Initial run-time detection of C++ EH ABI variant.
On Itanium C++ ABI platforms, there are a lot of different variations
that have subtly different structure layouts.  This commit adds a
run-time test that throws a C++ exception through a function that has
its personality function replaced with a wrapper so that we can inspect
a C++ exception in controlled conditions.

Initially, this just detects the exception type value used for C++
exceptions.
6 years ago
David Chisnall aa775cf835 Fix ObjC++ interop bug.
The reworked wrapping of C++ exceptions meant that we were missing a
dereference of the result of __cxa_begin_catch.

Add a test that triggers this issue.  It would have occurred in the
non-ARC version if we actually did anything with the exception, but
compiling it in ARC mode makes the compiler insert retain / autorelease
around the exception object to ensure that it remains live.
6 years ago
David Chisnall 242442b3aa Rework Objective-C++ exceptions.
The new version now does not depend on the layout of the C++ exception
structure and instead finds the two offsets that it cares about.

Fixes #108
6 years ago
David Chisnall 50493c38d7 Don't use pthread storage for exceptions.
If an exception unwinds to the top of a thread, the process will die, so
don't worry about leaking memory for this case.
7 years ago
David Chisnall 2e6528e82b Fix accidentally inverted preprocessor directive. 7 years ago
David Chisnall acf44d64cb Fix invalid preprocessor directives. 7 years ago
David Chisnall 088977679e DWARF EH cleanups.
Update the C++ ABI for the C++11 ABI and fix the missing ARM-specific
bits.  Work around a bug in ARM.
7 years ago
David Chisnall abf629b1f7 Make some private symbols private. 7 years ago
David Chisnall b81df02b91 Merge branch 'master' into newabi
Simplify the setSubclass dtable updating mechanism.
8 years ago
Dustin Howett 6af4fcb219 Fix eh_personality for NO_PTHREADS 8 years ago
David Chisnall ea5f2920e8 Small cleanups.
Technically, this was undefined behaviour, but it probably worked on most targets.
8 years ago
David Chisnall 7bd78e5b46 Fix a bug in ObjC++ EH.
Throwing an Objective-C exception through a C++ catch block was broken.
This was because the C++ code inserts a cleanup handler to make sure
that it invokes `__cxa_end_catch`.  Unwinding through this catchup
transformed the Objective-C exception into a C++ one.  This case should
have been handled, except for two bugs:

1. A typo (`#ifdef` instead of `#ifndef`) meant that we were not
   extracting the Objective-C exception from the C++ object.
2. We were skipping everything except catchalls after the search phase,
   because we lose some information in the transformation.

Fixes #49
8 years ago
David Chisnall 42b78dba9b (Hopefully) fix C++ exception interop on ARM. 10 years ago
Niels Grewe b2e7c50704 Fix throwing nil exceptions. 10 years ago
theraven a8fe7efdae Make sure we continue unwinding correctly on ARM.
Patch by Logan Chien!
12 years ago
theraven 6317b79a10 Implemented the new exception ABI, and a load of tests for it. This is used by
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.
13 years ago
theraven c6eede8179 GCC-compatibility tweak in EH. 14 years ago
theraven 6cea966cad Remove some accidentally-committed debug stuff. 14 years ago
theraven 9490b1b84e Implement ARM EH support, fix objc_msgSend() to work on ARM. 14 years ago
theraven 8af52846b7 Small object (hidden in a pointer) support. 15 years ago
theraven 9ef84a982c Remove redundant include. 15 years ago
theraven 6c7cf4a5a6 Add visibility attributes on all internal functions so that we aren't ever exporting them outside of libobjc. 15 years ago
theraven 600e970dea Separate ObjC++ support out into libobjcxx. Now code that doesn't need ObjCXX support can safely ignore it again. 15 years ago
theraven 7e465eb325 Tweak building without ObjC++ support a bit. 15 years ago
theraven 3ccb4240cc Fix getting Objective-C objects out of C++ exceptions. 15 years ago
theraven e0719a9c62 Added Objective-C++ exception handling support. Allows throwing Objective-C objects with throw or @throw and catching them with catch() or @catch. 15 years ago
theraven fc28010846 ...but don't catch foreign exceptions in catch statements for the boxing class's superclass. 15 years ago
theraven 4e5578b0be Allow boxed foreign exceptions to be caught in explicit catch statements. 15 years ago
theraven d6455e2a65 More EH tweaks. New ABI now uses "@id" for id catches and NULL for catchalls. Code compiled with GCC and clang with the old ABI will continue to use NULL for catchalls and id catches, which means that C++ exceptions will be caught in their boxed form here and must be explicitly rethrown. 15 years ago
theraven 45c428f9a3 Allow the boxed exception object to rethrow itself, if it knows how. This means that a C++ function can throw a C++ object, we can box it in an ObjC object for passing through Objective-C stack frames, and then unbox it to catch it in C++ code. 15 years ago
theraven 943ed5e714 Some source tidies. 16 years ago
theraven 7ac0904a1f Don't leak memory when throwing exceptions. 16 years ago
theraven 7d0d599241 Fix handling of cleanups while unwinding for exception throwing. 16 years ago
theraven f4e7a7bf5c Return the correct thing to exception handlers. 16 years ago
theraven f375d20d7a Add support for catching C++ (and Java / Ada) exceptions in Objective-C. 16 years ago
theraven 07758fe521 Removed last bits of legacy code from libobjc2. Added new exception handling implementation. 16 years ago