1 |
282 |
jeremybenn |
/* Header file for the ARM EABI unwinder
|
2 |
|
|
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
3 |
|
|
Free Software Foundation, Inc.
|
4 |
|
|
Contributed by Paul Brook
|
5 |
|
|
|
6 |
|
|
This file is free software; you can redistribute it and/or modify it
|
7 |
|
|
under the terms of the GNU General Public License as published by the
|
8 |
|
|
Free Software Foundation; either version 3, or (at your option) any
|
9 |
|
|
later version.
|
10 |
|
|
|
11 |
|
|
This file is distributed in the hope that it will be useful, but
|
12 |
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 |
|
|
General Public License for more details.
|
15 |
|
|
|
16 |
|
|
Under Section 7 of GPL version 3, you are granted additional
|
17 |
|
|
permissions described in the GCC Runtime Library Exception, version
|
18 |
|
|
3.1, as published by the Free Software Foundation.
|
19 |
|
|
|
20 |
|
|
You should have received a copy of the GNU General Public License and
|
21 |
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
22 |
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
23 |
|
|
<http://www.gnu.org/licenses/>. */
|
24 |
|
|
|
25 |
|
|
/* Language-independent unwinder header public defines. This contains both
|
26 |
|
|
ABI defined objects, and GNU support routines. */
|
27 |
|
|
|
28 |
|
|
#ifndef UNWIND_ARM_H
|
29 |
|
|
#define UNWIND_ARM_H
|
30 |
|
|
|
31 |
|
|
#define __ARM_EABI_UNWINDER__ 1
|
32 |
|
|
|
33 |
|
|
#ifdef __cplusplus
|
34 |
|
|
extern "C" {
|
35 |
|
|
#endif
|
36 |
|
|
typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
|
37 |
|
|
typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
|
38 |
|
|
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
|
39 |
|
|
typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
|
40 |
|
|
typedef _Unwind_Word _uw;
|
41 |
|
|
typedef unsigned _uw64 __attribute__((mode(__DI__)));
|
42 |
|
|
typedef unsigned _uw16 __attribute__((mode(__HI__)));
|
43 |
|
|
typedef unsigned _uw8 __attribute__((mode(__QI__)));
|
44 |
|
|
|
45 |
|
|
typedef enum
|
46 |
|
|
{
|
47 |
|
|
_URC_OK = 0, /* operation completed successfully */
|
48 |
|
|
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
|
49 |
|
|
_URC_END_OF_STACK = 5,
|
50 |
|
|
_URC_HANDLER_FOUND = 6,
|
51 |
|
|
_URC_INSTALL_CONTEXT = 7,
|
52 |
|
|
_URC_CONTINUE_UNWIND = 8,
|
53 |
|
|
_URC_FAILURE = 9 /* unspecified failure of some kind */
|
54 |
|
|
}
|
55 |
|
|
_Unwind_Reason_Code;
|
56 |
|
|
|
57 |
|
|
typedef enum
|
58 |
|
|
{
|
59 |
|
|
_US_VIRTUAL_UNWIND_FRAME = 0,
|
60 |
|
|
_US_UNWIND_FRAME_STARTING = 1,
|
61 |
|
|
_US_UNWIND_FRAME_RESUME = 2,
|
62 |
|
|
_US_ACTION_MASK = 3,
|
63 |
|
|
_US_FORCE_UNWIND = 8,
|
64 |
|
|
_US_END_OF_STACK = 16
|
65 |
|
|
}
|
66 |
|
|
_Unwind_State;
|
67 |
|
|
|
68 |
|
|
/* Provided only for for compatibility with existing code. */
|
69 |
|
|
typedef int _Unwind_Action;
|
70 |
|
|
#define _UA_SEARCH_PHASE 1
|
71 |
|
|
#define _UA_CLEANUP_PHASE 2
|
72 |
|
|
#define _UA_HANDLER_FRAME 4
|
73 |
|
|
#define _UA_FORCE_UNWIND 8
|
74 |
|
|
#define _UA_END_OF_STACK 16
|
75 |
|
|
#define _URC_NO_REASON _URC_OK
|
76 |
|
|
|
77 |
|
|
typedef struct _Unwind_Control_Block _Unwind_Control_Block;
|
78 |
|
|
typedef struct _Unwind_Context _Unwind_Context;
|
79 |
|
|
typedef _uw _Unwind_EHT_Header;
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
/* UCB: */
|
83 |
|
|
|
84 |
|
|
struct _Unwind_Control_Block
|
85 |
|
|
{
|
86 |
|
|
char exception_class[8];
|
87 |
|
|
void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block *);
|
88 |
|
|
/* Unwinder cache, private fields for the unwinder's use */
|
89 |
|
|
struct
|
90 |
|
|
{
|
91 |
|
|
_uw reserved1; /* Forced unwind stop fn, 0 if not forced */
|
92 |
|
|
_uw reserved2; /* Personality routine address */
|
93 |
|
|
_uw reserved3; /* Saved callsite address */
|
94 |
|
|
_uw reserved4; /* Forced unwind stop arg */
|
95 |
|
|
_uw reserved5;
|
96 |
|
|
}
|
97 |
|
|
unwinder_cache;
|
98 |
|
|
/* Propagation barrier cache (valid after phase 1): */
|
99 |
|
|
struct
|
100 |
|
|
{
|
101 |
|
|
_uw sp;
|
102 |
|
|
_uw bitpattern[5];
|
103 |
|
|
}
|
104 |
|
|
barrier_cache;
|
105 |
|
|
/* Cleanup cache (preserved over cleanup): */
|
106 |
|
|
struct
|
107 |
|
|
{
|
108 |
|
|
_uw bitpattern[4];
|
109 |
|
|
}
|
110 |
|
|
cleanup_cache;
|
111 |
|
|
/* Pr cache (for pr's benefit): */
|
112 |
|
|
struct
|
113 |
|
|
{
|
114 |
|
|
_uw fnstart; /* function start address */
|
115 |
|
|
_Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
|
116 |
|
|
_uw additional; /* additional data */
|
117 |
|
|
_uw reserved1;
|
118 |
|
|
}
|
119 |
|
|
pr_cache;
|
120 |
|
|
long long int :0; /* Force alignment to 8-byte boundary */
|
121 |
|
|
};
|
122 |
|
|
|
123 |
|
|
/* Virtual Register Set*/
|
124 |
|
|
|
125 |
|
|
typedef enum
|
126 |
|
|
{
|
127 |
|
|
_UVRSC_CORE = 0, /* integer register */
|
128 |
|
|
_UVRSC_VFP = 1, /* vfp */
|
129 |
|
|
_UVRSC_FPA = 2, /* fpa */
|
130 |
|
|
_UVRSC_WMMXD = 3, /* Intel WMMX data register */
|
131 |
|
|
_UVRSC_WMMXC = 4 /* Intel WMMX control register */
|
132 |
|
|
}
|
133 |
|
|
_Unwind_VRS_RegClass;
|
134 |
|
|
|
135 |
|
|
typedef enum
|
136 |
|
|
{
|
137 |
|
|
_UVRSD_UINT32 = 0,
|
138 |
|
|
_UVRSD_VFPX = 1,
|
139 |
|
|
_UVRSD_FPAX = 2,
|
140 |
|
|
_UVRSD_UINT64 = 3,
|
141 |
|
|
_UVRSD_FLOAT = 4,
|
142 |
|
|
_UVRSD_DOUBLE = 5
|
143 |
|
|
}
|
144 |
|
|
_Unwind_VRS_DataRepresentation;
|
145 |
|
|
|
146 |
|
|
typedef enum
|
147 |
|
|
{
|
148 |
|
|
_UVRSR_OK = 0,
|
149 |
|
|
_UVRSR_NOT_IMPLEMENTED = 1,
|
150 |
|
|
_UVRSR_FAILED = 2
|
151 |
|
|
}
|
152 |
|
|
_Unwind_VRS_Result;
|
153 |
|
|
|
154 |
|
|
/* Frame unwinding state. */
|
155 |
|
|
typedef struct
|
156 |
|
|
{
|
157 |
|
|
/* The current word (bytes packed msb first). */
|
158 |
|
|
_uw data;
|
159 |
|
|
/* Pointer to the next word of data. */
|
160 |
|
|
_uw *next;
|
161 |
|
|
/* The number of bytes left in this word. */
|
162 |
|
|
_uw8 bytes_left;
|
163 |
|
|
/* The number of words pointed to by ptr. */
|
164 |
|
|
_uw8 words_left;
|
165 |
|
|
}
|
166 |
|
|
__gnu_unwind_state;
|
167 |
|
|
|
168 |
|
|
typedef _Unwind_Reason_Code (*personality_routine) (_Unwind_State,
|
169 |
|
|
_Unwind_Control_Block *, _Unwind_Context *);
|
170 |
|
|
|
171 |
|
|
_Unwind_VRS_Result _Unwind_VRS_Set(_Unwind_Context *, _Unwind_VRS_RegClass,
|
172 |
|
|
_uw, _Unwind_VRS_DataRepresentation,
|
173 |
|
|
void *);
|
174 |
|
|
|
175 |
|
|
_Unwind_VRS_Result _Unwind_VRS_Get(_Unwind_Context *, _Unwind_VRS_RegClass,
|
176 |
|
|
_uw, _Unwind_VRS_DataRepresentation,
|
177 |
|
|
void *);
|
178 |
|
|
|
179 |
|
|
_Unwind_VRS_Result _Unwind_VRS_Pop(_Unwind_Context *, _Unwind_VRS_RegClass,
|
180 |
|
|
_uw, _Unwind_VRS_DataRepresentation);
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
/* Support functions for the PR. */
|
184 |
|
|
#define _Unwind_Exception _Unwind_Control_Block
|
185 |
|
|
typedef char _Unwind_Exception_Class[8];
|
186 |
|
|
|
187 |
|
|
void * _Unwind_GetLanguageSpecificData (_Unwind_Context *);
|
188 |
|
|
_Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *);
|
189 |
|
|
|
190 |
|
|
/* These two should never be used. */
|
191 |
|
|
_Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *);
|
192 |
|
|
_Unwind_Ptr _Unwind_GetTextRelBase (_Unwind_Context *);
|
193 |
|
|
|
194 |
|
|
/* Interface functions: */
|
195 |
|
|
_Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Control_Block *ucbp);
|
196 |
|
|
void __attribute__((noreturn)) _Unwind_Resume(_Unwind_Control_Block *ucbp);
|
197 |
|
|
_Unwind_Reason_Code _Unwind_Resume_or_Rethrow (_Unwind_Control_Block *ucbp);
|
198 |
|
|
|
199 |
|
|
typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
|
200 |
|
|
(int, _Unwind_Action, _Unwind_Exception_Class,
|
201 |
|
|
_Unwind_Control_Block *, struct _Unwind_Context *, void *);
|
202 |
|
|
_Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Control_Block *,
|
203 |
|
|
_Unwind_Stop_Fn, void *);
|
204 |
|
|
/* @@@ Use unwind data to perform a stack backtrace. The trace callback
|
205 |
|
|
is called for every stack frame in the call chain, but no cleanup
|
206 |
|
|
actions are performed. */
|
207 |
|
|
typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn) (_Unwind_Context *, void *);
|
208 |
|
|
_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn,
|
209 |
|
|
void*);
|
210 |
|
|
|
211 |
|
|
_Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
|
212 |
|
|
void _Unwind_Complete(_Unwind_Control_Block *ucbp);
|
213 |
|
|
void _Unwind_DeleteException (_Unwind_Exception *);
|
214 |
|
|
|
215 |
|
|
_Unwind_Reason_Code __gnu_unwind_frame (_Unwind_Control_Block *,
|
216 |
|
|
_Unwind_Context *);
|
217 |
|
|
_Unwind_Reason_Code __gnu_unwind_execute (_Unwind_Context *,
|
218 |
|
|
__gnu_unwind_state *);
|
219 |
|
|
|
220 |
|
|
/* Decode an R_ARM_TARGET2 relocation. */
|
221 |
|
|
static inline _Unwind_Word
|
222 |
|
|
_Unwind_decode_target2 (_Unwind_Word ptr)
|
223 |
|
|
{
|
224 |
|
|
_Unwind_Word tmp;
|
225 |
|
|
|
226 |
|
|
tmp = *(_Unwind_Word *) ptr;
|
227 |
|
|
/* Zero values are always NULL. */
|
228 |
|
|
if (!tmp)
|
229 |
|
|
return 0;
|
230 |
|
|
|
231 |
|
|
#if (defined(linux) && !defined(__uClinux__)) || defined(__NetBSD__)
|
232 |
|
|
/* Pc-relative indirect. */
|
233 |
|
|
tmp += ptr;
|
234 |
|
|
tmp = *(_Unwind_Word *) tmp;
|
235 |
|
|
#elif defined(__symbian__) || defined(__uClinux__)
|
236 |
|
|
/* Absolute pointer. Nothing more to do. */
|
237 |
|
|
#else
|
238 |
|
|
/* Pc-relative pointer. */
|
239 |
|
|
tmp += ptr;
|
240 |
|
|
#endif
|
241 |
|
|
return tmp;
|
242 |
|
|
}
|
243 |
|
|
|
244 |
|
|
static inline _Unwind_Word
|
245 |
|
|
_Unwind_GetGR (_Unwind_Context *context, int regno)
|
246 |
|
|
{
|
247 |
|
|
_uw val;
|
248 |
|
|
_Unwind_VRS_Get (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
|
249 |
|
|
return val;
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
/* Return the address of the instruction, not the actual IP value. */
|
253 |
|
|
#define _Unwind_GetIP(context) \
|
254 |
|
|
(_Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
|
255 |
|
|
|
256 |
|
|
#define _Unwind_GetIPInfo(context, ip_before_insn) \
|
257 |
|
|
(*ip_before_insn = 0, _Unwind_GetGR (context, 15) & ~(_Unwind_Word)1)
|
258 |
|
|
|
259 |
|
|
static inline void
|
260 |
|
|
_Unwind_SetGR (_Unwind_Context *context, int regno, _Unwind_Word val)
|
261 |
|
|
{
|
262 |
|
|
_Unwind_VRS_Set (context, _UVRSC_CORE, regno, _UVRSD_UINT32, &val);
|
263 |
|
|
}
|
264 |
|
|
|
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))
|
269 |
|
|
|
270 |
|
|
/* leb128 type numbers have a potentially unlimited size.
|
271 |
|
|
The target of the following definitions of _sleb128_t and _uleb128_t
|
272 |
|
|
is to have efficient data types large enough to hold the leb128 type
|
273 |
|
|
numbers used in the unwind code. */
|
274 |
|
|
typedef long _sleb128_t;
|
275 |
|
|
typedef unsigned long _uleb128_t;
|
276 |
|
|
|
277 |
|
|
#ifdef __cplusplus
|
278 |
|
|
} /* extern "C" */
|
279 |
|
|
#endif
|
280 |
|
|
|
281 |
|
|
#endif /* defined UNWIND_ARM_H */
|