Whole document tree unwind-cxx.hGo to the documentation of this file.00001 // -*- C++ -*- Exception handling and frame unwind runtime interface routines. 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 // This is derived from the C++ ABI for IA-64. Where we diverge 00022 // for cross-architecture compatibility are noted with "@@@". 00023 00024 #ifndef __UNWIND_CXX_H 00025 #define __UNWIND_CXX_H 1 00026 00027 // Level 2: C++ ABI 00028 00029 #include <typeinfo> 00030 #include <exception> 00031 #include <cstddef> 00032 #include "unwind.h" 00033 00034 namespace __cxxabiv1 00035 { 00036 00037 // A C++ exception object consists of a header, which is a wrapper around 00038 // an unwind object header with additional C++ specific information, 00039 // followed by the exception object itself. 00040 00041 struct __cxa_exception 00042 { 00043 // Manage the exception object itself. 00044 std::type_info *exceptionType; 00045 void (*exceptionDestructor)(void *); 00046 00047 // The C++ standard has entertaining rules wrt calling set_terminate 00048 // and set_unexpected in the middle of the exception cleanup process. 00049 std::unexpected_handler unexpectedHandler; 00050 std::terminate_handler terminateHandler; 00051 00052 // The caught exception stack threads through here. 00053 __cxa_exception *nextException; 00054 00055 // How many nested handlers have caught this exception. A negated 00056 // value is a signal that this object has been rethrown. 00057 int handlerCount; 00058 00059 // Cache parsed handler data from the personality routine Phase 1 00060 // for Phase 2 and __cxa_call_unexpected. 00061 int handlerSwitchValue; 00062 const unsigned char *actionRecord; 00063 const unsigned char *languageSpecificData; 00064 void *catchTemp; 00065 void *adjustedPtr; 00066 00067 // The generic exception header. Must be last. 00068 _Unwind_Exception unwindHeader; 00069 }; 00070 00071 // Each thread in a C++ program has access to a __cxa_eh_globals object. 00072 struct __cxa_eh_globals 00073 { 00074 __cxa_exception *caughtExceptions; 00075 unsigned int uncaughtExceptions; 00076 }; 00077 00078 00079 // The __cxa_eh_globals for the current thread can be obtained by using 00080 // either of the following functions. The "fast" version assumes at least 00081 // one prior call of __cxa_get_globals has been made from the current 00082 // thread, so no initialization is necessary. 00083 extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); 00084 extern "C" __cxa_eh_globals *__cxa_get_globals_fast () throw(); 00085 00086 // Allocate memory for the exception plus the thown object. 00087 extern "C" void *__cxa_allocate_exception(std::size_t thrown_size) throw(); 00088 00089 // Free the space allocated for the exception. 00090 extern "C" void __cxa_free_exception(void *thrown_exception) throw(); 00091 00092 // Throw the exception. 00093 extern "C" void __cxa_throw (void *thrown_exception, 00094 std::type_info *tinfo, 00095 void (*dest) (void *)) 00096 __attribute__((noreturn)); 00097 00098 // Used to implement exception handlers. 00099 extern "C" void *__cxa_begin_catch (_Unwind_Exception *) throw(); 00100 extern "C" void __cxa_end_catch (); 00101 extern "C" void __cxa_rethrow () __attribute__((noreturn)); 00102 00103 // These facilitate code generation for recurring situations. 00104 extern "C" void __cxa_bad_cast (); 00105 extern "C" void __cxa_bad_typeid (); 00106 00107 // @@@ These are not directly specified by the IA-64 C++ ABI. 00108 00109 // Handles re-checking the exception specification if unexpectedHandler 00110 // throws, and if bad_exception needs to be thrown. Called from the 00111 // compiler. 00112 extern "C" void __cxa_call_unexpected (_Unwind_Exception *) 00113 __attribute__((noreturn)); 00114 00115 // Invokes given handler, dying appropriately if the user handler was 00116 // so inconsiderate as to return. 00117 extern void __terminate(std::terminate_handler) __attribute__((noreturn)); 00118 extern void __unexpected(std::unexpected_handler) __attribute__((noreturn)); 00119 00120 // The current installed user handlers. 00121 extern std::terminate_handler __terminate_handler; 00122 extern std::unexpected_handler __unexpected_handler; 00123 00124 // These are explicitly GNU C++ specific. 00125 00126 // This is the exception class we report -- "GNUCC++\0". 00127 const _Unwind_Exception_Class __gxx_exception_class 00128 = ((((((((_Unwind_Exception_Class) 'G' 00129 << 8 | (_Unwind_Exception_Class) 'N') 00130 << 8 | (_Unwind_Exception_Class) 'U') 00131 << 8 | (_Unwind_Exception_Class) 'C') 00132 << 8 | (_Unwind_Exception_Class) 'C') 00133 << 8 | (_Unwind_Exception_Class) '+') 00134 << 8 | (_Unwind_Exception_Class) '+') 00135 << 8 | (_Unwind_Exception_Class) '\0'); 00136 00137 // GNU C++ personality routine, Version 0. 00138 extern "C" _Unwind_Reason_Code __gxx_personality_v0 00139 (int, _Unwind_Action, _Unwind_Exception_Class, 00140 struct _Unwind_Exception *, struct _Unwind_Context *); 00141 00142 // GNU C++ sjlj personality routine, Version 0. 00143 extern "C" _Unwind_Reason_Code __gxx_personality_sj0 00144 (int, _Unwind_Action, _Unwind_Exception_Class, 00145 struct _Unwind_Exception *, struct _Unwind_Context *); 00146 00147 // Acquire the C++ exception header from the C++ object. 00148 static inline __cxa_exception * 00149 __get_exception_header_from_obj (void *ptr) 00150 { 00151 return reinterpret_cast<__cxa_exception *>(ptr) - 1; 00152 } 00153 00154 // Acquire the C++ exception header from the generic exception header. 00155 static inline __cxa_exception * 00156 __get_exception_header_from_ue (_Unwind_Exception *exc) 00157 { 00158 return reinterpret_cast<__cxa_exception *>(exc + 1) - 1; 00159 } 00160 00161 } /* namespace __cxxabiv1 */ 00162 00163 #endif // __UNWIND_CXX_H Generated on Mon Apr 8 03:11:47 2002 for libstdc++-v3 Source by ![]() |