Louis Dionne | 7f068e5 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 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 gcc extensions to the C++ ABI Exception Handling Level 1. |
| 9 | // |
| 10 | //===----------------------------------------------------------------------===// |
| 11 | |
| 12 | #include <inttypes.h> |
| 13 | #include <stdbool.h> |
| 14 | #include <stdint.h> |
| 15 | #include <stdio.h> |
| 16 | #include <stdlib.h> |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 17 | #include <string.h> |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 18 | |
| 19 | #include "config.h" |
| 20 | #include "libunwind_ext.h" |
| 21 | #include "libunwind.h" |
| 22 | #include "Unwind-EHABI.h" |
| 23 | #include "unwind.h" |
| 24 | |
Xing Xue | 030b4eb | 2022-08-12 18:07:56 -0400 | [diff] [blame] | 25 | #if defined(_AIX) |
| 26 | #include <sys/debug.h> |
| 27 | #endif |
| 28 | |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 29 | #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 30 | |
Charles Davis | fa2e620 | 2018-08-30 21:29:00 +0000 | [diff] [blame] | 31 | #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND) |
Daniel Kiss | 6bf52ee | 2021-08-11 10:11:30 +0200 | [diff] [blame] | 32 | #define PRIVATE_1 private_[0] |
| 33 | #elif defined(_LIBUNWIND_ARM_EHABI) |
| 34 | #define PRIVATE_1 unwinder_cache.reserved1 |
| 35 | #else |
| 36 | #define PRIVATE_1 private_1 |
Charles Davis | fa2e620 | 2018-08-30 21:29:00 +0000 | [diff] [blame] | 37 | #endif |
| 38 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 39 | /// Called by __cxa_rethrow(). |
| 40 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 41 | _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) { |
Daniel Kiss | 6bf52ee | 2021-08-11 10:11:30 +0200 | [diff] [blame] | 42 | _LIBUNWIND_TRACE_API( |
| 43 | "_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR, |
| 44 | (void *)exception_object, (intptr_t)exception_object->PRIVATE_1); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 45 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 46 | // If this is non-forced and a stopping place was found, then this is a |
| 47 | // re-throw. |
| 48 | // Call _Unwind_RaiseException() as if this was a new exception |
Daniel Kiss | 6bf52ee | 2021-08-11 10:11:30 +0200 | [diff] [blame] | 49 | if (exception_object->PRIVATE_1 == 0) { |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 50 | return _Unwind_RaiseException(exception_object); |
| 51 | // Will return if there is no catch clause, so that __cxa_rethrow can call |
| 52 | // std::terminate(). |
| 53 | } |
| 54 | |
Gabriel Ravier | 42aa6de | 2022-08-20 18:09:03 -0700 | [diff] [blame^] | 55 | // Call through to _Unwind_Resume() which distinguishes between forced and |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 56 | // regular exceptions. |
| 57 | _Unwind_Resume(exception_object); |
| 58 | _LIBUNWIND_ABORT("_Unwind_Resume_or_Rethrow() called _Unwind_RaiseException()" |
| 59 | " which unexpectedly returned"); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 60 | } |
| 61 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 62 | /// Called by personality handler during phase 2 to get base address for data |
| 63 | /// relative encodings. |
| 64 | _LIBUNWIND_EXPORT uintptr_t |
| 65 | _Unwind_GetDataRelBase(struct _Unwind_Context *context) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 66 | _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", (void *)context); |
Xing Xue | bbcbce9 | 2022-04-13 11:01:59 -0400 | [diff] [blame] | 67 | #if defined(_AIX) |
| 68 | return unw_get_data_rel_base((unw_cursor_t *)context); |
| 69 | #else |
| 70 | (void)context; |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 71 | _LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented"); |
Xing Xue | bbcbce9 | 2022-04-13 11:01:59 -0400 | [diff] [blame] | 72 | #endif |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 75 | /// Called by personality handler during phase 2 to get base address for text |
| 76 | /// relative encodings. |
| 77 | _LIBUNWIND_EXPORT uintptr_t |
| 78 | _Unwind_GetTextRelBase(struct _Unwind_Context *context) { |
| 79 | (void)context; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 80 | _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", (void *)context); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 81 | _LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented"); |
| 82 | } |
| 83 | |
| 84 | |
| 85 | /// Scans unwind information to find the function that contains the |
| 86 | /// specified code address "pc". |
| 87 | _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 88 | _LIBUNWIND_TRACE_API("_Unwind_FindEnclosingFunction(pc=%p)", pc); |
Xing Xue | 030b4eb | 2022-08-12 18:07:56 -0400 | [diff] [blame] | 89 | #if defined(_AIX) |
| 90 | if (pc == NULL) |
| 91 | return NULL; |
| 92 | |
| 93 | // Get the start address of the enclosing function from the function's |
| 94 | // traceback table. |
| 95 | uint32_t *p = (uint32_t *)pc; |
| 96 | |
| 97 | // Keep looking forward until a word of 0 is found. The traceback |
| 98 | // table starts at the following word. |
| 99 | while (*p) |
| 100 | ++p; |
| 101 | struct tbtable *TBTable = (struct tbtable *)(p + 1); |
| 102 | |
| 103 | // Get the address of the traceback table extension. |
| 104 | p = (uint32_t *)&TBTable->tb_ext; |
| 105 | |
| 106 | // Skip field parminfo if it exists. |
| 107 | if (TBTable->tb.fixedparms || TBTable->tb.floatparms) |
| 108 | ++p; |
| 109 | |
| 110 | if (TBTable->tb.has_tboff) |
| 111 | // *p contains the offset from the function start to traceback table. |
| 112 | return (void *)((uintptr_t)TBTable - *p - sizeof(uint32_t)); |
| 113 | return NULL; |
| 114 | #else |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 115 | // This is slow, but works. |
| 116 | // We create an unwind cursor then alter the IP to be pc |
| 117 | unw_cursor_t cursor; |
| 118 | unw_context_t uc; |
| 119 | unw_proc_info_t info; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 120 | __unw_getcontext(&uc); |
| 121 | __unw_init_local(&cursor, &uc); |
| 122 | __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc); |
| 123 | if (__unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS) |
Charles Davis | 5aede5d | 2018-08-08 04:21:24 +0000 | [diff] [blame] | 124 | return (void *)(intptr_t) info.start_ip; |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 125 | else |
| 126 | return NULL; |
Xing Xue | 030b4eb | 2022-08-12 18:07:56 -0400 | [diff] [blame] | 127 | #endif |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | /// Walk every frame and call trace function at each one. If trace function |
| 131 | /// returns anything other than _URC_NO_REASON, then walk is terminated. |
| 132 | _LIBUNWIND_EXPORT _Unwind_Reason_Code |
| 133 | _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { |
| 134 | unw_cursor_t cursor; |
| 135 | unw_context_t uc; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 136 | __unw_getcontext(&uc); |
| 137 | __unw_init_local(&cursor, &uc); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 138 | |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 139 | _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 140 | (void *)(uintptr_t)callback); |
| 141 | |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 142 | #if defined(_LIBUNWIND_ARM_EHABI) |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 143 | // Create a mock exception object for force unwinding. |
| 144 | _Unwind_Exception ex; |
| 145 | memset(&ex, '\0', sizeof(ex)); |
Hans Wennborg | edf77b2 | 2021-09-02 18:43:26 +0200 | [diff] [blame] | 146 | strcpy((char *)&ex.exception_class, "CLNGUNW"); |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 147 | #endif |
| 148 | |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 149 | // walk each frame |
| 150 | while (true) { |
| 151 | _Unwind_Reason_Code result; |
| 152 | |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 153 | #if !defined(_LIBUNWIND_ARM_EHABI) |
Ed Maste | 6f72338 | 2016-08-30 13:08:21 +0000 | [diff] [blame] | 154 | // ask libunwind to get next frame (skip over first frame which is |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 155 | // _Unwind_Backtrace()) |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 156 | if (__unw_step(&cursor) <= 0) { |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 157 | _LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached " |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 158 | "bottom of stack, returning %d", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 159 | _URC_END_OF_STACK); |
| 160 | return _URC_END_OF_STACK; |
| 161 | } |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 162 | #else |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 163 | // Get the information for this frame. |
| 164 | unw_proc_info_t frameInfo; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 165 | if (__unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) { |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 166 | return _URC_END_OF_STACK; |
| 167 | } |
| 168 | |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 169 | // Update the pr_cache in the mock exception object. |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 170 | const uint32_t* unwindInfo = (uint32_t *) frameInfo.unwind_info; |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 171 | ex.pr_cache.fnstart = frameInfo.start_ip; |
| 172 | ex.pr_cache.ehtp = (_Unwind_EHT_Header *) unwindInfo; |
| 173 | ex.pr_cache.additional= frameInfo.flags; |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 174 | |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 175 | struct _Unwind_Context *context = (struct _Unwind_Context *)&cursor; |
| 176 | // Get and call the personality function to unwind the frame. |
Saleem Abdulrasool | 214b72e | 2020-02-10 08:52:31 -0800 | [diff] [blame] | 177 | _Unwind_Personality_Fn handler = (_Unwind_Personality_Fn)frameInfo.handler; |
Logan Chien | a54f096 | 2015-05-29 15:33:38 +0000 | [diff] [blame] | 178 | if (handler == NULL) { |
| 179 | return _URC_END_OF_STACK; |
| 180 | } |
| 181 | if (handler(_US_VIRTUAL_UNWIND_FRAME | _US_FORCE_UNWIND, &ex, context) != |
| 182 | _URC_CONTINUE_UNWIND) { |
| 183 | return _URC_END_OF_STACK; |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 184 | } |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 185 | #endif // defined(_LIBUNWIND_ARM_EHABI) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 186 | |
| 187 | // debugging |
| 188 | if (_LIBUNWIND_TRACING_UNWINDING) { |
| 189 | char functionName[512]; |
| 190 | unw_proc_info_t frame; |
| 191 | unw_word_t offset; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 192 | __unw_get_proc_name(&cursor, functionName, 512, &offset); |
| 193 | __unw_get_proc_info(&cursor, &frame); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 194 | _LIBUNWIND_TRACE_UNWINDING( |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 195 | " _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p", |
| 196 | frame.start_ip, functionName, frame.lsda, |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 197 | (void *)&cursor); |
| 198 | } |
| 199 | |
| 200 | // call trace function with this frame |
| 201 | result = (*callback)((struct _Unwind_Context *)(&cursor), ref); |
| 202 | if (result != _URC_NO_REASON) { |
| 203 | _LIBUNWIND_TRACE_UNWINDING( |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 204 | " _backtrace: ended because callback returned %d", result); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 205 | return result; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | |
Ed Maste | 4c43c3d | 2016-07-19 17:15:50 +0000 | [diff] [blame] | 211 | /// Find DWARF unwind info for an address 'pc' in some function. |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 212 | _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc, |
| 213 | struct dwarf_eh_bases *bases) { |
| 214 | // This is slow, but works. |
| 215 | // We create an unwind cursor then alter the IP to be pc |
| 216 | unw_cursor_t cursor; |
| 217 | unw_context_t uc; |
| 218 | unw_proc_info_t info; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 219 | __unw_getcontext(&uc); |
| 220 | __unw_init_local(&cursor, &uc); |
| 221 | __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc); |
| 222 | __unw_get_proc_info(&cursor, &info); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 223 | bases->tbase = (uintptr_t)info.extra; |
| 224 | bases->dbase = 0; // dbase not used on Mac OS X |
| 225 | bases->func = (uintptr_t)info.start_ip; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 226 | _LIBUNWIND_TRACE_API("_Unwind_Find_FDE(pc=%p) => %p", pc, |
Charles Davis | 5aede5d | 2018-08-08 04:21:24 +0000 | [diff] [blame] | 227 | (void *)(intptr_t) info.unwind_info); |
| 228 | return (void *)(intptr_t) info.unwind_info; |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /// Returns the CFA (call frame area, or stack pointer at start of function) |
| 232 | /// for the current context. |
| 233 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) { |
| 234 | unw_cursor_t *cursor = (unw_cursor_t *)context; |
| 235 | unw_word_t result; |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 236 | __unw_get_reg(cursor, UNW_REG_SP, &result); |
Martin Storsjo | 97e2d98 | 2017-10-30 19:06:34 +0000 | [diff] [blame] | 237 | _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR, |
| 238 | (void *)context, result); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 239 | return (uintptr_t)result; |
| 240 | } |
| 241 | |
| 242 | |
| 243 | /// Called by personality handler during phase 2 to get instruction pointer. |
| 244 | /// ipBefore is a boolean that says if IP is already adjusted to be the call |
| 245 | /// site address. Normally IP is the return address. |
| 246 | _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context, |
| 247 | int *ipBefore) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 248 | _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p)", (void *)context); |
Sterling Augustine | b6a6639 | 2019-10-31 12:45:20 -0700 | [diff] [blame] | 249 | int isSignalFrame = __unw_is_signal_frame((unw_cursor_t *)context); |
| 250 | // Negative means some kind of error (probably UNW_ENOINFO), but we have no |
| 251 | // good way to report that, and this maintains backward compatibility with the |
| 252 | // implementation that hard-coded zero in every case, even signal frames. |
| 253 | if (isSignalFrame <= 0) |
| 254 | *ipBefore = 0; |
| 255 | else |
| 256 | *ipBefore = 1; |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 257 | return _Unwind_GetIP(context); |
| 258 | } |
| 259 | |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 260 | #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 261 | |
| 262 | /// Called by programs with dynamic code generators that want |
| 263 | /// to register a dynamically generated FDE. |
| 264 | /// This function has existed on Mac OS X since 10.4, but |
| 265 | /// was broken until 10.6. |
| 266 | _LIBUNWIND_EXPORT void __register_frame(const void *fde) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 267 | _LIBUNWIND_TRACE_API("__register_frame(%p)", fde); |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 268 | __unw_add_dynamic_fde((unw_word_t)(uintptr_t)fde); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | |
| 272 | /// Called by programs with dynamic code generators that want |
| 273 | /// to unregister a dynamically generated FDE. |
| 274 | /// This function has existed on Mac OS X since 10.4, but |
| 275 | /// was broken until 10.6. |
| 276 | _LIBUNWIND_EXPORT void __deregister_frame(const void *fde) { |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 277 | _LIBUNWIND_TRACE_API("__deregister_frame(%p)", fde); |
Petr Hosek | 9bbfad5 | 2019-04-03 21:50:03 +0000 | [diff] [blame] | 278 | __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)fde); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | |
| 282 | // The following register/deregister functions are gcc extensions. |
| 283 | // They have existed on Mac OS X, but have never worked because Mac OS X |
| 284 | // before 10.6 used keymgr to track known FDEs, but these functions |
| 285 | // never got updated to use keymgr. |
| 286 | // For now, we implement these as do-nothing functions to keep any existing |
| 287 | // applications working. We also add the not in 10.6 symbol so that nwe |
| 288 | // application won't be able to use them. |
| 289 | |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 290 | #if defined(_LIBUNWIND_SUPPORT_FRAME_APIS) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 291 | _LIBUNWIND_EXPORT void __register_frame_info_bases(const void *fde, void *ob, |
| 292 | void *tb, void *db) { |
| 293 | (void)fde; |
| 294 | (void)ob; |
| 295 | (void)tb; |
| 296 | (void)db; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 297 | _LIBUNWIND_TRACE_API("__register_frame_info_bases(%p,%p, %p, %p)", |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 298 | fde, ob, tb, db); |
| 299 | // do nothing, this function never worked in Mac OS X |
| 300 | } |
| 301 | |
| 302 | _LIBUNWIND_EXPORT void __register_frame_info(const void *fde, void *ob) { |
| 303 | (void)fde; |
| 304 | (void)ob; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 305 | _LIBUNWIND_TRACE_API("__register_frame_info(%p, %p)", fde, ob); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 306 | // do nothing, this function never worked in Mac OS X |
| 307 | } |
| 308 | |
| 309 | _LIBUNWIND_EXPORT void __register_frame_info_table_bases(const void *fde, |
| 310 | void *ob, void *tb, |
| 311 | void *db) { |
| 312 | (void)fde; |
| 313 | (void)ob; |
| 314 | (void)tb; |
| 315 | (void)db; |
| 316 | _LIBUNWIND_TRACE_API("__register_frame_info_table_bases" |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 317 | "(%p,%p, %p, %p)", fde, ob, tb, db); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 318 | // do nothing, this function never worked in Mac OS X |
| 319 | } |
| 320 | |
| 321 | _LIBUNWIND_EXPORT void __register_frame_info_table(const void *fde, void *ob) { |
| 322 | (void)fde; |
| 323 | (void)ob; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 324 | _LIBUNWIND_TRACE_API("__register_frame_info_table(%p, %p)", fde, ob); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 325 | // do nothing, this function never worked in Mac OS X |
| 326 | } |
| 327 | |
| 328 | _LIBUNWIND_EXPORT void __register_frame_table(const void *fde) { |
| 329 | (void)fde; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 330 | _LIBUNWIND_TRACE_API("__register_frame_table(%p)", fde); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 331 | // do nothing, this function never worked in Mac OS X |
| 332 | } |
| 333 | |
| 334 | _LIBUNWIND_EXPORT void *__deregister_frame_info(const void *fde) { |
| 335 | (void)fde; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 336 | _LIBUNWIND_TRACE_API("__deregister_frame_info(%p)", fde); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 337 | // do nothing, this function never worked in Mac OS X |
| 338 | return NULL; |
| 339 | } |
| 340 | |
| 341 | _LIBUNWIND_EXPORT void *__deregister_frame_info_bases(const void *fde) { |
| 342 | (void)fde; |
Ed Maste | 41bc5a7 | 2016-08-30 15:38:10 +0000 | [diff] [blame] | 343 | _LIBUNWIND_TRACE_API("__deregister_frame_info_bases(%p)", fde); |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 344 | // do nothing, this function never worked in Mac OS X |
| 345 | return NULL; |
| 346 | } |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 347 | #endif // defined(_LIBUNWIND_SUPPORT_FRAME_APIS) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 348 | |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 349 | #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) |
Saleem Abdulrasool | 1755266 | 2015-04-24 19:39:17 +0000 | [diff] [blame] | 350 | |
Ranjeet Singh | 421231a | 2017-03-31 15:28:06 +0000 | [diff] [blame] | 351 | #endif // defined(_LIBUNWIND_BUILD_ZERO_COST_APIS) |