diff options
author | anonymous <local@localhost> | 2010-10-04 11:35:39 +0700 |
---|---|---|
committer | anonymous <local@localhost> | 2010-10-04 11:35:39 +0700 |
commit | e6a523d6eb2ee53a399da43b55f5b4e1bd7810ec (patch) | |
tree | d88b7daa2d7fbdff3d9f48a9c56148193a0adba7 | |
parent | e34781fc2d3165dff329a48fba4ac8e21e36c748 (diff) | |
download | libcxxrt-e6a523d6eb2ee53a399da43b55f5b4e1bd7810ec.tar.gz libcxxrt-e6a523d6eb2ee53a399da43b55f5b4e1bd7810ec.tar.bz2 libcxxrt-e6a523d6eb2ee53a399da43b55f5b4e1bd7810ec.tar.xz |
__cxa_get_exception_ptr implementation
-rw-r--r-- | src/exception.cc | 10 | ||||
-rw-r--r-- | test/test_exception.cc | 19 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/exception.cc b/src/exception.cc index 272bf30..e0d32da 100644 --- a/src/exception.cc +++ b/src/exception.cc @@ -901,6 +901,16 @@ extern "C" void __cxa_call_unexpected(void*exception) abort(); } +/** + * ABI function, returns the adjusted pointer to the exception object. + */ +extern "C" void *__cxa_get_exception_ptr(void *exceptionObject) { + // exceptionObject is the pointer to the _Unwind_Exception within the + // __cxa_exception. The throw object is after this + return ((char*)exceptionObject + sizeof(_Unwind_Exception)); +} + + namespace std { unexpected_handler set_unexpected(unexpected_handler f) throw() diff --git a/test/test_exception.cc b/test/test_exception.cc index 8149fbf..eb738ba 100644 --- a/test/test_exception.cc +++ b/test/test_exception.cc @@ -29,6 +29,16 @@ struct bar : foo }; +/** + * Non-pod type to test throwing + */ +class non_pod { +public: + non_pod(int i): x(i) {} + int x; +}; + + static int cleanup_count; /** * Simple structure declared with a destructor. Destroying this object will @@ -59,11 +69,12 @@ int inner(int i) case 2: fprintf(stderr, "Throwing int64_t\n");throw (int64_t)1; case 3: { foo f = {2} ; throw f; } case 4: { bar f; f.i = 2 ; f.bar=1 ; throw f; } + case 5: throw non_pod(3); } return -1; } -int outer(int i) throw(float, int, foo) +int outer(int i) throw(float, int, foo, non_pod) { //CLEANUP inner(i); @@ -97,6 +108,11 @@ static void test_catch(int s) TEST((s == 3 || s == 4) && f.i == 2, "Caught struct"); return; } + catch (non_pod np) { + fprintf(stderr, "Caught non_pod {%d}!\n", np.x); + TEST(s == 5 && np.x == 3, "Caught non_pod"); + return; + } //abort(); TEST(0, "Unreachable line reached"); } @@ -153,6 +169,7 @@ void test_exceptions(void) TEST_CLEANUP(test_catch(1)); TEST_CLEANUP(test_catch(3)); TEST_CLEANUP(test_catch(4)); + TEST_CLEANUP(test_catch(5)); TEST_CLEANUP(test_nested()); try{ test_catch(2); |