Chameleon

Chameleon Svn Source Tree

Root/branches/xZen/src/include/unwind.h

Source at commit 1247 created 7 years 11 months ago.
By meklort, Update makefiles... initial work for fat modules
1/* Exception handling and frame unwind runtime interface routines.
2 Copyright (C) 2001, 2003, 2004, 2006 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 2, 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 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA. */
20
21/* As a special exception, if you include this header file into source
22 files compiled by GCC, this header file does not by itself cause
23 the resulting executable to be covered by the GNU General Public
24 License. This exception does not however invalidate any other
25 reasons why the executable file might be covered by the GNU General
26 Public License. */
27
28/* This is derived from the C++ ABI for IA-64. Where we diverge
29 for cross-architecture compatibility are noted with "@@@". */
30
31#ifndef _UNWIND_H
32#define _UNWIND_H
33
34#ifndef HIDE_EXPORTS
35#pragma GCC visibility push(default)
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
43
44
45/* Level 1: Base ABI */
46
47/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
48 inefficient for 32-bit and smaller machines. */
49typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
50typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
51#if defined(__ia64__) && defined(__hpux__)
52typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
53#else
54typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
55#endif
56typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
57
58/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
59 consumer of an exception. We'll go along with this for now even on
60 32-bit machines. We'll need to provide some other option for
61 16-bit machines and for machines with > 8 bits per byte. */
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 _Unwind_Word private_1;
95 _Unwind_Word private_2;
96
97 /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
98 Taking that literally does not make much sense generically. Instead we
99 provide the maximum alignment required by any type for the machine. */
100} __attribute__((__aligned__));
101
102
103/* The ACTIONS argument to the personality routine is a bitwise OR of one
104 or more of the following constants. */
105typedef int _Unwind_Action;
106
107#define _UA_SEARCH_PHASE1
108#define _UA_CLEANUP_PHASE2
109#define _UA_HANDLER_FRAME4
110#define _UA_FORCE_UNWIND8
111#define _UA_END_OF_STACK16
112
113/* This is an opaque type used to refer to a system-specific data
114 structure used by the system unwinder. This context is created and
115 destroyed by the system, and passed to the personality routine
116 during unwinding. */
117struct _Unwind_Context;
118
119/* Raise an exception, passing along the given exception object. */
120extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
121
122/* Raise an exception for forced unwinding. */
123
124typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
125 (int, _Unwind_Action, _Unwind_Exception_Class,
126 struct _Unwind_Exception *, struct _Unwind_Context *, void *);
127
128extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
129 _Unwind_Stop_Fn,
130 void *);
131
132/* Helper to invoke the exception_cleanup routine. */
133extern void _Unwind_DeleteException (struct _Unwind_Exception *);
134
135/* Resume propagation of an existing exception. This is used after
136 e.g. executing cleanup code, and not to implement rethrowing. */
137extern void _Unwind_Resume (struct _Unwind_Exception *);
138
139/* @@@ Resume propagation of an FORCE_UNWIND exception, or to rethrow
140 a normal exception that was handled. */
141extern _Unwind_Reason_Code _Unwind_Resume_or_Rethrow (struct _Unwind_Exception *);
142
143/* @@@ Use unwind data to perform a stack backtrace. The trace callback
144 is called for every stack frame in the call chain, but no cleanup
145 actions are performed. */
146typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
147 (struct _Unwind_Context *, void *);
148
149extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
150
151/* These functions are used for communicating information about the unwind
152 context (i.e. the unwind descriptors and the user register state) between
153 the unwind library and the personality routine and landing pad. Only
154 selected registers maybe manipulated. */
155
156extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
157extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
158
159extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
160extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
161extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
162
163/* @@@ Retrieve the CFA of the given context. */
164extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
165
166extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
167
168extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
169
170
171/* The personality routine is the function in the C++ (or other language)
172 runtime library which serves as an interface between the system unwind
173 library and language-specific exception handling semantics. It is
174 specific to the code fragment described by an unwind info block, and
175 it is always referenced via the pointer in the unwind info block, and
176 hence it has no ABI-specified name.
177
178 Note that this implies that two different C++ implementations can
179 use different names, and have different contents in the language
180 specific data area. Moreover, that the language specific data
181 area contains no version info because name of the function invoked
182 provides more effective versioning by detecting at link time the
183 lack of code to handle the different data format. */
184
185typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
186 (int, _Unwind_Action, _Unwind_Exception_Class,
187 struct _Unwind_Exception *, struct _Unwind_Context *);
188
189/* @@@ The following alternate entry points are for setjmp/longjmp
190 based unwinding. */
191
192struct SjLj_Function_Context;
193extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
194extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
195
196extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
197 (struct _Unwind_Exception *);
198extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
199 (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
200extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
201extern _Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow (struct _Unwind_Exception *);
202
203/* @@@ The following provide access to the base addresses for text
204 and data-relative addressing in the LDSA. In order to stay link
205 compatible with the standard ABI for IA-64, we inline these. */
206
207#ifdef __ia64__
208#include <stdlib.h>
209
210static inline _Unwind_Ptr
211_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
212{
213 /* The GP is stored in R1. */
214 return _Unwind_GetGR (_C, 1);
215}
216
217static inline _Unwind_Ptr
218_Unwind_GetTextRelBase (struct _Unwind_Context *_C __attribute__ ((__unused__)))
219{
220 abort ();
221 return 0;
222}
223
224/* @@@ Retrieve the Backing Store Pointer of the given context. */
225extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
226#else
227extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
228extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
229#endif
230
231/* @@@ Given an address, return the entry point of the function that
232 contains it. */
233extern void * _Unwind_FindEnclosingFunction (void *pc);
234
235#ifdef __cplusplus
236}
237#endif
238
239#ifndef HIDE_EXPORTS
240#pragma GCC visibility pop
241#endif
242
243#endif /* unwind.h */
244

Archive Download this file

Revision: 1247