Back to index

glibc  2.9
unwind.h
Go to the documentation of this file.
00001 /* Header file for the ARM EABI unwinder
00002    Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
00003    Contributed by Paul Brook
00004 
00005    This file is free software; you can redistribute it and/or modify it
00006    under the terms of the GNU General Public License as published by the
00007    Free Software Foundation; either version 2, or (at your option) any
00008    later version.
00009 
00010    In addition to the permissions in the GNU General Public License, the
00011    Free Software Foundation gives you unlimited permission to link the
00012    compiled version of this file into combinations with other programs,
00013    and to distribute those combinations without any restriction coming
00014    from the use of this file.  (The General Public License restrictions
00015    do apply in other respects; for example, they cover modification of
00016    the file, and distribution when not linked into a combine
00017    executable.)
00018 
00019    This file is distributed in the hope that it will be useful, but
00020    WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022    General Public License for more details.
00023 
00024    You should have received a copy of the GNU General Public License
00025    along with this program; see the file COPYING.  If not, write to
00026    the Free Software Foundation, 51 Franklin Street, Fifth Floor,
00027    Boston, MA 02110-1301, USA.  */
00028 
00029 /* Language-independent unwinder header public defines.  This contains both
00030    ABI defined objects, and GNU support routines.  */
00031 
00032 #ifndef UNWIND_ARM_H
00033 #define UNWIND_ARM_H
00034 
00035 #define __ARM_EABI_UNWINDER__ 1
00036 
00037 #ifdef __cplusplus
00038 extern "C" {
00039 #endif
00040   typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
00041   typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
00042   typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
00043   typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
00044   typedef _Unwind_Word _uw;
00045   typedef unsigned _uw64 __attribute__((mode(__DI__)));
00046   typedef unsigned _uw16 __attribute__((mode(__HI__)));
00047   typedef unsigned _uw8 __attribute__((mode(__QI__)));
00048 
00049   typedef enum
00050     {
00051       _URC_OK = 0,       /* operation completed successfully */
00052       _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
00053       _URC_END_OF_STACK = 5,
00054       _URC_HANDLER_FOUND = 6,
00055       _URC_INSTALL_CONTEXT = 7,
00056       _URC_CONTINUE_UNWIND = 8,
00057       _URC_FAILURE = 9   /* unspecified failure of some kind */
00058     }
00059   _Unwind_Reason_Code;
00060 
00061   typedef enum
00062     {
00063       _US_VIRTUAL_UNWIND_FRAME = 0,
00064       _US_UNWIND_FRAME_STARTING = 1,
00065       _US_UNWIND_FRAME_RESUME = 2,
00066       _US_ACTION_MASK = 3,
00067       _US_FORCE_UNWIND = 8,
00068       _US_END_OF_STACK = 16
00069     }
00070   _Unwind_State;
00071 
00072   /* Provided only for for compatibility with existing code.  */
00073   typedef int _Unwind_Action;
00074 #define _UA_SEARCH_PHASE    1
00075 #define _UA_CLEANUP_PHASE   2
00076 #define _UA_HANDLER_FRAME   4
00077 #define _UA_FORCE_UNWIND    8
00078 #define _UA_END_OF_STACK    16
00079 #define _URC_NO_REASON      _URC_OK
00080 
00081   typedef struct _Unwind_Control_Block _Unwind_Control_Block;
00082   typedef struct _Unwind_Context _Unwind_Context;
00083   typedef _uw _Unwind_EHT_Header;
00084 
00085 
00086   /* UCB: */
00087 
00088   struct _Unwind_Control_Block
00089     {
00090 #ifdef _LIBC
00091       /* For the benefit of code which assumes this is a scalar.  All
00092         glibc ever does is clear it.  */
00093       _uw64 exception_class;
00094 #else
00095       char exception_class[8];
00096 #endif
00097       void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
00098       /* Unwinder cache, private fields for the unwinder's use */
00099       struct
00100        {
00101          _uw reserved1;  /* Forced unwind stop fn, 0 if not forced */
00102          _uw reserved2;  /* Personality routine address */
00103          _uw reserved3;  /* Saved callsite address */
00104          _uw reserved4;  /* Forced unwind stop arg */
00105          _uw reserved5;
00106        }
00107       unwinder_cache;
00108       /* Propagation barrier cache (valid after phase 1): */
00109       struct
00110        {
00111          _uw sp;
00112          _uw bitpattern[5];
00113        }
00114       barrier_cache;
00115       /* Cleanup cache (preserved over cleanup): */
00116       struct
00117        {
00118          _uw bitpattern[4];
00119        }
00120       cleanup_cache;
00121       /* Pr cache (for pr's benefit): */
00122       struct
00123        {
00124          _uw fnstart;                     /* function start address */
00125          _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
00126          _uw additional;           /* additional data */
00127          _uw reserved1;
00128        }
00129       pr_cache;
00130       long long int :0;     /* Force alignment to 8-byte boundary */
00131     };
00132 
00133   /* Virtual Register Set*/
00134 
00135   typedef enum
00136     {
00137       _UVRSC_CORE = 0,      /* integer register */
00138       _UVRSC_VFP = 1,       /* vfp */
00139       _UVRSC_FPA = 2,       /* fpa */
00140       _UVRSC_WMMXD = 3,     /* Intel WMMX data register */
00141       _UVRSC_WMMXC = 4      /* Intel WMMX control register */
00142     }
00143   _Unwind_VRS_RegClass;
00144 
00145   typedef enum
00146     {
00147       _UVRSD_UINT32 = 0,
00148       _UVRSD_VFPX = 1,
00149       _UVRSD_FPAX = 2,
00150       _UVRSD_UINT64 = 3,
00151       _UVRSD_FLOAT = 4,
00152       _UVRSD_DOUBLE = 5
00153     }
00154   _Unwind_VRS_DataRepresentation;
00155 
00156   typedef enum
00157     {
00158       _UVRSR_OK = 0,
00159       _UVRSR_NOT_IMPLEMENTED = 1,
00160       _UVRSR_FAILED = 2
00161     }
00162   _Unwind_VRS_Result;
00163 
00164   /* Frame unwinding state.  */
00165   typedef struct
00166     {
00167       /* The current word (bytes packed msb first).  */
00168       _uw data;
00169       /* Pointer to the next word of data.  */
00170       _uw *next;
00171       /* The number of bytes left in this word.  */
00172       _uw8 bytes_left;
00173       /* The number of words pointed to by ptr.  */
00174       _uw8 words_left;
00175     }
00176   __gnu_unwind_state;
00177 
00178   typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
00179       _Unwind_Control_Block *, _Unwind_Context *);
00180 
00181   _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
00182                                      _uw, _Unwind_VRS_DataRepresentation,
00183                                      void *);
00184 
00185   _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
00186                                      _uw, _Unwind_VRS_DataRepresentation,
00187                                      void *);
00188 
00189   _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
00190                                      _uw, _Unwind_VRS_DataRepresentation);
00191 
00192 
00193   /* Support functions for the PR.  */
00194 #define _Unwind_Exception _Unwind_Control_Block
00195   typedef char _Unwind_Exception_Class[8];
00196 
00197   void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
00198   _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
00199 
00200   /* These two should never be used.  */
00201   _Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
00202   _Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
00203 
00204   /* Interface functions: */
00205   _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
00206   void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
00207   _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Control_Block *ucbp);
00208 
00209   typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
00210        (int, _Unwind_Action, _Unwind_Exception_Class,
00211        _Unwind_Control_Block *, struct _Unwind_Context *, void *);
00212   _Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
00213                                        _Unwind_Stop_Fn, void *);
00214   _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
00215   void _Unwind_Complete(_Unwind_Control_Block *ucbp);
00216   void _Unwind_DeleteException (_Unwind_Exception *);
00217 
00218   _Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
00219                                      _Unwind_Context *);
00220   _Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
00221                                        __gnu_unwind_state *);
00222 
00223   /* Decode an R_ARM_TARGET2 relocation.  */
00224   static inline _Unwind_Word
00225   _Unwind_decode_target2 (_Unwind_Word ptr)
00226     {
00227       _Unwind_Word tmp;
00228 
00229       tmp = *(_Unwind_Word *) ptr;
00230       /* Zero values are always NULL.  */
00231       if (!tmp)
00232        return 0;
00233 
00234 #if defined(linux) || defined(__NetBSD__)
00235       /* Pc-relative indirect.  */
00236       tmp += ptr;
00237       tmp = *(_Unwind_Word *) tmp;
00238 #elif defined(__symbian__)
00239       /* Absolute pointer.  Nothing more to do.  */
00240 #else
00241       /* Pc-relative pointer.  */
00242       tmp += ptr;
00243 #endif
00244       return tmp;
00245     }
00246 
00247   static inline _Unwind_Word
00248   _Unwind_GetGR (_Unwind_Context *context, int regno)
00249     {
00250       _uw val;
00251       _Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
00252       return val;
00253     }
00254 
00255   /* Return the address of the instruction, not the actual IP value.  */
00256 #define _Unwind_GetIP(context) \
00257   (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
00258 
00259   static inline void
00260   _Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
00261     {
00262       _Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
00263     }
00264 
00265   /* The dwarf unwinder doesn't understand arm/thumb state.  We assume the
00266      landing pad uses the same instruction set as the call site.  */
00267 #define _Unwind_SetIP(context, val) \
00268   _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
00269 
00270 #ifdef __cplusplus
00271 }   /* extern "C" */
00272 #endif
00273 
00274 #endif /* defined UNWIND_ARM_H */