source: Daodan/MSYS2/mingw32/lib/gcc/i686-w64-mingw32/11.2.0/include/unwind.h@ 1170

Last change on this file since 1170 was 1166, checked in by rossy, 3 years ago

Daodan: Replace MinGW build env with an up-to-date MSYS2 env

File size: 10.6 KB
Line 
1/* Exception handling and frame unwind runtime interface routines.
2 Copyright (C) 2001-2021 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__
224static inline _Unwind_Ptr
225_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
226{
227 /* The GP is stored in R1. */
228 return _Unwind_GetGR (_C, 1);
229}
230
231static inline _Unwind_Ptr
232_Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__)))
233{
234 __builtin_abort ();
235 return 0;
236}
237
238/* @@@ Retrieve the Backing Store Pointer of the given context. */
239extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
240#else
241extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
242extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
243#endif
244
245/* @@@ Given an address, return the entry point of the function that
246 contains it. */
247extern void * _Unwind_FindEnclosingFunction (void *pc);
248
249#ifndef __SIZEOF_LONG__
250 #error "__SIZEOF_LONG__ macro not defined"
251#endif
252
253#ifndef __SIZEOF_POINTER__
254 #error "__SIZEOF_POINTER__ macro not defined"
255#endif
256
257
258/* leb128 type numbers have a potentially unlimited size.
259 The target of the following definitions of _sleb128_t and _uleb128_t
260 is to have efficient data types large enough to hold the leb128 type
261 numbers used in the unwind code.
262 Mostly these types will simply be defined to long and unsigned long
263 except when a unsigned long data type on the target machine is not
264 capable of storing a pointer. */
265
266#if __SIZEOF_LONG__ >= __SIZEOF_POINTER__
267 typedef long _sleb128_t;
268 typedef unsigned long _uleb128_t;
269#elif __SIZEOF_LONG_LONG__ >= __SIZEOF_POINTER__
270 typedef long long _sleb128_t;
271 typedef unsigned long long _uleb128_t;
272#else
273# error "What type shall we use for _sleb128_t?"
274#endif
275
276#if defined (__SEH__) && !defined (__USING_SJLJ_EXCEPTIONS__)
277/* Handles the mapping from SEH to GCC interfaces. */
278EXCEPTION_DISPOSITION _GCC_specific_handler (PEXCEPTION_RECORD, void *,
279 PCONTEXT, PDISPATCHER_CONTEXT,
280 _Unwind_Personality_Fn);
281#endif
282
283#ifdef __cplusplus
284}
285#endif
286
287#ifndef HIDE_EXPORTS
288#pragma GCC visibility pop
289#endif
290
291/* Additional actions to unwind number of stack frames. */
292#define _Unwind_Frames_Extra(frames)
293
294/* Increment frame count. */
295#define _Unwind_Frames_Increment(context, frames) frames++
296
297#endif /* unwind.h */
Note: See TracBrowser for help on using the repository browser.