From 61278584b5c84c422ff5da10f46c3235c54636c9 Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Sun, 19 Jul 2015 15:23:10 +0000 Subject: libunwind: Introduce __libunwind_config.h. Introduce __libunwind_config.h to avoid cross repository circular dependency with libcxxabi. git-svn-id: https://llvm.org/svn/llvm-project/libunwind/trunk@242642 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__libunwind_config.h | 20 ++++++++++++++++++++ include/libunwind.h | 6 +++--- include/unwind.h | 10 +++++----- src/AddressSpace.hpp | 8 ++++---- src/Unwind-EHABI.cpp | 8 ++++---- src/Unwind-EHABI.h | 6 +++--- src/UnwindCursor.hpp | 12 ++++++------ src/UnwindLevel1-gcc-ext.c | 10 +++++----- src/UnwindLevel1.c | 4 ++-- src/libunwind.cpp | 4 ++-- src/libunwind_ext.h | 2 +- 11 files changed, 55 insertions(+), 35 deletions(-) create mode 100644 include/__libunwind_config.h diff --git a/include/__libunwind_config.h b/include/__libunwind_config.h new file mode 100644 index 0000000..63393d3 --- /dev/null +++ b/include/__libunwind_config.h @@ -0,0 +1,20 @@ +//===------------------------- __libunwind_config.h -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef ____LIBUNWIND_CONFIG_H__ +#define ____LIBUNWIND_CONFIG_H__ + +#if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \ + !defined(__ARM_DWARF_EH__) +#define _LIBUNWIND_ARM_EHABI 1 +#else +#define _LIBUNWIND_ARM_EHABI 0 +#endif + +#endif // ____LIBUNWIND_CONFIG_H__ diff --git a/include/libunwind.h b/include/libunwind.h index e2396e4..4a75a7b 100644 --- a/include/libunwind.h +++ b/include/libunwind.h @@ -14,11 +14,11 @@ #ifndef __LIBUNWIND__ #define __LIBUNWIND__ +#include <__libunwind_config.h> + #include #include -#include <__cxxabi_config.h> - #ifdef __APPLE__ #include #ifdef __arm__ @@ -58,7 +58,7 @@ typedef struct unw_cursor_t unw_cursor_t; typedef struct unw_addr_space *unw_addr_space_t; typedef int unw_regnum_t; -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI typedef uint32_t unw_word_t; typedef uint64_t unw_fpreg_t; #else diff --git a/include/unwind.h b/include/unwind.h index 86001bb..31fb871 100644 --- a/include/unwind.h +++ b/include/unwind.h @@ -14,6 +14,8 @@ #ifndef __UNWIND_H__ #define __UNWIND_H__ +#include <__libunwind_config.h> + #include #include @@ -23,8 +25,6 @@ #define LIBUNWIND_UNAVAIL #endif -#include <__cxxabi_config.h> - typedef enum { _URC_NO_REASON = 0, _URC_OK = 0, @@ -36,7 +36,7 @@ typedef enum { _URC_HANDLER_FOUND = 6, _URC_INSTALL_CONTEXT = 7, _URC_CONTINUE_UNWIND = 8, -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI _URC_FAILURE = 9 #endif } _Unwind_Reason_Code; @@ -51,7 +51,7 @@ typedef enum { typedef struct _Unwind_Context _Unwind_Context; // opaque -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI typedef uint32_t _Unwind_State; static const _Unwind_State _US_VIRTUAL_UNWIND_FRAME = 0; @@ -164,7 +164,7 @@ extern void _Unwind_Resume(_Unwind_Exception *exception_object); #endif extern void _Unwind_DeleteException(_Unwind_Exception *exception_object); -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI typedef enum { _UVRSC_CORE = 0, /* integer register */ _UVRSC_VFP = 1, /* vfp */ diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp index 4d74129..567cbda 100644 --- a/src/AddressSpace.hpp +++ b/src/AddressSpace.hpp @@ -34,7 +34,7 @@ namespace libunwind { #include "dwarf2.h" #include "Registers.hpp" -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI #ifdef __linux__ typedef long unsigned int *_Unwind_Ptr; @@ -55,7 +55,7 @@ struct EHTEntry { extern EHTEntry __exidx_start; extern EHTEntry __exidx_end; #endif // !defined(_LIBUNWIND_IS_BAREMETAL) -#endif // LIBCXXABI_ARM_EHABI +#endif // _LIBUNWIND_ARM_EHABI #if defined(__CloudABI__) || defined(__FreeBSD__) || defined(__linux__) #if _LIBUNWIND_SUPPORT_DWARF_UNWIND && _LIBUNWIND_SUPPORT_DWARF_INDEX @@ -92,7 +92,7 @@ struct UnwindInfoSections { uintptr_t compact_unwind_section; uintptr_t compact_unwind_section_length; #endif -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI uintptr_t arm_section; uintptr_t arm_section_length; #endif @@ -357,7 +357,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr, info.compact_unwind_section_length = dyldInfo.compact_unwind_section_length; return true; } -#elif LIBCXXABI_ARM_EHABI +#elif _LIBUNWIND_ARM_EHABI #ifdef _LIBUNWIND_IS_BAREMETAL // Bare metal is statically linked, so no need to ask the dynamic loader info.arm_section = (uintptr_t)(&__exidx_start); diff --git a/src/Unwind-EHABI.cpp b/src/Unwind-EHABI.cpp index eb641e3..1a8f90d 100644 --- a/src/Unwind-EHABI.cpp +++ b/src/Unwind-EHABI.cpp @@ -12,7 +12,7 @@ #include "Unwind-EHABI.h" -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI #include #include @@ -451,7 +451,7 @@ unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) { // Walk each frame looking for a place to stop. for (bool handlerNotFound = true; handlerNotFound;) { -#if !LIBCXXABI_ARM_EHABI +#if !_LIBUNWIND_ARM_EHABI // Ask libuwind to get next frame (skip over first which is // _Unwind_RaiseException). int stepResult = unw_step(&cursor1); @@ -585,7 +585,7 @@ static _Unwind_Reason_Code unwind_phase2(unw_context_t *uc, resume = false; } -#if !LIBCXXABI_ARM_EHABI +#if !_LIBUNWIND_ARM_EHABI int stepResult = unw_step(&cursor2); if (stepResult == 0) { _LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): unw_step() reached " @@ -1006,4 +1006,4 @@ __gnu_unwind_frame(_Unwind_Exception *exception_object, return _URC_OK; } -#endif // LIBCXXABI_ARM_EHABI +#endif // _LIBUNWIND_ARM_EHABI diff --git a/src/Unwind-EHABI.h b/src/Unwind-EHABI.h index ebd56a1..a7c62df 100644 --- a/src/Unwind-EHABI.h +++ b/src/Unwind-EHABI.h @@ -11,9 +11,9 @@ #ifndef __UNWIND_EHABI_H__ #define __UNWIND_EHABI_H__ -#include <__cxxabi_config.h> +#include <__libunwind_config.h> -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI #include #include @@ -46,6 +46,6 @@ extern _Unwind_Reason_Code __aeabi_unwind_cpp_pr2( } // extern "C" #endif -#endif // LIBCXXABI_ARM_EHABI +#endif // _LIBUNWIND_ARM_EHABI #endif // __UNWIND_EHABI_H__ diff --git a/src/UnwindCursor.hpp b/src/UnwindCursor.hpp index 7703af9..59924f0 100644 --- a/src/UnwindCursor.hpp +++ b/src/UnwindCursor.hpp @@ -438,7 +438,7 @@ public: private: -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI bool getInfoFromEHABISection(pint_t pc, const UnwindInfoSections §s); int stepWithEHABI() { @@ -634,7 +634,7 @@ template bool UnwindCursor::isSignalFrame() { return _isSignalFrame; } -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI struct EHABIIndexEntry { uint32_t functionOffset; uint32_t data; @@ -1163,7 +1163,7 @@ bool UnwindCursor::getInfoFromCompactEncodingSection(pint_t pc, template void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { pint_t pc = (pint_t)this->getReg(UNW_REG_IP); -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI // Remove the thumb bit so the IP represents the actual instruction address. // This matches the behaviour of _Unwind_GetIP on arm. pc &= (pint_t)~0x1; @@ -1213,7 +1213,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) { } #endif -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI // If there is ARM EHABI unwind info, look there next. if (sects.arm_section != 0 && this->getInfoFromEHABISection(pc, sects)) return; @@ -1297,12 +1297,12 @@ int UnwindCursor::step() { result = this->stepWithCompactEncoding(); #elif _LIBUNWIND_SUPPORT_DWARF_UNWIND result = this->stepWithDwarfFDE(); -#elif LIBCXXABI_ARM_EHABI +#elif _LIBUNWIND_ARM_EHABI result = this->stepWithEHABI(); #else #error Need _LIBUNWIND_SUPPORT_COMPACT_UNWIND or \ _LIBUNWIND_SUPPORT_DWARF_UNWIND or \ - LIBCXXABI_ARM_EHABI + _LIBUNWIND_ARM_EHABI #endif // update info based on new PC diff --git a/src/UnwindLevel1-gcc-ext.c b/src/UnwindLevel1-gcc-ext.c index 2a8b24c..28ba092 100644 --- a/src/UnwindLevel1-gcc-ext.c +++ b/src/UnwindLevel1-gcc-ext.c @@ -28,7 +28,7 @@ /// Called by __cxa_rethrow(). _LIBUNWIND_EXPORT _Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) { -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%ld\n", (void *)exception_object, (long)exception_object->unwinder_cache.reserved1); @@ -38,7 +38,7 @@ _Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) { (long)exception_object->private_1); #endif -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI // _Unwind_RaiseException on EHABI will always set the reserved1 field to 0, // which is in the same position as private_1 below. return _Unwind_RaiseException(exception_object); @@ -111,7 +111,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { _LIBUNWIND_TRACE_API("_Unwind_Backtrace(callback=%p)\n", (void *)(uintptr_t)callback); -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI // Create a mock exception object for force unwinding. _Unwind_Exception ex; memset(&ex, '\0', sizeof(ex)); @@ -122,7 +122,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { while (true) { _Unwind_Reason_Code result; -#if !LIBCXXABI_ARM_EHABI +#if !_LIBUNWIND_ARM_EHABI // ask libuwind to get next frame (skip over first frame which is // _Unwind_Backtrace()) if (unw_step(&cursor) <= 0) { @@ -154,7 +154,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { _URC_CONTINUE_UNWIND) { return _URC_END_OF_STACK; } -#endif // LIBCXXABI_ARM_EHABI +#endif // _LIBUNWIND_ARM_EHABI // debugging if (_LIBUNWIND_TRACING_UNWINDING) { diff --git a/src/UnwindLevel1.c b/src/UnwindLevel1.c index 61abd89..caef0cf 100644 --- a/src/UnwindLevel1.c +++ b/src/UnwindLevel1.c @@ -23,7 +23,7 @@ #include "unwind.h" #include "config.h" -#if !LIBCXXABI_ARM_EHABI +#if !_LIBUNWIND_ARM_EHABI static _Unwind_Reason_Code unwind_phase1(unw_context_t *uc, _Unwind_Exception *exception_object) { @@ -530,5 +530,5 @@ _LIBUNWIND_EXPORT void _Unwind_SetIP(struct _Unwind_Context *context, _Unwind_SetGR(context, 15, value | thumb_bit); } -#endif // !LIBCXXABI_ARM_EHABI +#endif // !_LIBUNWIND_ARM_EHABI diff --git a/src/libunwind.cpp b/src/libunwind.cpp index 8f5078b..9a16e48 100644 --- a/src/libunwind.cpp +++ b/src/libunwind.cpp @@ -61,7 +61,7 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor, #elif defined(__arm64__) new ((void *)cursor) UnwindCursor( context, LocalAddressSpace::sThisAddressSpace); -#elif LIBCXXABI_ARM_EHABI +#elif _LIBUNWIND_ARM_EHABI new ((void *)cursor) UnwindCursor( context, LocalAddressSpace::sThisAddressSpace); #endif @@ -205,7 +205,7 @@ _LIBUNWIND_EXPORT int unw_get_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum, /// Set value of specified float register at cursor position in stack frame. _LIBUNWIND_EXPORT int unw_set_fpreg(unw_cursor_t *cursor, unw_regnum_t regNum, unw_fpreg_t value) { -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI _LIBUNWIND_TRACE_API("unw_set_fpreg(cursor=%p, regNum=%d, value=%llX)\n", static_cast(cursor), regNum, value); #else diff --git a/src/libunwind_ext.h b/src/libunwind_ext.h index 5eb0e87..72dbf58 100644 --- a/src/libunwind_ext.h +++ b/src/libunwind_ext.h @@ -33,7 +33,7 @@ extern void unw_iterate_dwarf_unwind_cache(void (*func)(unw_word_t ip_start, extern void _unw_add_dynamic_fde(unw_word_t fde); extern void _unw_remove_dynamic_fde(unw_word_t fde); -#if LIBCXXABI_ARM_EHABI +#if _LIBUNWIND_ARM_EHABI extern const uint32_t* decode_eht_entry(const uint32_t*, size_t*, size_t*); extern _Unwind_Reason_Code _Unwind_VRS_Interpret(_Unwind_Context *context, const uint32_t *data, -- cgit v1.2.3