sl@0: /* unwind_env.h sl@0: * sl@0: * Copyright 2003 ARM Limited. sl@0: */ sl@0: /* sl@0: Licence sl@0: sl@0: 1. Subject to the provisions of clause 2, ARM hereby grants to LICENSEE a sl@0: perpetual, non-exclusive, nontransferable, royalty free, worldwide licence sl@0: to use this Example Implementation of Exception Handling solely for the sl@0: purpose of developing, having developed, manufacturing, having sl@0: manufactured, offering to sell, selling, supplying or otherwise sl@0: distributing products which comply with the Exception Handling ABI for the sl@0: ARM Architecture specification. All other rights are reserved to ARM or its sl@0: licensors. sl@0: sl@0: 2. THIS EXAMPLE IMPLEMENTATION OF EXCEPTION HANDLING IS PROVIDED "AS IS" sl@0: WITH NO WARRANTIES EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED sl@0: TO ANY WARRANTY OF SATISFACTORY QUALITY, MERCHANTABILITY, NONINFRINGEMENT sl@0: OR FITNESS FOR A PARTICULAR PURPOSE. sl@0: */ sl@0: /* sl@0: * RCS $Revision: 1.3 $ sl@0: * Checkin $Date: 2003/10/23 13:57:32 $ sl@0: * Revising $Author: agrant $ sl@0: */ sl@0: sl@0: /* Environment definition - abstractions and requirements - to aid sl@0: * portability of the ARM exceptions code. sl@0: */ sl@0: sl@0: #ifndef UNWINDENV_H sl@0: #define UNWINDENV_H sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: /* Source language sl@0: * sl@0: * The compiler is expected to define preprocessor symbols as follows: sl@0: * __cplusplus when compiling in C++ mode. sl@0: * __thumb when compiling to Thumb code. sl@0: * sl@0: * Some use is made of embedded assembly language, introduced by __asm. sl@0: * This is described in ARM's toolchain documentation. Some edits may be sl@0: * required for other compilers. The compiler should define one or more of: sl@0: * __TARGET_ARCH_4T __TARGET_ARCH_4TXM __TARGET_ARCH_5T __TARGET_ARCH_5TXM sl@0: * __TARGET_ARCH_5TE __TARGET_ARCH_6 sl@0: * so the correct assembly wrappers are generated for certain functions. sl@0: * sl@0: * __APCS_INTERWORK should be defined if ARM/Thumb interworking is required. sl@0: * sl@0: * For all the above symbols, if your compiler does not provide appropriate sl@0: * definitions, add them here. sl@0: * sl@0: * Some source language extensions are also used. sl@0: */ sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: /* Library structure sl@0: * sl@0: * ARM's private make system contains an automated facility for compiling sl@0: * source files multiple times to create multiple object files. The source sl@0: * regions intended to constitute object file xxx.o are delimited by sl@0: * #ifdef xxx_c / #endif directives. The exact preprocessor symbols used sl@0: * for this conditionalisation are described in a comment at the start of sl@0: * each file. When porting to a different system, compilations must be sl@0: * performed with these preprocessor symbols appropriately defined sl@0: * (or remove the conditionalisation). sl@0: * sl@0: * ARM declares (or redeclares) some routines as weak in order that sl@0: * references to them are weak, so that the static linker will not load sl@0: * unwanted code. This is achieved by decorating routine declarations sl@0: * with appropriate language extensions. Note that compilers supporting sl@0: * similar features but via a different syntax may require edits to sl@0: * the library source. sl@0: * sl@0: * Define those decorations here (define as empty if not required): sl@0: */ sl@0: sl@0: #define WEAKDECL __weak /* token in C and C++ */ sl@0: #define WEAKASMDECL [WEAK] /* token in assembler */ sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: /* Source language support and language extensions */ sl@0: sl@0: /* It is possible to compile the C++ semantics code using a compiler sl@0: * which does not support C++ exceptions; this was useful to ARM whilst sl@0: * ARM's compiler was being developed, and the facility has not been sl@0: * removed. C++ exceptions syntax is conditionalised by sl@0: * #ifdef ARM_EXCEPTIONS_ENABLED / #endif. Define ARM_EXCEPTIONS_ENABLED sl@0: * by some means here if you want a usable library: sl@0: */ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: /* For conditionalisation, specifically on ARM_EXCEPTIONS_ENABLED */ sl@0: #include "basics.h" sl@0: } sl@0: #endif sl@0: sl@0: /* The following definitions of syntax decoration may be empty if the sl@0: * facility is not required. Note that compilers supporting similar sl@0: * features but via a different syntax may require edits to the library sl@0: * source. sl@0: * sl@0: * Define the decorations here (define as empty if not required): sl@0: */ sl@0: sl@0: /* If the compiler understands noreturn functions: */ sl@0: #define NORETURNDECL __declspec(noreturn) sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: /* Types */ sl@0: sl@0: /* The implementation requires types uint8_t, uint16_t, uint32_t and sl@0: * uint64_t to be defined as unsigned integers of the appropriate number sl@0: * of bits. sl@0: * sl@0: * Do that here: sl@0: */ sl@0: sl@0: #include sl@0: sl@0: /* The C++ semantics support requires definition of the RTTI object sl@0: * layout. We use the same structures and names as the generic C++ sl@0: * ABI for Itanium. sl@0: * sl@0: * Define those structures here: sl@0: */ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #include "cxxabi.h" sl@0: } sl@0: #endif sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: /* External requirements */ sl@0: sl@0: /* The C++ exception-handling 'globals' should be allocated per-thread. sl@0: * The Exceptions ABI does not specify how this happens, but it is sl@0: * intended that the details are localised to __cxa_get_globals. sl@0: * sl@0: * In the ARM implementation of __cxa_get_globals, it is assumed that a sl@0: * zero-initialised location in a known per-thread place is somehow sl@0: * obtainable, and can be assigned (by __cxa_get_globals) a pointer to sl@0: * the allocated globals data structure. The macro EH_GLOBALS should be sl@0: * defined here to yield a suitable address of type void*. This is used sl@0: * only in __cxa_get_globals. sl@0: * sl@0: * Define it here: sl@0: */ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: /* for __user_libspace() machinery */ sl@0: #include sl@0: #define EH_GLOBALS libspace.eh_globals sl@0: } sl@0: #endif sl@0: sl@0: sl@0: /* A routine is required for C++ derived class to base class conversion. sl@0: * This is used once, in __cxa_type_match. It is likely that suitable sl@0: * code exists as part of the RTTI support code. Therefore access it sl@0: * via a macro: sl@0: * DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO) sl@0: * Convert PTR from a pointer to a derived class (described by sl@0: * CLASS_INFO) to a pointer to a base class (described by BASE_INFO) sl@0: * and store the resulting pointer in P_NEW_PTR. Return true (or sl@0: * non-zero) if the base class was found and the conversion was done, sl@0: * otherwise return false (or zero). sl@0: * sl@0: * Define the macro here: sl@0: */ sl@0: sl@0: #ifdef __cplusplus sl@0: /* In the ARM implementation, a suitable routine exists elsewhere in the sl@0: * C++ runtime library, where it is part of the dynamic_cast mechanism. sl@0: */ sl@0: extern "C" int __derived_to_base_conversion(void** p_ptr, void** p_new_ptr, sl@0: const std::type_info * class_info, sl@0: const std::type_info * base_info, sl@0: char** access_flags, int use_access_flags); sl@0: sl@0: #define DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO) \ sl@0: __derived_to_base_conversion(&(PTR), (P_NEW_PTR), (CLASS_INFO), (BASE_INFO), NULL, 0) sl@0: #endif sl@0: sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: /* Runtime debug support sl@0: * sl@0: * Here we define the interface to a "bottleneck function" to be called sl@0: * by exception handling code at 'interesting' points during execution, sl@0: * and breakpointable by a debugger. sl@0: * sl@0: * This is not part of the Exceptions ABI but is expected to be sl@0: * standardised elsewhere, probably in a Debug ABI. sl@0: * sl@0: * If you don't want this, define DEBUGGER_BOTTLENECK as a dummy, e.g. sl@0: * #define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) (void)0 sl@0: */ sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: struct _Unwind_Control_Block; sl@0: sl@0: typedef enum { sl@0: _UASUBSYS_CPP = 0x00, sl@0: _UASUBSYS_UNWINDER = 0xff sl@0: } _Unwind_Activity_subsystem; sl@0: sl@0: typedef enum { sl@0: _UAACT_STARTING = 0x0, sl@0: _UAACT_ENDING = 0x1, sl@0: _UAACT_BARRIERFOUND = 0x2, sl@0: _UAACT_PADENTRY = 0x3, sl@0: _UAACT_CPP_TYPEINFO = 0x80 sl@0: } _Unwind_Activity_activity; sl@0: sl@0: typedef enum { sl@0: _UAARG_ENDING_UNSPECIFIED = 0x0, sl@0: _UAARG_ENDING_TABLECORRUPT = 0x1, sl@0: _UAARG_ENDING_NOUNWIND = 0x2, sl@0: _UAARG_ENDING_VRSFAILED = 0x3, sl@0: /* C++ only: */ sl@0: _UAARG_ENDING_CPP_BADOPCODE = 0x4, sl@0: /* Unwinder only: */ sl@0: _UAARG_ENDING_UNWINDER_LOOKUPFAILED = 0x4, sl@0: _UAARG_ENDING_UNWINDER_BUFFERFAILED = 0x5 sl@0: } _Unwind_Activity_arg; sl@0: sl@0: void _Unwind_Activity(struct _Unwind_Control_Block *ucbp, uint32_t reason, uint32_t arg); sl@0: #define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) \ sl@0: _Unwind_Activity((UCBP),(((LANG)<<24)|ACTIVITY),(uint32_t)(ARG)) sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: /* Printed diagnostics sl@0: * sl@0: * These may be useful for debugging purposes during development, provided sl@0: * the execution environment supports diagnostics via printf. sl@0: * sl@0: * #define PR_DIAGNOSTICS for printed diagnostics from the personality routine. sl@0: * #define VRS_DIAGNOSTICS for printed diagnostics about VRS operations. sl@0: * #define UNWIND_ACTIVITY_DIAGNOSTICS for printed information from _Unwind_Activity. sl@0: */ sl@0: sl@0: /* ---------------------------------------------------------------------- */ sl@0: sl@0: #endif /* defined UNWINDENV_H */