Whole document tree eh_throw.ccGo to the documentation of this file.00001 // -*- C++ -*- Exception handling routines for throwing. 00002 // Copyright (C) 2001 Free Software Foundation, Inc. 00003 // 00004 // This file is part of GNU CC. 00005 // 00006 // GNU CC is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2, or (at your option) 00009 // any later version. 00010 // 00011 // GNU CC is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with GNU CC; see the file COPYING. If not, write to 00018 // the Free Software Foundation, 59 Temple Place - Suite 330, 00019 // Boston, MA 02111-1307, USA. 00020 00021 // As a special exception, you may use this file as part of a free software 00022 // library without restriction. Specifically, if other files instantiate 00023 // templates or use macros or inline functions from this file, or you compile 00024 // this file and link it with other files to produce an executable, this 00025 // file does not by itself cause the resulting executable to be covered by 00026 // the GNU General Public License. This exception does not however 00027 // invalidate any other reasons why the executable file might be covered by 00028 // the GNU General Public License. 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 // If we havn't been caught by a foreign handler, then this is 00044 // some sort of unwind error. In that case just die immediately. 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 // Some sort of unwinding error. Note that terminate is a handler. 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 // Watch for luser rethrowing with no active exception. 00087 if (header) 00088 { 00089 // Tell __cxa_end_catch this is a rethrow. 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 // Some sort of unwinding error. Note that terminate is a handler. 00099 __cxa_begin_catch (&header->unwindHeader); 00100 } 00101 std::terminate (); 00102 } Generated on Mon Apr 8 03:11:24 2002 for libstdc++-v3 Source by ![]() |