source: Daodan/MinGW/lib/gcc/mingw32/5.3.0/include/unwind.h@ 1094

Last change on this file since 1094 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 10.5 KB
Line 
1/* Exception handling and frame unwind runtime interface routines.
2 Copyright (C) 2001-2015 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 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/* This is derived from the C++ ABI for IA-64. Where we diverge
26 for cross-architecture compatibility are noted with "@@@". */
27
28#ifndef _UNWIND_H
29#define _UNWIND_H
30
31#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
32/* Only for _GCC_specific_handler. */
33#include <windows.h>
34#endif
35
36#ifndef HIDE_EXPORTS
37#pragma GCC visibility push(default)
38#endif
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/* Level 1: Base ABI */
45
46/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
47 inefficient for 32-bit and smaller machines. */
48typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
49typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
50#if defined(__ia64__) && defined(__hpux__)
51typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
52#else
53typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
54#endif
55typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
56
57/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
58 consumer of an exception. We'll go along with this for now even on
59 32-bit machines. We'll need to provide some other option for
60 16-bit machines and for machines with > 8 bits per byte. */
61typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
62
63/* The unwind interface uses reason codes in several contexts to
64 identify the reasons for failures or other actions. */
65typedef enum
66{
67 _URC_NO_REASON = 0,
68 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
69 _URC_FATAL_PHASE2_ERROR = 2,
70 _URC_FATAL_PHASE1_ERROR = 3,
71 _URC_NORMAL_STOP = 4,
72 _URC_END_OF_STACK = 5,
73 _URC_HANDLER_FOUND = 6,
74 _URC_INSTALL_CONTEXT = 7,
75 _URC_CONTINUE_UNWIND = 8
76} _Unwind_Reason_Code;
77
78
79/* The unwind interface uses a pointer to an exception header object
80 as its representation of an exception being thrown. In general, the
81 full representation of an exception object is language- and
82 implementation-specific, but it will be prefixed by a header
83 understood by the unwind interface. */
84
85struct _Unwind_Exception;
86
87typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
88 struct _Unwind_Exception *);
89
90struct _Unwind_Exception
91{
92 _Unwind_Exception_Class exception_class;
93 _Unwind_Exception_Cleanup_Fn exception_cleanup;
94
95#if !defined (__USING_SJLJ_EXCEPTIONS__) && defined (__SEH__)
96 _Unwind_Word private_[6];
97#else
98 _Unwind_Word private_1;
99 _Unwind_Word private_2;
100#endif
101
102 /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
103 Taking that literally does not make much sense generically. Instead we
104 provide the maximum alignment required by any type for the machine. */
105} __attribute__((__aligned__));
106
107
108/* The ACTIONS argument to the personality routine is a bitwise OR of one
109 or more of the following constants. */
110typedef int _Unwind_Action;
111
112#define _UA_SEARCH_PHASE 1
113#define _UA_CLEANUP_PHASE 2
114#define _UA_HANDLER_FRAME 4
115#define _UA_FORCE_UNWIND 8
116#define _UA_END_OF_STACK 16
117
118/* The target can override this macro to define any back-end-specific
119 attributes required for the lowest-level stack frame. */
120#ifndef LIBGCC2_UNWIND_ATTRIBUTE
121#define LIBGCC2_UNWIND_ATTRIBUTE
122#endif
123
124/* This is an opaque type used to refer to a system-specific data
125 structure used by the system unwinder. This context is created and
126 destroyed by the system, and passed to the personality routine
127 during unwinding. */
128struct _Unwind_Context;
129
130/* Raise an exception, passing along the given exception object. */
131extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
132_Unwind_RaiseException (struct _Unwind_Exception *);
133
134/* Raise an exception for forced unwinding. */
135
136typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
137 (int, _Unwind_Action, _Unwind_Exception_Class,
138 struct _Unwind_Exception *, struct _Unwind_Context *, void *);
139
140extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
141_Unwind_ForcedUnwind (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
142
143/* Helper to invoke the exception_cleanup routine. */
144extern void _Unwind_DeleteException (struct _Unwind_Exception *);
145
146/* Resume propagation of an existing exception. This is used after
147 e.g. executing cleanup code, and not to implement rethrowing. */
148extern void LIBGCC2_UNWIND_ATTRIBUTE
149_Unwind_Resume (struct _Unwind_Exception *);
150
151/* @@@ Resume propagation of a FORCE_UNWIND exception, or to rethrow
152 a normal exception that was handled. */
153extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
154_Unwind_Resume_or_Rethrow (struct _Unwind_Exception *);
155
156/* @@@ Use unwind data to perform a stack backtrace. The trace callback
157 is called for every stack frame in the call chain, but no cleanup
158 actions are performed. */
159typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
160 (struct _Unwind_Context *, void *);
161
162extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
163_Unwind_Backtrace (_Unwind_Trace_Fn, void *);
164
165/* These functions are used for communicating information about the unwind
166 context (i.e. the unwind descriptors and the user register state) between
167 the unwind library and the personality routine and landing pad. Only
168 selected registers may be manipulated. */
169
170extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
171extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
172
173extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
174extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
175extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
176
177/* @@@ Retrieve the CFA of the given context. */
178extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
179
180extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
181
182extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
183
184
185/* The personality routine is the function in the C++ (or other language)
186 runtime library which serves as an interface between the system unwind
187 library and language-specific exception handling semantics. It is
188 specific to the code fragment described by an unwind info block, and
189 it is always referenced via the pointer in the unwind info block, and
190 hence it has no ABI-specified name.
191
192 Note that this implies that two different C++ implementations can
193 use different names, and have different contents in the language
194 specific data area. Moreover, that the language specific data
195 area contains no version info because name of the function invoked
196 provides more effective versioning by detecting at link time the
197 lack of code to handle the different data format. */
198
199typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
200 (int, _Unwind_Action, _Unwind_Exception_Class,
201 struct _Unwind_Exception *, struct _Unwind_Context *);
202
203/* @@@ The following alternate entry points are for setjmp/longjmp
204 based unwinding. */
205
206struct SjLj_Function_Context;
207extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
208extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
209
210extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
211_Unwind_SjLj_RaiseException (struct _Unwind_Exception *);
212extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
213_Unwind_SjLj_ForcedUnwind (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
214extern void LIBGCC2_UNWIND_ATTRIBUTE
215_Unwind_SjLj_Resume (struct _Unwind_Exception *);
216extern _Unwind_Reason_Code LIBGCC2_UNWIND_ATTRIBUTE
217_Unwind_SjLj_Resume_or_Rethrow (struct _Unwind_Exception *);
218
219/* @@@ The following provide access to the base addresses for text
220 and data-relative addressing in the LDSA. In order to stay link
221 compatible with the standard ABI for IA-64, we inline these. */
222
223#ifdef __ia64__
224#include <stdlib.h>
225
226static inline _Unwind_Ptr
227_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
228{
229 /* The GP is stored in R1. */
230 return _Unwind_GetGR (_C, 1);
231}
232
233static inline _Unwind_Ptr
234_Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__)))
235{
236 abort ();
237 return 0;
238}
239
240/* @@@ Retrieve the Backing Store Pointer of the given context. */
241extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
242#else
243extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
244extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
245#endif
246
247/* @@@ Given an address, return the entry point of the function that
248 contains it. */
249extern void * _Unwind_FindEnclosingFunction (void *pc);
250
251#ifndef __SIZEOF_LONG__
252 #error "__SIZEOF_LONG__ macro not defined"
253#endif
254
255#ifndef __SIZEOF_POINTER__
256 #error "__SIZEOF_POINTER__ macro not defined"
257#endif
258
259
260/* leb128 type numbers have a potentially unlimited size.
261 The target of the following definitions of _sleb128_t and _uleb128_t
262 is to have efficient data types large enough to hold the leb128 type
263 numbers used in the unwind code.
264 Mostly these types will simply be defined to long and unsigned long
265 except when a unsigned long data type on the target machine is not
266 capable of storing a pointer. */
267
268#if __SIZEOF_LONG__ >= __SIZEOF_POINTER__
269 typedef long _sleb128_t;
270 typedef unsigned long _uleb128_t;
271#elif __SIZEOF_LONG_LONG__ >= __SIZEOF_POINTER__
272 typedef long long _sleb128_t;
273 typedef unsigned long long _uleb128_t;
274#else
275# error "What type shall we use for _sleb128_t?"
276#endif
277
278#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
279/* Handles the mapping from SEH to GCC interfaces. */
280EXCEPTION_DISPOSITION _GCC_specific_handler (PEXCEPTION_RECORD, void *,
281 PCONTEXT, PDISPATCHER_CONTEXT,
282 _Unwind_Personality_Fn);
283#endif
284
285#ifdef __cplusplus
286}
287#endif
288
289#ifndef HIDE_EXPORTS
290#pragma GCC visibility pop
291#endif
292
293#endif /* unwind.h */
Note: See TracBrowser for help on using the repository browser.