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