1 /* Header file for the ARM EABI unwinder
2 Copyright (C) 2003, 2004, 2005, 2009 Free Software Foundation, Inc.
3 Contributed by Paul Brook
5 This file is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 In addition to the permissions in the GNU General Public License, the
11 Free Software Foundation gives you unlimited permission to link the
12 compiled version of this file into combinations with other programs,
13 and to distribute those combinations without any restriction coming
14 from the use of this file. (The General Public License restrictions
15 do apply in other respects; for example, they cover modification of
16 the file, and distribution when not linked into a combine
19 This file is distributed in the hope that it will be useful, but
20 WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; see the file COPYING. If not, write to
26 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27 Boston, MA 02110-1301, USA. */
29 /* Language-independent unwinder header public defines. This contains both
30 ABI defined objects, and GNU support routines. */
35 #define __ARM_EABI_UNWINDER__ 1
40 typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
41 typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
42 typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
43 typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
44 typedef _Unwind_Word _uw;
45 typedef unsigned _uw64 __attribute__((mode(__DI__)));
46 typedef unsigned _uw16 __attribute__((mode(__HI__)));
47 typedef unsigned _uw8 __attribute__((mode(__QI__)));
51 _URC_OK = 0, /* operation completed successfully */
52 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
53 _URC_END_OF_STACK = 5,
54 _URC_HANDLER_FOUND = 6,
55 _URC_INSTALL_CONTEXT = 7,
56 _URC_CONTINUE_UNWIND = 8,
57 _URC_FAILURE = 9 /* unspecified failure of some kind */
63 _US_VIRTUAL_UNWIND_FRAME = 0,
64 _US_UNWIND_FRAME_STARTING = 1,
65 _US_UNWIND_FRAME_RESUME = 2,
72 /* Provided only for for compatibility with existing code. */
73 typedef int _Unwind_Action;
74 #define _UA_SEARCH_PHASE 1
75 #define _UA_CLEANUP_PHASE 2
76 #define _UA_HANDLER_FRAME 4
77 #define _UA_FORCE_UNWIND 8
78 #define _UA_END_OF_STACK 16
79 #define _URC_NO_REASON _URC_OK
81 typedef struct _Unwind_Control_Block _Unwind_Control_Block;
82 typedef struct _Unwind_Context _Unwind_Context;
83 typedef _uw _Unwind_EHT_Header;
88 struct _Unwind_Control_Block
91 /* For the benefit of code which assumes this is a scalar. All
92 glibc ever does is clear it. */
93 _uw64 exception_class;
95 char exception_class[8];
97 void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
98 /* Unwinder cache, private fields for the unwinder's use */
101 _uw reserved1; /* Forced unwind stop fn, 0 if not forced */
102 _uw reserved2; /* Personality routine address */
103 _uw reserved3; /* Saved callsite address */
104 _uw reserved4; /* Forced unwind stop arg */
108 /* Propagation barrier cache (valid after phase 1): */
115 /* Cleanup cache (preserved over cleanup): */
121 /* Pr cache (for pr's benefit): */
124 _uw fnstart; /* function start address */
125 _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
126 _uw additional; /* additional data */
130 long long int :0; /* Force alignment to 8-byte boundary */
133 /* Virtual Register Set*/
137 _UVRSC_CORE = 0, /* integer register */
138 _UVRSC_VFP = 1, /* vfp */
139 _UVRSC_FPA = 2, /* fpa */
140 _UVRSC_WMMXD = 3, /* Intel WMMX data register */
141 _UVRSC_WMMXC = 4 /* Intel WMMX control register */
143 _Unwind_VRS_RegClass;
154 _Unwind_VRS_DataRepresentation;
159 _UVRSR_NOT_IMPLEMENTED = 1,
164 /* Frame unwinding state. */
167 /* The current word (bytes packed msb first). */
169 /* Pointer to the next word of data. */
171 /* The number of bytes left in this word. */
173 /* The number of words pointed to by ptr. */
178 typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
179 _Unwind_Control_Block *, _Unwind_Context *);
181 _Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
182 _uw, _Unwind_VRS_DataRepresentation,
185 _Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
186 _uw, _Unwind_VRS_DataRepresentation,
189 _Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
190 _uw, _Unwind_VRS_DataRepresentation);
193 /* Support functions for the PR. */
194 #define _Unwind_Exception _Unwind_Control_Block
195 typedef char _Unwind_Exception_Class[8];
197 void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
198 _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
200 /* These two should never be used. */
201 _Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
202 _Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
204 /* Interface functions: */
205 _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
206 void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
207 _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Control_Block *ucbp);
209 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
210 (int, _Unwind_Action, _Unwind_Exception_Class,
211 _Unwind_Control_Block *, struct _Unwind_Context *, void *);
212 _Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
213 _Unwind_Stop_Fn, void *);
214 _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
215 void _Unwind_Complete(_Unwind_Control_Block *ucbp);
216 void _Unwind_DeleteException (_Unwind_Exception *);
218 _Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
220 _Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
221 __gnu_unwind_state *);
223 /* Decode an R_ARM_TARGET2 relocation. */
224 static inline _Unwind_Word
225 _Unwind_decode_target2 (_Unwind_Word ptr)
229 tmp = *(_Unwind_Word *) ptr;
230 /* Zero values are always NULL. */
234 #if defined(linux) || defined(__NetBSD__)
235 /* Pc-relative indirect. */
237 tmp = *(_Unwind_Word *) tmp;
238 #elif defined(__symbian__)
239 /* Absolute pointer. Nothing more to do. */
241 /* Pc-relative pointer. */
247 static inline _Unwind_Word
248 _Unwind_GetGR (_Unwind_Context *context, int regno)
251 _Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
255 /* Return the address of the instruction, not the actual IP value. */
256 #define _Unwind_GetIP(context) \
257 (_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
260 _Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
262 _Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
265 /* The dwarf unwinder doesn't understand arm/thumb state. We assume the
266 landing pad uses the same instruction set as the call site. */
267 #define _Unwind_SetIP(context, val) \
268 _Unwind_SetGR (context, 15, val | (_Unwind_GetGR (context, 15) & 1))
270 typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
271 (struct _Unwind_Context *, void *);
273 extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
279 #endif /* defined UNWIND_ARM_H */