00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <bits/c++config.h>
00032 #include "unwind-cxx.h"
00033
00034
00035 using namespace __cxxabiv1;
00036
00037
00038 static void
00039 __gxx_exception_cleanup (_Unwind_Reason_Code code, _Unwind_Exception *exc)
00040 {
00041 __cxa_exception *header = __get_exception_header_from_ue (exc);
00042
00043
00044
00045 if (code != _URC_FOREIGN_EXCEPTION_CAUGHT)
00046 __terminate (header->terminateHandler);
00047
00048 if (header->exceptionDestructor)
00049 header->exceptionDestructor (header + 1);
00050
00051 __cxa_free_exception (header + 1);
00052 }
00053
00054
00055 extern "C" void
00056 __cxa_throw (void *obj, std::type_info *tinfo, void (*dest) (void *))
00057 {
00058 __cxa_exception *header = __get_exception_header_from_obj (obj);
00059 header->exceptionType = tinfo;
00060 header->exceptionDestructor = dest;
00061 header->unexpectedHandler = __unexpected_handler;
00062 header->terminateHandler = __terminate_handler;
00063 header->unwindHeader.exception_class = __gxx_exception_class;
00064 header->unwindHeader.exception_cleanup = __gxx_exception_cleanup;
00065
00066 __cxa_eh_globals *globals = __cxa_get_globals ();
00067 globals->uncaughtExceptions += 1;
00068
00069 #ifdef _GLIBCPP_SJLJ_EXCEPTIONS
00070 _Unwind_SjLj_RaiseException (&header->unwindHeader);
00071 #else
00072 _Unwind_RaiseException (&header->unwindHeader);
00073 #endif
00074
00075
00076 __cxa_begin_catch (&header->unwindHeader);
00077 std::terminate ();
00078 }
00079
00080 extern "C" void
00081 __cxa_rethrow ()
00082 {
00083 __cxa_eh_globals *globals = __cxa_get_globals ();
00084 __cxa_exception *header = globals->caughtExceptions;
00085
00086
00087 if (header)
00088 {
00089
00090 header->handlerCount = -header->handlerCount;
00091
00092 #ifdef _GLIBCPP_SJLJ_EXCEPTIONS
00093 _Unwind_SjLj_RaiseException (&header->unwindHeader);
00094 #else
00095 _Unwind_RaiseException (&header->unwindHeader);
00096 #endif
00097
00098
00099 __cxa_begin_catch (&header->unwindHeader);
00100 }
00101 std::terminate ();
00102 }