libunwind: Introduce __libunwind_config.h.

Introduce __libunwind_config.h to avoid cross repository circular
dependency with libcxxabi.

llvm-svn: 242642
This commit is contained in:
Logan Chien 2015-07-19 15:23:10 +00:00
parent 611f614ee1
commit 5191fe9509
11 changed files with 55 additions and 35 deletions

View File

@ -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__

View File

@ -14,11 +14,11 @@
#ifndef __LIBUNWIND__
#define __LIBUNWIND__
#include <__libunwind_config.h>
#include <stdint.h>
#include <stddef.h>
#include <__cxxabi_config.h>
#ifdef __APPLE__
#include <Availability.h>
#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

View File

@ -14,6 +14,8 @@
#ifndef __UNWIND_H__
#define __UNWIND_H__
#include <__libunwind_config.h>
#include <stdint.h>
#include <stddef.h>
@ -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 */

View File

@ -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);

View File

@ -12,7 +12,7 @@
#include "Unwind-EHABI.h"
#if LIBCXXABI_ARM_EHABI
#if _LIBUNWIND_ARM_EHABI
#include <stdbool.h>
#include <stdint.h>
@ -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

View File

@ -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 <stdint.h>
#include <unwind.h>
@ -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__

View File

@ -438,7 +438,7 @@ public:
private:
#if LIBCXXABI_ARM_EHABI
#if _LIBUNWIND_ARM_EHABI
bool getInfoFromEHABISection(pint_t pc, const UnwindInfoSections &sects);
int stepWithEHABI() {
@ -634,7 +634,7 @@ template <typename A, typename R> bool UnwindCursor<A, R>::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<A, R>::getInfoFromCompactEncodingSection(pint_t pc,
template <typename A, typename R>
void UnwindCursor<A, R>::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<A, R>::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<A, R>::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

View File

@ -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) {

View File

@ -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

View File

@ -61,7 +61,7 @@ _LIBUNWIND_EXPORT int unw_init_local(unw_cursor_t *cursor,
#elif defined(__arm64__)
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm64>(
context, LocalAddressSpace::sThisAddressSpace);
#elif LIBCXXABI_ARM_EHABI
#elif _LIBUNWIND_ARM_EHABI
new ((void *)cursor) UnwindCursor<LocalAddressSpace, Registers_arm>(
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<void *>(cursor), regNum, value);
#else

View File

@ -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,