Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 1 | //===------------------------- UnwindLevel1.c -----------------------------===// |
| 2 | // |
Chandler Carruth | 61860a5 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 6 | // |
| 7 | // |
| 8 | // Implements C++ ABI Exception Handling Level 1 as documented at: |
Louis Dionne | 59d0c60 | 2019-04-11 16:37:07 +0000 | [diff] [blame] | 9 | // https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 10 | // using libunwind |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Logan Chien | 5456e8d | 2015-07-24 00:16:48 +0000 | [diff] [blame] | 14 | // ARM EHABI does not specify _Unwind_{Get,Set}{GR,IP}(). Thus, we are |
| 15 | // defining inline functions to delegate the function calls to |
| 16 | // _Unwind_VRS_{Get,Set}(). However, some applications might declare the |
| 17 | // function protetype directly (instead of including <unwind.h>), thus we need |
| 18 | // to export these functions from libunwind.so as well. |
| 19 | #define _LIBUNWIND_UNWIND_LEVEL1_EXTERNAL_LINKAGE 1 |
| 20 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 21 | #include <inttypes.h> |
| 22 | #include <stdint.h> |
| 23 | #include <stdbool.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <stdio.h> |
| 26 | #include <string.h> |
| 27 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 28 | #include "config.h" |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 29 | #include "libunwind.h" |
| 30 | #include "libunwind_ext.h" |
| 31 | #include "unwind.h" |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 32 | |
Martin Storsjo | 9f16c6c | 2017-09-26 08:07:26 +0000 | [diff] [blame] | 33 | #if !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 34 | |
Charles Davis | fa2e620 | 2018-08-30 21:29:00 +0000 | [diff] [blame] | 35 | #ifndef _LIBUNWIND_SUPPORT_SEH_UNWIND |
| 36 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 37 | static _Unwind_Reason_Code |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 38 | unwind_phase1(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) { |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 39 | __unw_init_local(cursor, uc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 40 | |
| 41 | // Walk each frame looking for a place to stop. |
Fangrui Song | 45db2df | 2020-11-21 12:38:00 -0800 | [diff] [blame] | 42 | while (true) { |
Ed Maste | 6f72338 | 2016-08-30 13:08:21 +0000 | [diff] [blame] | 43 | // Ask libunwind to get next frame (skip over first which is |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 44 | // _Unwind_RaiseException). |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 45 | int stepResult = __unw_step(cursor); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 46 | if (stepResult == 0) { |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 47 | _LIBUNWIND_TRACE_UNWINDING( |
| 48 | "unwind_phase1(ex_ojb=%p): __unw_step() reached " |
| 49 | "bottom => _URC_END_OF_STACK", |
| 50 | (void *)exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 51 | return _URC_END_OF_STACK; |
| 52 | } else if (stepResult < 0) { |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 53 | _LIBUNWIND_TRACE_UNWINDING( |
| 54 | "unwind_phase1(ex_ojb=%p): __unw_step failed => " |
| 55 | "_URC_FATAL_PHASE1_ERROR", |
| 56 | (void *)exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 57 | return _URC_FATAL_PHASE1_ERROR; |
| 58 | } |
| 59 | |
| 60 | // See if frame has code to run (has personality routine). |
| 61 | unw_proc_info_t frameInfo; |
| 62 | unw_word_t sp; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 63 | if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) { |
| 64 | _LIBUNWIND_TRACE_UNWINDING( |
| 65 | "unwind_phase1(ex_ojb=%p): __unw_get_proc_info " |
| 66 | "failed => _URC_FATAL_PHASE1_ERROR", |
| 67 | (void *)exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 68 | return _URC_FATAL_PHASE1_ERROR; |
| 69 | } |
| 70 | |
Daniel Kiss | 7729bc9 | 2021-08-11 10:11:31 +0200 | [diff] [blame^] | 71 | #ifndef NDEBUG |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 72 | // When tracing, print state information. |
| 73 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 74 | char functionBuf[512]; |
| 75 | const char *functionName = functionBuf; |
| 76 | unw_word_t offset; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 77 | if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf), |
| 78 | &offset) != UNW_ESUCCESS) || |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 79 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 80 | functionName = ".anonymous."; |
| 81 | unw_word_t pc; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 82 | __unw_get_reg(cursor, UNW_REG_IP, &pc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 83 | _LIBUNWIND_TRACE_UNWINDING( |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 84 | "unwind_phase1(ex_ojb=%p): pc=0x%" PRIxPTR ", start_ip=0x%" PRIxPTR |
| 85 | ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR "", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 86 | (void *)exception_object, pc, frameInfo.start_ip, functionName, |
| 87 | frameInfo.lsda, frameInfo.handler); |
| 88 | } |
Daniel Kiss | 7729bc9 | 2021-08-11 10:11:31 +0200 | [diff] [blame^] | 89 | #endif |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 90 | |
| 91 | // If there is a personality routine, ask it if it will want to stop at |
| 92 | // this frame. |
| 93 | if (frameInfo.handler != 0) { |
Saleem Abdulrasool | 214b72e | 2020-02-10 08:52:31 -0800 | [diff] [blame] | 94 | _Unwind_Personality_Fn p = |
| 95 | (_Unwind_Personality_Fn)(uintptr_t)(frameInfo.handler); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 96 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 97 | "unwind_phase1(ex_ojb=%p): calling personality function %p", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 98 | (void *)exception_object, (void *)(uintptr_t)p); |
| 99 | _Unwind_Reason_Code personalityResult = |
| 100 | (*p)(1, _UA_SEARCH_PHASE, exception_object->exception_class, |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 101 | exception_object, (struct _Unwind_Context *)(cursor)); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 102 | switch (personalityResult) { |
| 103 | case _URC_HANDLER_FOUND: |
| 104 | // found a catch clause or locals that need destructing in this frame |
| 105 | // stop search and remember stack pointer at the frame |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 106 | __unw_get_reg(cursor, UNW_REG_SP, &sp); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 107 | exception_object->private_2 = (uintptr_t)sp; |
| 108 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 109 | "unwind_phase1(ex_ojb=%p): _URC_HANDLER_FOUND", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 110 | (void *)exception_object); |
| 111 | return _URC_NO_REASON; |
| 112 | |
| 113 | case _URC_CONTINUE_UNWIND: |
| 114 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 115 | "unwind_phase1(ex_ojb=%p): _URC_CONTINUE_UNWIND", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 116 | (void *)exception_object); |
| 117 | // continue unwinding |
| 118 | break; |
| 119 | |
| 120 | default: |
| 121 | // something went wrong |
| 122 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 123 | "unwind_phase1(ex_ojb=%p): _URC_FATAL_PHASE1_ERROR", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 124 | (void *)exception_object); |
| 125 | return _URC_FATAL_PHASE1_ERROR; |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | return _URC_NO_REASON; |
| 130 | } |
| 131 | |
| 132 | |
| 133 | static _Unwind_Reason_Code |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 134 | unwind_phase2(unw_context_t *uc, unw_cursor_t *cursor, _Unwind_Exception *exception_object) { |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 135 | __unw_init_local(cursor, uc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 136 | |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 137 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p)", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 138 | (void *)exception_object); |
| 139 | |
| 140 | // Walk each frame until we reach where search phase said to stop. |
| 141 | while (true) { |
| 142 | |
Ed Maste | 6f72338 | 2016-08-30 13:08:21 +0000 | [diff] [blame] | 143 | // Ask libunwind to get next frame (skip over first which is |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 144 | // _Unwind_RaiseException). |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 145 | int stepResult = __unw_step(cursor); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 146 | if (stepResult == 0) { |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 147 | _LIBUNWIND_TRACE_UNWINDING( |
| 148 | "unwind_phase2(ex_ojb=%p): __unw_step() reached " |
| 149 | "bottom => _URC_END_OF_STACK", |
| 150 | (void *)exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 151 | return _URC_END_OF_STACK; |
| 152 | } else if (stepResult < 0) { |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 153 | _LIBUNWIND_TRACE_UNWINDING( |
| 154 | "unwind_phase2(ex_ojb=%p): __unw_step failed => " |
| 155 | "_URC_FATAL_PHASE1_ERROR", |
| 156 | (void *)exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 157 | return _URC_FATAL_PHASE2_ERROR; |
| 158 | } |
| 159 | |
| 160 | // Get info about this frame. |
| 161 | unw_word_t sp; |
| 162 | unw_proc_info_t frameInfo; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 163 | __unw_get_reg(cursor, UNW_REG_SP, &sp); |
| 164 | if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) { |
| 165 | _LIBUNWIND_TRACE_UNWINDING( |
| 166 | "unwind_phase2(ex_ojb=%p): __unw_get_proc_info " |
| 167 | "failed => _URC_FATAL_PHASE1_ERROR", |
| 168 | (void *)exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 169 | return _URC_FATAL_PHASE2_ERROR; |
| 170 | } |
| 171 | |
Daniel Kiss | 7729bc9 | 2021-08-11 10:11:31 +0200 | [diff] [blame^] | 172 | #ifndef NDEBUG |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 173 | // When tracing, print state information. |
| 174 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 175 | char functionBuf[512]; |
| 176 | const char *functionName = functionBuf; |
| 177 | unw_word_t offset; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 178 | if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf), |
| 179 | &offset) != UNW_ESUCCESS) || |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 180 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 181 | functionName = ".anonymous."; |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 182 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIxPTR |
| 183 | ", func=%s, sp=0x%" PRIxPTR ", lsda=0x%" PRIxPTR |
| 184 | ", personality=0x%" PRIxPTR, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 185 | (void *)exception_object, frameInfo.start_ip, |
| 186 | functionName, sp, frameInfo.lsda, |
| 187 | frameInfo.handler); |
| 188 | } |
Daniel Kiss | 7729bc9 | 2021-08-11 10:11:31 +0200 | [diff] [blame^] | 189 | #endif |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 190 | |
| 191 | // If there is a personality routine, tell it we are unwinding. |
| 192 | if (frameInfo.handler != 0) { |
Saleem Abdulrasool | 214b72e | 2020-02-10 08:52:31 -0800 | [diff] [blame] | 193 | _Unwind_Personality_Fn p = |
| 194 | (_Unwind_Personality_Fn)(uintptr_t)(frameInfo.handler); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 195 | _Unwind_Action action = _UA_CLEANUP_PHASE; |
| 196 | if (sp == exception_object->private_2) { |
| 197 | // Tell personality this was the frame it marked in phase 1. |
| 198 | action = (_Unwind_Action)(_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME); |
| 199 | } |
| 200 | _Unwind_Reason_Code personalityResult = |
| 201 | (*p)(1, action, exception_object->exception_class, exception_object, |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 202 | (struct _Unwind_Context *)(cursor)); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 203 | switch (personalityResult) { |
| 204 | case _URC_CONTINUE_UNWIND: |
| 205 | // Continue unwinding |
| 206 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 207 | "unwind_phase2(ex_ojb=%p): _URC_CONTINUE_UNWIND", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 208 | (void *)exception_object); |
| 209 | if (sp == exception_object->private_2) { |
| 210 | // Phase 1 said we would stop at this frame, but we did not... |
| 211 | _LIBUNWIND_ABORT("during phase1 personality function said it would " |
| 212 | "stop here, but now in phase2 it did not stop here"); |
| 213 | } |
| 214 | break; |
| 215 | case _URC_INSTALL_CONTEXT: |
| 216 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 217 | "unwind_phase2(ex_ojb=%p): _URC_INSTALL_CONTEXT", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 218 | (void *)exception_object); |
| 219 | // Personality routine says to transfer control to landing pad. |
| 220 | // We may get control back if landing pad calls _Unwind_Resume(). |
| 221 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 222 | unw_word_t pc; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 223 | __unw_get_reg(cursor, UNW_REG_IP, &pc); |
| 224 | __unw_get_reg(cursor, UNW_REG_SP, &sp); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 225 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): re-entering " |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 226 | "user code with ip=0x%" PRIxPTR |
| 227 | ", sp=0x%" PRIxPTR, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 228 | (void *)exception_object, pc, sp); |
| 229 | } |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 230 | __unw_resume(cursor); |
| 231 | // __unw_resume() only returns if there was an error. |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 232 | return _URC_FATAL_PHASE2_ERROR; |
| 233 | default: |
| 234 | // Personality routine returned an unknown result code. |
| 235 | _LIBUNWIND_DEBUG_LOG("personality function returned unknown result %d", |
| 236 | personalityResult); |
| 237 | return _URC_FATAL_PHASE2_ERROR; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | // Clean up phase did not resume at the frame that the search phase |
| 243 | // said it would... |
| 244 | return _URC_FATAL_PHASE2_ERROR; |
| 245 | } |
| 246 | |
| 247 | static _Unwind_Reason_Code |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 248 | unwind_phase2_forced(unw_context_t *uc, unw_cursor_t *cursor, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 249 | _Unwind_Exception *exception_object, |
| 250 | _Unwind_Stop_Fn stop, void *stop_parameter) { |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 251 | __unw_init_local(cursor, uc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 252 | |
| 253 | // Walk each frame until we reach where search phase said to stop |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 254 | while (__unw_step(cursor) > 0) { |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 255 | |
| 256 | // Update info about this frame. |
| 257 | unw_proc_info_t frameInfo; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 258 | if (__unw_get_proc_info(cursor, &frameInfo) != UNW_ESUCCESS) { |
| 259 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): __unw_step " |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 260 | "failed => _URC_END_OF_STACK", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 261 | (void *)exception_object); |
| 262 | return _URC_FATAL_PHASE2_ERROR; |
| 263 | } |
| 264 | |
Daniel Kiss | 7729bc9 | 2021-08-11 10:11:31 +0200 | [diff] [blame^] | 265 | #ifndef NDEBUG |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 266 | // When tracing, print state information. |
| 267 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 268 | char functionBuf[512]; |
| 269 | const char *functionName = functionBuf; |
| 270 | unw_word_t offset; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 271 | if ((__unw_get_proc_name(cursor, functionBuf, sizeof(functionBuf), |
| 272 | &offset) != UNW_ESUCCESS) || |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 273 | (frameInfo.start_ip + offset > frameInfo.end_ip)) |
| 274 | functionName = ".anonymous."; |
| 275 | _LIBUNWIND_TRACE_UNWINDING( |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 276 | "unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIxPTR |
| 277 | ", func=%s, lsda=0x%" PRIxPTR ", personality=0x%" PRIxPTR, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 278 | (void *)exception_object, frameInfo.start_ip, functionName, |
| 279 | frameInfo.lsda, frameInfo.handler); |
| 280 | } |
Daniel Kiss | 7729bc9 | 2021-08-11 10:11:31 +0200 | [diff] [blame^] | 281 | #endif |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 282 | |
| 283 | // Call stop function at each frame. |
| 284 | _Unwind_Action action = |
| 285 | (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE); |
| 286 | _Unwind_Reason_Code stopResult = |
| 287 | (*stop)(1, action, exception_object->exception_class, exception_object, |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 288 | (struct _Unwind_Context *)(cursor), stop_parameter); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 289 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 290 | "unwind_phase2_forced(ex_ojb=%p): stop function returned %d", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 291 | (void *)exception_object, stopResult); |
| 292 | if (stopResult != _URC_NO_REASON) { |
| 293 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 294 | "unwind_phase2_forced(ex_ojb=%p): stopped by stop function", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 295 | (void *)exception_object); |
| 296 | return _URC_FATAL_PHASE2_ERROR; |
| 297 | } |
| 298 | |
| 299 | // If there is a personality routine, tell it we are unwinding. |
| 300 | if (frameInfo.handler != 0) { |
Saleem Abdulrasool | 214b72e | 2020-02-10 08:52:31 -0800 | [diff] [blame] | 301 | _Unwind_Personality_Fn p = |
| 302 | (_Unwind_Personality_Fn)(intptr_t)(frameInfo.handler); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 303 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 304 | "unwind_phase2_forced(ex_ojb=%p): calling personality function %p", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 305 | (void *)exception_object, (void *)(uintptr_t)p); |
| 306 | _Unwind_Reason_Code personalityResult = |
| 307 | (*p)(1, action, exception_object->exception_class, exception_object, |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 308 | (struct _Unwind_Context *)(cursor)); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 309 | switch (personalityResult) { |
| 310 | case _URC_CONTINUE_UNWIND: |
| 311 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 312 | "personality returned " |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 313 | "_URC_CONTINUE_UNWIND", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 314 | (void *)exception_object); |
| 315 | // Destructors called, continue unwinding |
| 316 | break; |
| 317 | case _URC_INSTALL_CONTEXT: |
| 318 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 319 | "personality returned " |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 320 | "_URC_INSTALL_CONTEXT", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 321 | (void *)exception_object); |
| 322 | // We may get control back if landing pad calls _Unwind_Resume(). |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 323 | __unw_resume(cursor); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 324 | break; |
| 325 | default: |
| 326 | // Personality routine returned an unknown result code. |
| 327 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): " |
| 328 | "personality returned %d, " |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 329 | "_URC_FATAL_PHASE2_ERROR", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 330 | (void *)exception_object, personalityResult); |
| 331 | return _URC_FATAL_PHASE2_ERROR; |
| 332 | } |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | // Call stop function one last time and tell it we've reached the end |
| 337 | // of the stack. |
| 338 | _LIBUNWIND_TRACE_UNWINDING("unwind_phase2_forced(ex_ojb=%p): calling stop " |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 339 | "function with _UA_END_OF_STACK", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 340 | (void *)exception_object); |
| 341 | _Unwind_Action lastAction = |
| 342 | (_Unwind_Action)(_UA_FORCE_UNWIND | _UA_CLEANUP_PHASE | _UA_END_OF_STACK); |
| 343 | (*stop)(1, lastAction, exception_object->exception_class, exception_object, |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 344 | (struct _Unwind_Context *)(cursor), stop_parameter); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 345 | |
| 346 | // Clean up phase did not resume at the frame that the search phase said it |
| 347 | // would. |
| 348 | return _URC_FATAL_PHASE2_ERROR; |
| 349 | } |
| 350 | |
| 351 | |
| 352 | /// Called by __cxa_throw. Only returns if there is a fatal error. |
| 353 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 354 | _Unwind_RaiseException(_Unwind_Exception *exception_object) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 355 | _LIBUNWIND_TRACE_API("_Unwind_RaiseException(ex_obj=%p)", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 356 | (void *)exception_object); |
| 357 | unw_context_t uc; |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 358 | unw_cursor_t cursor; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 359 | __unw_getcontext(&uc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 360 | |
| 361 | // Mark that this is a non-forced unwind, so _Unwind_Resume() |
| 362 | // can do the right thing. |
| 363 | exception_object->private_1 = 0; |
| 364 | exception_object->private_2 = 0; |
| 365 | |
| 366 | // phase 1: the search phase |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 367 | _Unwind_Reason_Code phase1 = unwind_phase1(&uc, &cursor, exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 368 | if (phase1 != _URC_NO_REASON) |
| 369 | return phase1; |
| 370 | |
| 371 | // phase 2: the clean up phase |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 372 | return unwind_phase2(&uc, &cursor, exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | |
| 376 | |
| 377 | /// When _Unwind_RaiseException() is in phase2, it hands control |
| 378 | /// to the personality function at each frame. The personality |
| 379 | /// may force a jump to a landing pad in that function, the landing |
| 380 | /// pad code may then call _Unwind_Resume() to continue with the |
| 381 | /// unwinding. Note: the call to _Unwind_Resume() is from compiler |
| 382 | /// geneated user code. All other _Unwind_* routines are called |
| 383 | /// by the C++ runtime __cxa_* routines. |
| 384 | /// |
| 385 | /// Note: re-throwing an exception (as opposed to continuing the unwind) |
| 386 | /// is implemented by having the code call __cxa_rethrow() which |
| 387 | /// in turn calls _Unwind_Resume_or_Rethrow(). |
| 388 | _LIBUNWIND_EXPORT void |
| 389 | _Unwind_Resume(_Unwind_Exception *exception_object) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 390 | _LIBUNWIND_TRACE_API("_Unwind_Resume(ex_obj=%p)", (void *)exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 391 | unw_context_t uc; |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 392 | unw_cursor_t cursor; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 393 | __unw_getcontext(&uc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 394 | |
| 395 | if (exception_object->private_1 != 0) |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 396 | unwind_phase2_forced(&uc, &cursor, exception_object, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 397 | (_Unwind_Stop_Fn) exception_object->private_1, |
| 398 | (void *)exception_object->private_2); |
| 399 | else |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 400 | unwind_phase2(&uc, &cursor, exception_object); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 401 | |
| 402 | // Clients assume _Unwind_Resume() does not return, so all we can do is abort. |
| 403 | _LIBUNWIND_ABORT("_Unwind_Resume() can't return"); |
| 404 | } |
| 405 | |
| 406 | |
| 407 | |
| 408 | /// Not used by C++. |
| 409 | /// Unwinds stack, calling "stop" function at each frame. |
| 410 | /// Could be used to implement longjmp(). |
| 411 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 412 | _Unwind_ForcedUnwind(_Unwind_Exception *exception_object, |
| 413 | _Unwind_Stop_Fn stop, void *stop_parameter) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 414 | _LIBUNWIND_TRACE_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 415 | (void *)exception_object, (void *)(uintptr_t)stop); |
| 416 | unw_context_t uc; |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 417 | unw_cursor_t cursor; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 418 | __unw_getcontext(&uc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 419 | |
| 420 | // Mark that this is a forced unwind, so _Unwind_Resume() can do |
| 421 | // the right thing. |
| 422 | exception_object->private_1 = (uintptr_t) stop; |
| 423 | exception_object->private_2 = (uintptr_t) stop_parameter; |
| 424 | |
| 425 | // do it |
Asiri Rathnayake | 2ae6e62 | 2016-06-14 15:51:01 +0000 | [diff] [blame] | 426 | return unwind_phase2_forced(&uc, &cursor, exception_object, stop, stop_parameter); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | |
| 430 | /// Called by personality handler during phase 2 to get LSDA for current frame. |
| 431 | _LIBUNWIND_EXPORT uintptr_t |
| 432 | _Unwind_GetLanguageSpecificData(struct _Unwind_Context *context) { |
| 433 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 434 | unw_proc_info_t frameInfo; |
| 435 | uintptr_t result = 0; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 436 | if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 437 | result = (uintptr_t)frameInfo.lsda; |
| 438 | _LIBUNWIND_TRACE_API( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 439 | "_Unwind_GetLanguageSpecificData(context=%p) => 0x%" PRIxPTR, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 440 | (void *)context, result); |
| 441 | if (result != 0) { |
| 442 | if (*((uint8_t *)result) != 0xFF) |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 443 | _LIBUNWIND_DEBUG_LOG("lsda at 0x%" PRIxPTR " does not start with 0xFF", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 444 | result); |
| 445 | } |
| 446 | return result; |
| 447 | } |
| 448 | |
| 449 | |
| 450 | /// Called by personality handler during phase 2 to find the start of the |
| 451 | /// function. |
| 452 | _LIBUNWIND_EXPORT uintptr_t |
| 453 | _Unwind_GetRegionStart(struct _Unwind_Context *context) { |
| 454 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 455 | unw_proc_info_t frameInfo; |
| 456 | uintptr_t result = 0; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 457 | if (__unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 458 | result = (uintptr_t)frameInfo.start_ip; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 459 | _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%" PRIxPTR, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 460 | (void *)context, result); |
| 461 | return result; |
| 462 | } |
| 463 | |
Charles Davis | fa2e620 | 2018-08-30 21:29:00 +0000 | [diff] [blame] | 464 | #endif // !_LIBUNWIND_SUPPORT_SEH_UNWIND |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 465 | |
| 466 | /// Called by personality handler during phase 2 if a foreign exception |
| 467 | // is caught. |
| 468 | _LIBUNWIND_EXPORT void |
| 469 | _Unwind_DeleteException(_Unwind_Exception *exception_object) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 470 | _LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 471 | (void *)exception_object); |
| 472 | if (exception_object->exception_cleanup != NULL) |
| 473 | (*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT, |
| 474 | exception_object); |
| 475 | } |
| 476 | |
| 477 | /// Called by personality handler during phase 2 to get register values. |
| 478 | _LIBUNWIND_EXPORT uintptr_t |
| 479 | _Unwind_GetGR(struct _Unwind_Context *context, int index) { |
| 480 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 481 | unw_word_t result; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 482 | __unw_get_reg(cursor, index, &result); |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 483 | _LIBUNWIND_TRACE_API("_Unwind_GetGR(context=%p, reg=%d) => 0x%" PRIxPTR, |
| 484 | (void *)context, index, result); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 485 | return (uintptr_t)result; |
| 486 | } |
| 487 | |
| 488 | /// Called by personality handler during phase 2 to alter register values. |
| 489 | _LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index, |
| 490 | uintptr_t value) { |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 491 | _LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%0" PRIxPTR |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 492 | ")", |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 493 | (void *)context, index, value); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 494 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 495 | __unw_set_reg(cursor, index, value); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | /// Called by personality handler during phase 2 to get instruction pointer. |
| 499 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) { |
| 500 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 501 | unw_word_t result; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 502 | __unw_get_reg(cursor, UNW_REG_IP, &result); |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 503 | _LIBUNWIND_TRACE_API("_Unwind_GetIP(context=%p) => 0x%" PRIxPTR, |
| 504 | (void *)context, result); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 505 | return (uintptr_t)result; |
| 506 | } |
| 507 | |
| 508 | /// Called by personality handler during phase 2 to alter instruction pointer, |
| 509 | /// such as setting where the landing pad is, so _Unwind_Resume() will |
| 510 | /// start executing in the landing pad. |
| 511 | _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context, |
| 512 | uintptr_t value) { |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 513 | _LIBUNWIND_TRACE_API("_Unwind_SetIP(context=%p, value=0x%0" PRIxPTR ")", |
| 514 | (void *)context, value); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 515 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 516 | __unw_set_reg(cursor, UNW_REG_IP, value); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 517 | } |
| 518 | |
Martin Storsjo | 9f16c6c | 2017-09-26 08:07:26 +0000 | [diff] [blame] | 519 | #endif // !defined(_LIBUNWIND_ARM_EHABI) && !defined(__USING_SJLJ_EXCEPTIONS__) |