Howard Hinnant | b487f89 | 2011-12-06 18:01:47 +0000 | [diff] [blame] | 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://www.codesourcery.com/public/cxx-abi/abi-eh.html |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Marshall Clow | 2025361 | 2011-07-20 14:53:53 +0000 | [diff] [blame] | 14 | #include <exception> // for std::unexpected_handler and std::terminate_handler |
| 15 | #include <cxxabi.h> |
| 16 | #include "unwind.h" |
| 17 | |
| 18 | namespace __cxxabiv1 { |
| 19 | |
Howard Hinnant | b94f225 | 2012-01-24 18:15:20 +0000 | [diff] [blame^] | 20 | static const uint64_t kOurExceptionClass = 0x434C4E47432B2B00; // CLNGC++\0 |
| 21 | static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1 |
| 22 | |
Marshall Clow | 2025361 | 2011-07-20 14:53:53 +0000 | [diff] [blame] | 23 | struct __cxa_exception { |
| 24 | #if __LP64__ |
| 25 | // This is a new field to support C++ 0x exception_ptr. |
| 26 | // For binary compatibility it is at the start of this |
| 27 | // struct which is prepended to the object thrown in |
| 28 | // __cxa_allocate_exception. |
| 29 | size_t referenceCount; |
| 30 | #endif |
| 31 | |
| 32 | // Manage the exception object itself. |
| 33 | std::type_info *exceptionType; |
| 34 | void (*exceptionDestructor)(void *); |
| 35 | std::unexpected_handler unexpectedHandler; |
| 36 | std::terminate_handler terminateHandler; |
| 37 | |
| 38 | __cxa_exception *nextException; |
| 39 | |
| 40 | int handlerCount; |
| 41 | |
| 42 | #ifdef __ARM_EABI_UNWINDER__ |
| 43 | __cxa_exception* nextPropagatingException; |
| 44 | int propagationCount; |
| 45 | #else |
| 46 | int handlerSwitchValue; |
| 47 | const unsigned char *actionRecord; |
| 48 | const unsigned char *languageSpecificData; |
| 49 | void *catchTemp; |
| 50 | void *adjustedPtr; |
| 51 | #endif |
| 52 | |
| 53 | #if !__LP64__ |
| 54 | // This is a new field to support C++ 0x exception_ptr. |
| 55 | // For binary compatibility it is placed where the compiler |
| 56 | // previously adding padded to 64-bit align unwindHeader. |
| 57 | size_t referenceCount; |
| 58 | #endif |
| 59 | |
| 60 | _Unwind_Exception unwindHeader; |
| 61 | }; |
Howard Hinnant | a6baba1 | 2011-12-08 19:35:18 +0000 | [diff] [blame] | 62 | |
| 63 | // http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html |
Marshall Clow | 2025361 | 2011-07-20 14:53:53 +0000 | [diff] [blame] | 64 | |
| 65 | struct __cxa_dependent_exception { |
| 66 | #if __LP64__ |
| 67 | void* primaryException; |
| 68 | #endif |
| 69 | |
Marshall Clow | 2025361 | 2011-07-20 14:53:53 +0000 | [diff] [blame] | 70 | std::type_info *exceptionType; |
| 71 | void (*exceptionDestructor)(void *); |
Marshall Clow | 2025361 | 2011-07-20 14:53:53 +0000 | [diff] [blame] | 72 | std::unexpected_handler unexpectedHandler; |
| 73 | std::terminate_handler terminateHandler; |
| 74 | |
| 75 | __cxa_exception *nextException; |
| 76 | |
| 77 | int handlerCount; |
| 78 | |
| 79 | #ifdef __ARM_EABI_UNWINDER__ |
| 80 | __cxa_exception* nextPropagatingException; |
| 81 | int propagationCount; |
| 82 | #else |
| 83 | int handlerSwitchValue; |
| 84 | const unsigned char *actionRecord; |
| 85 | const unsigned char *languageSpecificData; |
| 86 | void * catchTemp; |
| 87 | void *adjustedPtr; |
| 88 | #endif |
| 89 | |
| 90 | #if !__LP64__ |
| 91 | void* primaryException; |
| 92 | #endif |
| 93 | |
| 94 | _Unwind_Exception unwindHeader; |
| 95 | }; |
| 96 | |
| 97 | struct __cxa_eh_globals { |
| 98 | __cxa_exception * caughtExceptions; |
| 99 | unsigned int uncaughtExceptions; |
| 100 | #ifdef __ARM_EABI_UNWINDER__ |
| 101 | __cxa_exception* propagatingExceptions; |
| 102 | #endif |
| 103 | }; |
| 104 | |
| 105 | extern "C" __cxa_eh_globals * __cxa_get_globals () throw(); |
| 106 | extern "C" __cxa_eh_globals * __cxa_get_globals_fast () throw(); |
| 107 | |
| 108 | extern "C" void * __cxa_allocate_dependent_exception () throw(); |
| 109 | extern "C" void __cxa_free_dependent_exception (void * dependent_exception) throw(); |
| 110 | |
| 111 | } |