1//===------------------------- cxa_exception.hpp --------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8// 9// This file implements the "Exception Handling APIs" 10// http://mentorembedded.github.io/cxx-abi/abi-eh.html 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef _CXA_EXCEPTION_H 15#define _CXA_EXCEPTION_H 16 17#include <exception> // for std::unexpected_handler and std::terminate_handler 18#include <cxxabi.h> 19#include "unwind.h" 20 21namespace __cxxabiv1 { 22 23#pragma GCC visibility push(hidden) 24 25static const uint64_t kOurExceptionClass = 0x434C4E47432B2B00; // CLNGC++\0 26static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1 27static const uint64_t get_vendor_and_language = 0xFFFFFFFFFFFFFF00; // mask for CLNGC++ 28 29struct __cxa_exception { 30#if __LP64__ || LIBCXXABI_ARM_EHABI 31 // This is a new field to support C++ 0x exception_ptr. 32 // For binary compatibility it is at the start of this 33 // struct which is prepended to the object thrown in 34 // __cxa_allocate_exception. 35 size_t referenceCount; 36#endif 37 38 // Manage the exception object itself. 39 std::type_info *exceptionType; 40 void (*exceptionDestructor)(void *); 41 std::unexpected_handler unexpectedHandler; 42 std::terminate_handler terminateHandler; 43 44 __cxa_exception *nextException; 45 46 int handlerCount; 47 48#if LIBCXXABI_ARM_EHABI 49 __cxa_exception* nextPropagatingException; 50 int propagationCount; 51#else 52 int handlerSwitchValue; 53 const unsigned char *actionRecord; 54 const unsigned char *languageSpecificData; 55 void *catchTemp; 56 void *adjustedPtr; 57#endif 58 59#if !__LP64__ && !LIBCXXABI_ARM_EHABI 60 // This is a new field to support C++ 0x exception_ptr. 61 // For binary compatibility it is placed where the compiler 62 // previously adding padded to 64-bit align unwindHeader. 63 size_t referenceCount; 64#endif 65 66 _Unwind_Exception unwindHeader; 67}; 68 69// http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html 70// The layout of this structure MUST match the layout of __cxa_exception, with 71// primaryException instead of referenceCount. 72struct __cxa_dependent_exception { 73#if __LP64__ || LIBCXXABI_ARM_EHABI 74 void* primaryException; 75#endif 76 77 std::type_info *exceptionType; 78 void (*exceptionDestructor)(void *); 79 std::unexpected_handler unexpectedHandler; 80 std::terminate_handler terminateHandler; 81 82 __cxa_exception *nextException; 83 84 int handlerCount; 85 86#if LIBCXXABI_ARM_EHABI 87 __cxa_exception* nextPropagatingException; 88 int propagationCount; 89#else 90 int handlerSwitchValue; 91 const unsigned char *actionRecord; 92 const unsigned char *languageSpecificData; 93 void * catchTemp; 94 void *adjustedPtr; 95#endif 96 97#if !__LP64__ && !LIBCXXABI_ARM_EHABI 98 void* primaryException; 99#endif 100 101 _Unwind_Exception unwindHeader; 102}; 103 104struct __cxa_eh_globals { 105 __cxa_exception * caughtExceptions; 106 unsigned int uncaughtExceptions; 107#if LIBCXXABI_ARM_EHABI 108 __cxa_exception* propagatingExceptions; 109#endif 110}; 111 112#pragma GCC visibility pop 113#pragma GCC visibility push(default) 114 115extern "C" __cxa_eh_globals * __cxa_get_globals (); 116extern "C" __cxa_eh_globals * __cxa_get_globals_fast (); 117 118extern "C" void * __cxa_allocate_dependent_exception (); 119extern "C" void __cxa_free_dependent_exception (void * dependent_exception); 120 121#pragma GCC visibility pop 122 123} // namespace __cxxabiv1 124 125#endif // _CXA_EXCEPTION_H 126