6 typedef void *(unexpected_handler)(void);
7 typedef void *(terminate_handler)(void);
9 struct _Unwind_Context;
13 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
14 _URC_FATAL_PHASE2_ERROR = 2,
15 _URC_FATAL_PHASE1_ERROR = 3,
17 _URC_END_OF_STACK = 5,
18 _URC_HANDLER_FOUND = 6,
19 _URC_INSTALL_CONTEXT = 7,
20 _URC_CONTINUE_UNWIND = 8
21 } _Unwind_Reason_Code;
23 typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code reason, struct _Unwind_Exception *exc);
25 struct _Unwind_Exception
27 uint64_t exception_class;
28 _Unwind_Exception_Cleanup_Fn exception_cleanup;
33 struct __cxa_exception
35 std::type_info* exceptionType;
36 void (*exceptionDestructor)(void *);
37 unexpected_handler unexpectedHandler;
38 terminate_handler terminateHandler;
39 __cxa_exception* nextException;
43 int handlerSwitchValue;
44 const char* actionRecord;
45 const char* languageSpecificData;
49 _Unwind_Exception unwindHeader;
52 int uncaught_exception_count;
53 __cxa_exception *uncaught_exception_top;
55 extern "C" void __cxa_call_unexpected(void *)
57 // An unexpected exception was thrown from a function that lists its possible exceptions
61 extern "C" void *__cxa_begin_catch(void *exceptionObject)
63 struct __cxa_exception *except = static_cast<__cxa_exception*>( exceptionObject );
66 except->handlerCount ++;
68 except->nextException = uncaught_exception_top;
69 uncaught_exception_top = except;
71 uncaught_exception_count --;
76 extern "C" void __cxa_end_catch()
78 struct __cxa_exception *except = uncaught_exception_top;
79 except->handlerCount --;
80 uncaught_exception_top = except->nextException;
82 if( except->handlerCount == 0 ) {
83 //__cxa_free_exception(except+1);