Index: include/__cxxabi_config.h =================================================================== --- /dev/null +++ include/__cxxabi_config.h @@ -0,0 +1,20 @@ +//===-------------------------- __cxxabi_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 ____CXXABI_CONFIG_H +#define ____CXXABI_CONFIG_H + +#if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__arm__) && \ + !defined(__ARM_DWARF_EH__) && !defined(__APPLE__) +#define LIBCXXABI_ARM_EHABI 1 +#else +#define LIBCXXABI_ARM_EHABI 0 +#endif + +#endif // ____CXXABI_CONFIG_H Index: include/cxxabi.h =================================================================== --- include/cxxabi.h +++ include/cxxabi.h @@ -18,17 +18,11 @@ #include #include +#include <__cxxabi_config.h> + #define _LIBCPPABI_VERSION 1001 #define LIBCXXABI_NORETURN __attribute__((noreturn)) -// FIXME: This is also in unwind.h and libunwind.h, can we consolidate? -#if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__arm__) && \ - !defined(__ARM_DWARF_EH__) && !defined(__APPLE__) -#define LIBCXXABI_ARM_EHABI 1 -#else -#define LIBCXXABI_ARM_EHABI 0 -#endif - #ifdef __cplusplus namespace std { Index: include/libunwind.h =================================================================== --- include/libunwind.h +++ include/libunwind.h @@ -17,13 +17,7 @@ #include #include -// FIXME: This is also in unwind.h and cxxabi.h, can we consolidate? -#if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__arm__) && \ - !defined(__ARM_DWARF_EH__) && !defined(__APPLE__) -#define LIBCXXABI_ARM_EHABI 1 -#else -#define LIBCXXABI_ARM_EHABI 0 -#endif +#include <__cxxabi_config.h> #ifdef __APPLE__ #include Index: include/unwind.h =================================================================== --- include/unwind.h +++ include/unwind.h @@ -23,13 +23,7 @@ #define LIBUNWIND_UNAVAIL #endif -// FIXME: This is also in cxxabi.h and libunwind.h, can we consolidate? -#if !defined(__USING_SJLJ_EXCEPTIONS__) && defined(__arm__) && \ - !defined(__ARM_DWARF_EH__) && !defined(__APPLE__) -#define LIBCXXABI_ARM_EHABI 1 -#else -#define LIBCXXABI_ARM_EHABI 0 -#endif +#include <__cxxabi_config.h> typedef enum { _URC_NO_REASON = 0, @@ -208,9 +202,7 @@ _Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass, uint32_t discriminator, _Unwind_VRS_DataRepresentation representation); -#endif -#if LIBCXXABI_ARM_EHABI static inline uintptr_t _Unwind_GetGR(struct _Unwind_Context* context, int index) { uintptr_t value = 0; Index: src/Unwind/Unwind-EHABI.h =================================================================== --- src/Unwind/Unwind-EHABI.h +++ src/Unwind/Unwind-EHABI.h @@ -11,6 +11,10 @@ #ifndef __UNWIND_EHABI_H__ #define __UNWIND_EHABI_H__ +#include <__cxxabi_config.h> + +#if LIBCXXABI_ARM_EHABI + #include #include @@ -42,4 +46,6 @@ } // extern "C" #endif +#endif // LIBCXXABI_ARM_EHABI + #endif // __UNWIND_EHABI_H__ Index: src/Unwind/Unwind-EHABI.cpp =================================================================== --- src/Unwind/Unwind-EHABI.cpp +++ src/Unwind/Unwind-EHABI.cpp @@ -12,7 +12,7 @@ #include "Unwind-EHABI.h" -#include +#if LIBCXXABI_ARM_EHABI #include #include @@ -26,7 +26,6 @@ #include "unwind.h" #include "../private_typeinfo.h" -#if LIBCXXABI_ARM_EHABI namespace { // Strange order: take words in order, but inside word, take from most to least @@ -47,23 +46,23 @@ } struct Descriptor { - // See # 9.2 - typedef enum { - SU16 = 0, // Short descriptor, 16-bit entries - LU16 = 1, // Long descriptor, 16-bit entries - LU32 = 3, // Long descriptor, 32-bit entries - RESERVED0 = 4, RESERVED1 = 5, RESERVED2 = 6, RESERVED3 = 7, - RESERVED4 = 8, RESERVED5 = 9, RESERVED6 = 10, RESERVED7 = 11, - RESERVED8 = 12, RESERVED9 = 13, RESERVED10 = 14, RESERVED11 = 15 - } Format; - - // See # 9.2 - typedef enum { - CLEANUP = 0x0, - FUNC = 0x1, - CATCH = 0x2, - INVALID = 0x4 - } Kind; + // See # 9.2 + typedef enum { + SU16 = 0, // Short descriptor, 16-bit entries + LU16 = 1, // Long descriptor, 16-bit entries + LU32 = 3, // Long descriptor, 32-bit entries + RESERVED0 = 4, RESERVED1 = 5, RESERVED2 = 6, RESERVED3 = 7, + RESERVED4 = 8, RESERVED5 = 9, RESERVED6 = 10, RESERVED7 = 11, + RESERVED8 = 12, RESERVED9 = 13, RESERVED10 = 14, RESERVED11 = 15 + } Format; + + // See # 9.2 + typedef enum { + CLEANUP = 0x0, + FUNC = 0x1, + CATCH = 0x2, + INVALID = 0x4 + } Kind; }; _Unwind_Reason_Code ProcessDescriptors( @@ -133,7 +132,7 @@ landing_pad = signExtendPrel31(landing_pad & ~0x80000000); if (landing_pad == 0xffffffff) { return _URC_HANDLER_FOUND; - } else if (landing_pad == 0xfffffffe ) { + } else if (landing_pad == 0xfffffffe) { return _URC_FAILURE; } else { /* @@ -152,7 +151,7 @@ } default: _LIBUNWIND_ABORT("Invalid descriptor kind found."); - }; + } getNextWord(descriptor, &descriptorWord); } @@ -948,7 +947,7 @@ return _Unwind_VRS_Set(context, _UVRSC_CORE, UNW_ARM_SP, _UVRSD_UINT32, &sp); } - }; + } } /// Called by personality handler during phase 2 to find the start of the @@ -961,7 +960,7 @@ if (unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS) result = (uintptr_t)frameInfo.start_ip; _LIBUNWIND_TRACE_API("_Unwind_GetRegionStart(context=%p) => 0x%llX\n", - context, (long long)result); + context, (long long)result); return result; } @@ -971,7 +970,7 @@ _LIBUNWIND_EXPORT void _Unwind_DeleteException(_Unwind_Exception *exception_object) { _LIBUNWIND_TRACE_API("_Unwind_DeleteException(ex_obj=%p)\n", - exception_object); + exception_object); if (exception_object->exception_cleanup != NULL) (*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT, exception_object); Index: src/Unwind/UnwindCursor.hpp =================================================================== --- src/Unwind/UnwindCursor.hpp +++ src/Unwind/UnwindCursor.hpp @@ -23,17 +23,15 @@ #include #endif -#include "libunwind.h" +#include "config.h" #include "AddressSpace.hpp" -#include "Registers.hpp" -#include "DwarfInstructions.hpp" #include "CompactUnwinder.hpp" #include "config.h" - -#if LIBCXXABI_ARM_EHABI +#include "DwarfInstructions.hpp" +#include "libunwind.h" +#include "Registers.hpp" #include "Unwind-EHABI.h" -#endif namespace libunwind { Index: src/Unwind/UnwindLevel1-gcc-ext.c =================================================================== --- src/Unwind/UnwindLevel1-gcc-ext.c +++ src/Unwind/UnwindLevel1-gcc-ext.c @@ -16,14 +16,11 @@ #include #include -#include "libunwind.h" -#include "unwind.h" -#include "libunwind_ext.h" #include "config.h" - -#if LIBCXXABI_ARM_EHABI +#include "libunwind_ext.h" +#include "libunwind.h" #include "Unwind-EHABI.h" -#endif +#include "unwind.h" #if _LIBUNWIND_BUILD_ZERO_COST_APIS Index: src/cxa_exception.hpp =================================================================== --- src/cxa_exception.hpp +++ src/cxa_exception.hpp @@ -24,9 +24,9 @@ static const uint64_t kOurExceptionClass = 0x434C4E47432B2B00; // CLNGC++\0 static const uint64_t kOurDependentExceptionClass = 0x434C4E47432B2B01; // CLNGC++\1 -static const uint64_t get_vendor_and_language = 0xFFFFFFFFFFFFFF00; // mask for CLNGC++ - -struct __cxa_exception { +static const uint64_t get_vendor_and_language = 0xFFFFFFFFFFFFFF00; // mask for CLNGC++ + +struct __cxa_exception { #if defined(__LP64__) || LIBCXXABI_ARM_EHABI // This is a new field to support C++ 0x exception_ptr. // For binary compatibility it is at the start of this @@ -34,10 +34,10 @@ // __cxa_allocate_exception. size_t referenceCount; #endif - + // Manage the exception object itself. std::type_info *exceptionType; - void (*exceptionDestructor)(void *); + void (*exceptionDestructor)(void *); std::unexpected_handler unexpectedHandler; std::terminate_handler terminateHandler; @@ -73,16 +73,16 @@ #if defined(__LP64__) || LIBCXXABI_ARM_EHABI void* primaryException; #endif - + std::type_info *exceptionType; - void (*exceptionDestructor)(void *); + void (*exceptionDestructor)(void *); std::unexpected_handler unexpectedHandler; std::terminate_handler terminateHandler; __cxa_exception *nextException; int handlerCount; - + #if LIBCXXABI_ARM_EHABI __cxa_exception* nextPropagatingException; int propagationCount; @@ -93,7 +93,7 @@ void * catchTemp; void *adjustedPtr; #endif - + #if !defined(__LP64__) && !LIBCXXABI_ARM_EHABI void* primaryException; #endif Index: src/cxa_exception.cpp =================================================================== --- src/cxa_exception.cpp +++ src/cxa_exception.cpp @@ -258,12 +258,10 @@ { #if LIBCXXABI_ARM_EHABI return reinterpret_cast( - static_cast<_Unwind_Control_Block*>(unwind_exception)->barrier_cache.bitpattern[0]); + static_cast<_Unwind_Control_Block*>(unwind_exception)->barrier_cache.bitpattern[0]); #else - return cxa_exception_from_exception_unwind_exception - ( - static_cast<_Unwind_Exception*>(unwind_exception) - )->adjustedPtr; + return cxa_exception_from_exception_unwind_exception( + static_cast<_Unwind_Exception*>(unwind_exception))->adjustedPtr; #endif }