1349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //
80b57cec5SDimitry Andric // Implements gcc extensions to the C++ ABI Exception Handling Level 1.
90b57cec5SDimitry Andric //
100b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
110b57cec5SDimitry Andric
120b57cec5SDimitry Andric #include <inttypes.h>
130b57cec5SDimitry Andric #include <stdbool.h>
140b57cec5SDimitry Andric #include <stdint.h>
150b57cec5SDimitry Andric #include <stdio.h>
160b57cec5SDimitry Andric #include <stdlib.h>
170b57cec5SDimitry Andric #include <string.h>
180b57cec5SDimitry Andric
190b57cec5SDimitry Andric #include "config.h"
200b57cec5SDimitry Andric #include "libunwind_ext.h"
210b57cec5SDimitry Andric #include "libunwind.h"
220b57cec5SDimitry Andric #include "Unwind-EHABI.h"
230b57cec5SDimitry Andric #include "unwind.h"
240b57cec5SDimitry Andric
25bdd1243dSDimitry Andric #if defined(_AIX)
26bdd1243dSDimitry Andric #include <sys/debug.h>
27bdd1243dSDimitry Andric #endif
28bdd1243dSDimitry Andric
290b57cec5SDimitry Andric #if defined(_LIBUNWIND_BUILD_ZERO_COST_APIS)
300b57cec5SDimitry Andric
310b57cec5SDimitry Andric #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
32349cc55cSDimitry Andric #define PRIVATE_1 private_[0]
33349cc55cSDimitry Andric #elif defined(_LIBUNWIND_ARM_EHABI)
34349cc55cSDimitry Andric #define PRIVATE_1 unwinder_cache.reserved1
35349cc55cSDimitry Andric #else
36349cc55cSDimitry Andric #define PRIVATE_1 private_1
370b57cec5SDimitry Andric #endif
380b57cec5SDimitry Andric
390b57cec5SDimitry Andric /// Called by __cxa_rethrow().
400b57cec5SDimitry Andric _LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_Resume_or_Rethrow(_Unwind_Exception * exception_object)410b57cec5SDimitry Andric _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) {
42349cc55cSDimitry Andric _LIBUNWIND_TRACE_API(
43349cc55cSDimitry Andric "_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR,
44349cc55cSDimitry Andric (void *)exception_object, (intptr_t)exception_object->PRIVATE_1);
450b57cec5SDimitry Andric
460b57cec5SDimitry Andric // If this is non-forced and a stopping place was found, then this is a
470b57cec5SDimitry Andric // re-throw.
480b57cec5SDimitry Andric // Call _Unwind_RaiseException() as if this was a new exception
49349cc55cSDimitry Andric if (exception_object->PRIVATE_1 == 0) {
500b57cec5SDimitry Andric return _Unwind_RaiseException(exception_object);
510b57cec5SDimitry Andric // Will return if there is no catch clause, so that __cxa_rethrow can call
520b57cec5SDimitry Andric // std::terminate().
530b57cec5SDimitry Andric }
540b57cec5SDimitry Andric
55bdd1243dSDimitry Andric // Call through to _Unwind_Resume() which distinguishes between forced and
560b57cec5SDimitry Andric // regular exceptions.
570b57cec5SDimitry Andric _Unwind_Resume(exception_object);
580b57cec5SDimitry Andric _LIBUNWIND_ABORT("_Unwind_Resume_or_Rethrow() called _Unwind_RaiseException()"
590b57cec5SDimitry Andric " which unexpectedly returned");
600b57cec5SDimitry Andric }
610b57cec5SDimitry Andric
620b57cec5SDimitry Andric /// Called by personality handler during phase 2 to get base address for data
630b57cec5SDimitry Andric /// relative encodings.
640b57cec5SDimitry Andric _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetDataRelBase(struct _Unwind_Context * context)650b57cec5SDimitry Andric _Unwind_GetDataRelBase(struct _Unwind_Context *context) {
660b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("_Unwind_GetDataRelBase(context=%p)", (void *)context);
6781ad6265SDimitry Andric #if defined(_AIX)
6881ad6265SDimitry Andric return unw_get_data_rel_base((unw_cursor_t *)context);
6981ad6265SDimitry Andric #else
7081ad6265SDimitry Andric (void)context;
710b57cec5SDimitry Andric _LIBUNWIND_ABORT("_Unwind_GetDataRelBase() not implemented");
7281ad6265SDimitry Andric #endif
730b57cec5SDimitry Andric }
740b57cec5SDimitry Andric
750b57cec5SDimitry Andric /// Called by personality handler during phase 2 to get base address for text
760b57cec5SDimitry Andric /// relative encodings.
770b57cec5SDimitry Andric _LIBUNWIND_EXPORT uintptr_t
_Unwind_GetTextRelBase(struct _Unwind_Context * context)780b57cec5SDimitry Andric _Unwind_GetTextRelBase(struct _Unwind_Context *context) {
790b57cec5SDimitry Andric (void)context;
800b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("_Unwind_GetTextRelBase(context=%p)", (void *)context);
810b57cec5SDimitry Andric _LIBUNWIND_ABORT("_Unwind_GetTextRelBase() not implemented");
820b57cec5SDimitry Andric }
830b57cec5SDimitry Andric
840b57cec5SDimitry Andric
850b57cec5SDimitry Andric /// Scans unwind information to find the function that contains the
860b57cec5SDimitry Andric /// specified code address "pc".
_Unwind_FindEnclosingFunction(void * pc)870b57cec5SDimitry Andric _LIBUNWIND_EXPORT void *_Unwind_FindEnclosingFunction(void *pc) {
880b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("_Unwind_FindEnclosingFunction(pc=%p)", pc);
89bdd1243dSDimitry Andric #if defined(_AIX)
90bdd1243dSDimitry Andric if (pc == NULL)
91bdd1243dSDimitry Andric return NULL;
92bdd1243dSDimitry Andric
93bdd1243dSDimitry Andric // Get the start address of the enclosing function from the function's
94bdd1243dSDimitry Andric // traceback table.
95bdd1243dSDimitry Andric uint32_t *p = (uint32_t *)pc;
96bdd1243dSDimitry Andric
97bdd1243dSDimitry Andric // Keep looking forward until a word of 0 is found. The traceback
98bdd1243dSDimitry Andric // table starts at the following word.
99bdd1243dSDimitry Andric while (*p)
100bdd1243dSDimitry Andric ++p;
101bdd1243dSDimitry Andric struct tbtable *TBTable = (struct tbtable *)(p + 1);
102bdd1243dSDimitry Andric
103bdd1243dSDimitry Andric // Get the address of the traceback table extension.
104bdd1243dSDimitry Andric p = (uint32_t *)&TBTable->tb_ext;
105bdd1243dSDimitry Andric
106bdd1243dSDimitry Andric // Skip field parminfo if it exists.
107bdd1243dSDimitry Andric if (TBTable->tb.fixedparms || TBTable->tb.floatparms)
108bdd1243dSDimitry Andric ++p;
109bdd1243dSDimitry Andric
110bdd1243dSDimitry Andric if (TBTable->tb.has_tboff)
111bdd1243dSDimitry Andric // *p contains the offset from the function start to traceback table.
112bdd1243dSDimitry Andric return (void *)((uintptr_t)TBTable - *p - sizeof(uint32_t));
113bdd1243dSDimitry Andric return NULL;
114bdd1243dSDimitry Andric #else
1150b57cec5SDimitry Andric // This is slow, but works.
1160b57cec5SDimitry Andric // We create an unwind cursor then alter the IP to be pc
1170b57cec5SDimitry Andric unw_cursor_t cursor;
1180b57cec5SDimitry Andric unw_context_t uc;
1190b57cec5SDimitry Andric unw_proc_info_t info;
1200b57cec5SDimitry Andric __unw_getcontext(&uc);
1210b57cec5SDimitry Andric __unw_init_local(&cursor, &uc);
1220b57cec5SDimitry Andric __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
1230b57cec5SDimitry Andric if (__unw_get_proc_info(&cursor, &info) == UNW_ESUCCESS)
1240b57cec5SDimitry Andric return (void *)(intptr_t) info.start_ip;
1250b57cec5SDimitry Andric else
1260b57cec5SDimitry Andric return NULL;
127bdd1243dSDimitry Andric #endif
1280b57cec5SDimitry Andric }
1290b57cec5SDimitry Andric
1300b57cec5SDimitry Andric /// Walk every frame and call trace function at each one. If trace function
1310b57cec5SDimitry Andric /// returns anything other than _URC_NO_REASON, then walk is terminated.
1320b57cec5SDimitry Andric _LIBUNWIND_EXPORT _Unwind_Reason_Code
_Unwind_Backtrace(_Unwind_Trace_Fn callback,void * ref)1330b57cec5SDimitry Andric _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
1340b57cec5SDimitry Andric unw_cursor_t cursor;
1350b57cec5SDimitry Andric unw_context_t uc;
1360b57cec5SDimitry Andric __unw_getcontext(&uc);
1370b57cec5SDimitry Andric __unw_init_local(&cursor, &uc);
1380b57cec5SDimitry Andric
1390b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)",
1400b57cec5SDimitry Andric (void *)(uintptr_t)callback);
1410b57cec5SDimitry Andric
1420b57cec5SDimitry Andric #if defined(_LIBUNWIND_ARM_EHABI)
1430b57cec5SDimitry Andric // Create a mock exception object for force unwinding.
1440b57cec5SDimitry Andric _Unwind_Exception ex;
1450b57cec5SDimitry Andric memset(&ex, '\0', sizeof(ex));
146*5f757f3fSDimitry Andric memcpy(&ex.exception_class, "CLNGUNW", sizeof(ex.exception_class));
1470b57cec5SDimitry Andric #endif
1480b57cec5SDimitry Andric
1490b57cec5SDimitry Andric // walk each frame
1500b57cec5SDimitry Andric while (true) {
1510b57cec5SDimitry Andric _Unwind_Reason_Code result;
1520b57cec5SDimitry Andric
1530b57cec5SDimitry Andric #if !defined(_LIBUNWIND_ARM_EHABI)
1540b57cec5SDimitry Andric // ask libunwind to get next frame (skip over first frame which is
1550b57cec5SDimitry Andric // _Unwind_Backtrace())
1560b57cec5SDimitry Andric if (__unw_step(&cursor) <= 0) {
1570b57cec5SDimitry Andric _LIBUNWIND_TRACE_UNWINDING(" _backtrace: ended because cursor reached "
1580b57cec5SDimitry Andric "bottom of stack, returning %d",
1590b57cec5SDimitry Andric _URC_END_OF_STACK);
1600b57cec5SDimitry Andric return _URC_END_OF_STACK;
1610b57cec5SDimitry Andric }
1620b57cec5SDimitry Andric #else
1630b57cec5SDimitry Andric // Get the information for this frame.
1640b57cec5SDimitry Andric unw_proc_info_t frameInfo;
1650b57cec5SDimitry Andric if (__unw_get_proc_info(&cursor, &frameInfo) != UNW_ESUCCESS) {
1660b57cec5SDimitry Andric return _URC_END_OF_STACK;
1670b57cec5SDimitry Andric }
1680b57cec5SDimitry Andric
1690b57cec5SDimitry Andric // Update the pr_cache in the mock exception object.
17006c3fb27SDimitry Andric uint32_t *unwindInfo = (uint32_t *)frameInfo.unwind_info;
1710b57cec5SDimitry Andric ex.pr_cache.fnstart = frameInfo.start_ip;
1720b57cec5SDimitry Andric ex.pr_cache.ehtp = (_Unwind_EHT_Header *) unwindInfo;
1730b57cec5SDimitry Andric ex.pr_cache.additional= frameInfo.flags;
1740b57cec5SDimitry Andric
1750b57cec5SDimitry Andric struct _Unwind_Context *context = (struct _Unwind_Context *)&cursor;
1760b57cec5SDimitry Andric // Get and call the personality function to unwind the frame.
1775ffd83dbSDimitry Andric _Unwind_Personality_Fn handler = (_Unwind_Personality_Fn)frameInfo.handler;
1780b57cec5SDimitry Andric if (handler == NULL) {
1790b57cec5SDimitry Andric return _URC_END_OF_STACK;
1800b57cec5SDimitry Andric }
1810b57cec5SDimitry Andric if (handler(_US_VIRTUAL_UNWIND_FRAME | _US_FORCE_UNWIND, &ex, context) !=
1820b57cec5SDimitry Andric _URC_CONTINUE_UNWIND) {
1830b57cec5SDimitry Andric return _URC_END_OF_STACK;
1840b57cec5SDimitry Andric }
1850b57cec5SDimitry Andric #endif // defined(_LIBUNWIND_ARM_EHABI)
1860b57cec5SDimitry Andric
1870b57cec5SDimitry Andric // debugging
1880b57cec5SDimitry Andric if (_LIBUNWIND_TRACING_UNWINDING) {
1890b57cec5SDimitry Andric char functionName[512];
1900b57cec5SDimitry Andric unw_proc_info_t frame;
1910b57cec5SDimitry Andric unw_word_t offset;
1920b57cec5SDimitry Andric __unw_get_proc_name(&cursor, functionName, 512, &offset);
1930b57cec5SDimitry Andric __unw_get_proc_info(&cursor, &frame);
1940b57cec5SDimitry Andric _LIBUNWIND_TRACE_UNWINDING(
1950b57cec5SDimitry Andric " _backtrace: start_ip=0x%" PRIxPTR ", func=%s, lsda=0x%" PRIxPTR ", context=%p",
1960b57cec5SDimitry Andric frame.start_ip, functionName, frame.lsda,
1970b57cec5SDimitry Andric (void *)&cursor);
1980b57cec5SDimitry Andric }
1990b57cec5SDimitry Andric
2000b57cec5SDimitry Andric // call trace function with this frame
2010b57cec5SDimitry Andric result = (*callback)((struct _Unwind_Context *)(&cursor), ref);
2020b57cec5SDimitry Andric if (result != _URC_NO_REASON) {
2030b57cec5SDimitry Andric _LIBUNWIND_TRACE_UNWINDING(
2040b57cec5SDimitry Andric " _backtrace: ended because callback returned %d", result);
2050b57cec5SDimitry Andric return result;
2060b57cec5SDimitry Andric }
2070b57cec5SDimitry Andric }
2080b57cec5SDimitry Andric }
209e8141ad1SDimitry Andric #ifdef __arm__
210e8141ad1SDimitry Andric /* Preserve legacy libgcc (pre r318024) ARM ABI mistake */
211e8141ad1SDimitry Andric __sym_compat(_Unwind_Backtrace, _Unwind_Backtrace, GCC_3.3);
212e8141ad1SDimitry Andric #endif
2130b57cec5SDimitry Andric
2140b57cec5SDimitry Andric
2150b57cec5SDimitry Andric /// Find DWARF unwind info for an address 'pc' in some function.
_Unwind_Find_FDE(const void * pc,struct dwarf_eh_bases * bases)2160b57cec5SDimitry Andric _LIBUNWIND_EXPORT const void *_Unwind_Find_FDE(const void *pc,
2170b57cec5SDimitry Andric struct dwarf_eh_bases *bases) {
2180b57cec5SDimitry Andric // This is slow, but works.
2190b57cec5SDimitry Andric // We create an unwind cursor then alter the IP to be pc
2200b57cec5SDimitry Andric unw_cursor_t cursor;
2210b57cec5SDimitry Andric unw_context_t uc;
2220b57cec5SDimitry Andric unw_proc_info_t info;
2230b57cec5SDimitry Andric __unw_getcontext(&uc);
2240b57cec5SDimitry Andric __unw_init_local(&cursor, &uc);
2250b57cec5SDimitry Andric __unw_set_reg(&cursor, UNW_REG_IP, (unw_word_t)(intptr_t)pc);
2260b57cec5SDimitry Andric __unw_get_proc_info(&cursor, &info);
2270b57cec5SDimitry Andric bases->tbase = (uintptr_t)info.extra;
2280b57cec5SDimitry Andric bases->dbase = 0; // dbase not used on Mac OS X
2290b57cec5SDimitry Andric bases->func = (uintptr_t)info.start_ip;
2300b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("_Unwind_Find_FDE(pc=%p) => %p", pc,
2310b57cec5SDimitry Andric (void *)(intptr_t) info.unwind_info);
2320b57cec5SDimitry Andric return (void *)(intptr_t) info.unwind_info;
2330b57cec5SDimitry Andric }
2340b57cec5SDimitry Andric
2350b57cec5SDimitry Andric /// Returns the CFA (call frame area, or stack pointer at start of function)
2360b57cec5SDimitry Andric /// for the current context.
_Unwind_GetCFA(struct _Unwind_Context * context)2370b57cec5SDimitry Andric _LIBUNWIND_EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context *context) {
2380b57cec5SDimitry Andric unw_cursor_t *cursor = (unw_cursor_t *)context;
2390b57cec5SDimitry Andric unw_word_t result;
2400b57cec5SDimitry Andric __unw_get_reg(cursor, UNW_REG_SP, &result);
2410b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("_Unwind_GetCFA(context=%p) => 0x%" PRIxPTR,
2420b57cec5SDimitry Andric (void *)context, result);
2430b57cec5SDimitry Andric return (uintptr_t)result;
2440b57cec5SDimitry Andric }
2450b57cec5SDimitry Andric
2460b57cec5SDimitry Andric
2470b57cec5SDimitry Andric /// Called by personality handler during phase 2 to get instruction pointer.
2480b57cec5SDimitry Andric /// ipBefore is a boolean that says if IP is already adjusted to be the call
2490b57cec5SDimitry Andric /// site address. Normally IP is the return address.
_Unwind_GetIPInfo(struct _Unwind_Context * context,int * ipBefore)2500b57cec5SDimitry Andric _LIBUNWIND_EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context *context,
2510b57cec5SDimitry Andric int *ipBefore) {
2520b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("_Unwind_GetIPInfo(context=%p)", (void *)context);
253480093f4SDimitry Andric int isSignalFrame = __unw_is_signal_frame((unw_cursor_t *)context);
254480093f4SDimitry Andric // Negative means some kind of error (probably UNW_ENOINFO), but we have no
255480093f4SDimitry Andric // good way to report that, and this maintains backward compatibility with the
256480093f4SDimitry Andric // implementation that hard-coded zero in every case, even signal frames.
257480093f4SDimitry Andric if (isSignalFrame <= 0)
2580b57cec5SDimitry Andric *ipBefore = 0;
259480093f4SDimitry Andric else
260480093f4SDimitry Andric *ipBefore = 1;
2610b57cec5SDimitry Andric return _Unwind_GetIP(context);
2620b57cec5SDimitry Andric }
2630b57cec5SDimitry Andric
2640b57cec5SDimitry Andric #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
2650b57cec5SDimitry Andric
2669f287522SDimitry Andric #if defined(__FreeBSD__)
2679f287522SDimitry Andric
2689f287522SDimitry Andric // Based on LLVM's lib/ExecutionEngine/RuntimeDyld/RTDyldMemoryManager.cpp
2699f287522SDimitry Andric // and XXX should be fixed to be alignment-safe.
processFDE(const char * addr,bool isDeregister)2709f287522SDimitry Andric static void processFDE(const char *addr, bool isDeregister) {
2719f287522SDimitry Andric uint64_t length;
2729f287522SDimitry Andric while ((length = *((const uint32_t *)addr)) != 0) {
2739f287522SDimitry Andric const char *p = addr + 4;
2749f287522SDimitry Andric if (length == 0xffffffff) {
2759f287522SDimitry Andric length = *((const uint64_t *)p);
2769f287522SDimitry Andric p += 8;
2779f287522SDimitry Andric }
2789f287522SDimitry Andric uint32_t offset = *((const uint32_t *)p);
2799f287522SDimitry Andric if (offset != 0) {
2809f287522SDimitry Andric if (isDeregister)
2819f287522SDimitry Andric __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)addr);
2829f287522SDimitry Andric else
2839f287522SDimitry Andric __unw_add_dynamic_fde((unw_word_t)(uintptr_t)addr);
2849f287522SDimitry Andric }
2859f287522SDimitry Andric addr = p + length;
2869f287522SDimitry Andric }
2879f287522SDimitry Andric }
2889f287522SDimitry Andric
2899f287522SDimitry Andric /// Called by programs with dynamic code generators that want to register
2909f287522SDimitry Andric /// dynamically generated FDEs, with a libgcc-compatible API.
2919f287522SDimitry Andric
__register_frame(const void * addr)2929f287522SDimitry Andric _LIBUNWIND_EXPORT void __register_frame(const void *addr) {
2939f287522SDimitry Andric _LIBUNWIND_TRACE_API("__register_frame(%p)", addr);
2949f287522SDimitry Andric processFDE(addr, false);
2959f287522SDimitry Andric }
2969f287522SDimitry Andric
2979f287522SDimitry Andric /// Called by programs with dynamic code generators that want to unregister
2989f287522SDimitry Andric /// dynamically generated FDEs, with a libgcc-compatible API.
__deregister_frame(const void * addr)2999f287522SDimitry Andric _LIBUNWIND_EXPORT void __deregister_frame(const void *addr) {
3009f287522SDimitry Andric _LIBUNWIND_TRACE_API("__deregister_frame(%p)", addr);
3019f287522SDimitry Andric processFDE(addr, true);
3029f287522SDimitry Andric }
3039f287522SDimitry Andric
3049f287522SDimitry Andric #else // defined(__FreeBSD__)
3059f287522SDimitry Andric
3060b57cec5SDimitry Andric /// Called by programs with dynamic code generators that want
3070b57cec5SDimitry Andric /// to register a dynamically generated FDE.
3080b57cec5SDimitry Andric /// This function has existed on Mac OS X since 10.4, but
3090b57cec5SDimitry Andric /// was broken until 10.6.
__register_frame(const void * fde)3100b57cec5SDimitry Andric _LIBUNWIND_EXPORT void __register_frame(const void *fde) {
3110b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__register_frame(%p)", fde);
3120b57cec5SDimitry Andric __unw_add_dynamic_fde((unw_word_t)(uintptr_t)fde);
3130b57cec5SDimitry Andric }
3140b57cec5SDimitry Andric
31506c3fb27SDimitry Andric
3160b57cec5SDimitry Andric /// Called by programs with dynamic code generators that want
3170b57cec5SDimitry Andric /// to unregister a dynamically generated FDE.
3180b57cec5SDimitry Andric /// This function has existed on Mac OS X since 10.4, but
3190b57cec5SDimitry Andric /// was broken until 10.6.
__deregister_frame(const void * fde)3200b57cec5SDimitry Andric _LIBUNWIND_EXPORT void __deregister_frame(const void *fde) {
3210b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__deregister_frame(%p)", fde);
3220b57cec5SDimitry Andric __unw_remove_dynamic_fde((unw_word_t)(uintptr_t)fde);
3230b57cec5SDimitry Andric }
3240b57cec5SDimitry Andric
3259f287522SDimitry Andric #endif // defined(__FreeBSD__)
3260b57cec5SDimitry Andric
3270b57cec5SDimitry Andric // The following register/deregister functions are gcc extensions.
3280b57cec5SDimitry Andric // They have existed on Mac OS X, but have never worked because Mac OS X
3290b57cec5SDimitry Andric // before 10.6 used keymgr to track known FDEs, but these functions
3300b57cec5SDimitry Andric // never got updated to use keymgr.
3310b57cec5SDimitry Andric // For now, we implement these as do-nothing functions to keep any existing
3320b57cec5SDimitry Andric // applications working. We also add the not in 10.6 symbol so that nwe
3330b57cec5SDimitry Andric // application won't be able to use them.
3340b57cec5SDimitry Andric
3350b57cec5SDimitry Andric #if defined(_LIBUNWIND_SUPPORT_FRAME_APIS)
__register_frame_info_bases(const void * fde,void * ob,void * tb,void * db)3360b57cec5SDimitry Andric _LIBUNWIND_EXPORT void __register_frame_info_bases(const void *fde, void *ob,
3370b57cec5SDimitry Andric void *tb, void *db) {
3380b57cec5SDimitry Andric (void)fde;
3390b57cec5SDimitry Andric (void)ob;
3400b57cec5SDimitry Andric (void)tb;
3410b57cec5SDimitry Andric (void)db;
3420b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__register_frame_info_bases(%p,%p, %p, %p)",
3430b57cec5SDimitry Andric fde, ob, tb, db);
3440b57cec5SDimitry Andric // do nothing, this function never worked in Mac OS X
3450b57cec5SDimitry Andric }
3460b57cec5SDimitry Andric
__register_frame_info(const void * fde,void * ob)3470b57cec5SDimitry Andric _LIBUNWIND_EXPORT void __register_frame_info(const void *fde, void *ob) {
3480b57cec5SDimitry Andric (void)fde;
3490b57cec5SDimitry Andric (void)ob;
3500b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__register_frame_info(%p, %p)", fde, ob);
3510b57cec5SDimitry Andric // do nothing, this function never worked in Mac OS X
3520b57cec5SDimitry Andric }
3530b57cec5SDimitry Andric
__register_frame_info_table_bases(const void * fde,void * ob,void * tb,void * db)3540b57cec5SDimitry Andric _LIBUNWIND_EXPORT void __register_frame_info_table_bases(const void *fde,
3550b57cec5SDimitry Andric void *ob, void *tb,
3560b57cec5SDimitry Andric void *db) {
3570b57cec5SDimitry Andric (void)fde;
3580b57cec5SDimitry Andric (void)ob;
3590b57cec5SDimitry Andric (void)tb;
3600b57cec5SDimitry Andric (void)db;
3610b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__register_frame_info_table_bases"
3620b57cec5SDimitry Andric "(%p,%p, %p, %p)", fde, ob, tb, db);
3630b57cec5SDimitry Andric // do nothing, this function never worked in Mac OS X
3640b57cec5SDimitry Andric }
3650b57cec5SDimitry Andric
__register_frame_info_table(const void * fde,void * ob)3660b57cec5SDimitry Andric _LIBUNWIND_EXPORT void __register_frame_info_table(const void *fde, void *ob) {
3670b57cec5SDimitry Andric (void)fde;
3680b57cec5SDimitry Andric (void)ob;
3690b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__register_frame_info_table(%p, %p)", fde, ob);
3700b57cec5SDimitry Andric // do nothing, this function never worked in Mac OS X
3710b57cec5SDimitry Andric }
3720b57cec5SDimitry Andric
__register_frame_table(const void * fde)3730b57cec5SDimitry Andric _LIBUNWIND_EXPORT void __register_frame_table(const void *fde) {
3740b57cec5SDimitry Andric (void)fde;
3750b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__register_frame_table(%p)", fde);
3760b57cec5SDimitry Andric // do nothing, this function never worked in Mac OS X
3770b57cec5SDimitry Andric }
3780b57cec5SDimitry Andric
__deregister_frame_info(const void * fde)3790b57cec5SDimitry Andric _LIBUNWIND_EXPORT void *__deregister_frame_info(const void *fde) {
3800b57cec5SDimitry Andric (void)fde;
3810b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__deregister_frame_info(%p)", fde);
3820b57cec5SDimitry Andric // do nothing, this function never worked in Mac OS X
3830b57cec5SDimitry Andric return NULL;
3840b57cec5SDimitry Andric }
3850b57cec5SDimitry Andric
__deregister_frame_info_bases(const void * fde)3860b57cec5SDimitry Andric _LIBUNWIND_EXPORT void *__deregister_frame_info_bases(const void *fde) {
3870b57cec5SDimitry Andric (void)fde;
3880b57cec5SDimitry Andric _LIBUNWIND_TRACE_API("__deregister_frame_info_bases(%p)", fde);
3890b57cec5SDimitry Andric // do nothing, this function never worked in Mac OS X
3900b57cec5SDimitry Andric return NULL;
3910b57cec5SDimitry Andric }
3920b57cec5SDimitry Andric #endif // defined(_LIBUNWIND_SUPPORT_FRAME_APIS)
3930b57cec5SDimitry Andric
3940b57cec5SDimitry Andric #endif // defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
3950b57cec5SDimitry Andric
3960b57cec5SDimitry Andric #endif // defined(_LIBUNWIND_BUILD_ZERO_COST_APIS)
397