Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -469,10 +469,12 @@ AC_MSG_RESULT($exception_type) ], [ AC_MSG_RESULT(exceptions unavailable!) AC_MSG_ERROR([Exceptions not accepted by compiler!]) ]) + + AC_CHECK_FUNCS(_Unwind_GetDataRelBase _Unwind_GetTextRelBase) ;; "Apple runtime") AC_DEFINE(OF_APPLE_RUNTIME, 1, [Whether we use the Apple ObjC runtime]) @@ -482,10 +484,12 @@ ], [ AC_MSG_ERROR([libobjc not found!]) ]) ;; esac + +AC_CHECK_FUNCS(_Unwind_Backtrace) AC_CHECK_FUNC(objc_constructInstance, [], [ AC_SUBST(INSTANCE_M, "instance.m") ]) Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -41,33 +41,14 @@ #if defined(OF_WINDOWS) && defined(OF_HAVE_SOCKETS) # include #endif -/* - * Define HAVE_DWARF_EXCEPTIONS if OBJC_ZEROCOST_EXCEPTIONS is defined, but - * don't do so on iOS, as it is defined there even if SjLj exceptions are used. - */ -#ifndef HAVE_DWARF_EXCEPTIONS -# if defined(OBJC_ZEROCOST_EXCEPTIONS) && !defined(OF_IOS) -# define HAVE_DWARF_EXCEPTIONS -# endif -#endif - -/* - * Define HAVE_DWARF_EXCEPTIONS if HAVE_SEH_EXCEPTIONS is defined, as SEH - * exceptions are implemented as a wrapper around DWARF exceptions. - */ -#ifdef HAVE_SEH_EXCEPTIONS -# define HAVE_DWARF_EXCEPTIONS -#endif - #if defined(OF_ARM) && !defined(__ARM_DWARF_EH__) # define HAVE_ARM_EHABI_EXCEPTIONS #endif -#ifdef HAVE_DWARF_EXCEPTIONS struct _Unwind_Context; typedef enum { _URC_OK = 0, _URC_END_OF_STACK = 5 }_Unwind_Reason_Code; @@ -75,18 +56,19 @@ struct backtrace_ctx { void **backtrace; uint8_t i; }; +#ifdef HAVE__UNWIND_BACKTRACE extern _Unwind_Reason_Code _Unwind_Backtrace( _Unwind_Reason_Code (*)(struct _Unwind_Context *, void *), void *); -# ifndef HAVE_ARM_EHABI_EXCEPTIONS +#endif +#ifndef HAVE_ARM_EHABI_EXCEPTIONS extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *); -# else +#else extern int _Unwind_VRS_Get(struct _Unwind_Context *, int, uint32_t, int, void *); -# endif #endif #if !defined(HAVE_STRERROR_R) && defined(OF_HAVE_THREADS) static of_mutex_t mutex; @@ -223,11 +205,11 @@ #endif return ret; } -#ifdef HAVE_DWARF_EXCEPTIONS +#ifdef HAVE__UNWIND_BACKTRACE static _Unwind_Reason_Code backtrace_callback(struct _Unwind_Context *ctx, void *data) { struct backtrace_ctx *bt = data; @@ -251,11 +233,11 @@ + (instancetype)exception { return [[[self alloc] init] autorelease]; } -#ifdef HAVE_DWARF_EXCEPTIONS +#ifdef HAVE__UNWIND_BACKTRACE - (instancetype)init { struct backtrace_ctx ctx; self = [super init]; @@ -274,11 +256,11 @@ @"An exception of type %@ occurred!", [self class]]; } - (OFArray OF_GENERIC(OFString *) *)backtrace { -#ifdef HAVE_DWARF_EXCEPTIONS +#ifdef HAVE__UNWIND_BACKTRACE OFMutableArray OF_GENERIC(OFString *) *backtrace = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (uint8_t i = 0; Index: src/runtime/exception.m ================================================================== --- src/runtime/exception.m +++ src/runtime/exception.m @@ -169,21 +169,22 @@ extern _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *); extern void _Unwind_DeleteException(struct _Unwind_Exception *); extern void *_Unwind_GetLanguageSpecificData(struct _Unwind_Context *); extern uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context *); -#ifndef OF_ITANIUM +#ifdef HAVE__UNWIND_GETDATARELBASE extern uintptr_t _Unwind_GetDataRelBase(struct _Unwind_Context *); +#endif +#ifdef HAVE__UNWIND_GETTEXTRELBASE extern uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context *); -#else -extern uintptr_t _Unwind_GetGR(struct _Unwind_Context *, int); #endif #ifndef HAVE_ARM_EHABI_EXCEPTIONS # define CONTINUE_UNWIND return _URC_CONTINUE_UNWIND extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *); +extern uintptr_t _Unwind_GetGR(struct _Unwind_Context *, int); extern void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t); extern void _Unwind_SetGR(struct _Unwind_Context *, int, uintptr_t); #else extern _Unwind_Reason_Code __gnu_unwind_frame(struct _Unwind_Exception *, struct _Unwind_Context *); @@ -292,19 +293,21 @@ case DW_EH_PE_pcrel: case DW_EH_PE_aligned: return 0; case DW_EH_PE_funcrel: return _Unwind_GetRegionStart(ctx); -#ifndef OF_ITANIUM +#ifdef HAVE__UNWIND_GETDATARELBASE case DW_EH_PE_datarel: return _Unwind_GetDataRelBase(ctx); - case DW_EH_PE_textrel: - return _Unwind_GetTextRelBase(ctx); #else case DW_EH_PE_datarel: return _Unwind_GetGR(ctx, 1); #endif +#ifdef HAVE__UNWIND_GETTEXTRELBASE + case DW_EH_PE_textrel: + return _Unwind_GetTextRelBase(ctx); +#endif } OBJC_ERROR("Unknown encoding!") }