source: trunk/src/gcc/gcc/unwind.h@ 2

Last change on this file since 2 was 2, checked in by bird, 23 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.0 KB
Line 
1/* Exception handling and frame unwind runtime interface routines.
2 Copyright (C) 2001 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, 59 Temple Place - Suite 330, Boston, MA
19 02111-1307, USA. */
20
21/* This is derived from the C++ ABI for IA-64. Where we diverge
22 for cross-architecture compatibility are noted with "@@@". */
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Level 1: Base ABI */
29
30/* @@@ The IA-64 ABI uses uint64 throughout. Most places this is
31 inefficient for 32-bit and smaller machines. */
32typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
33typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
34typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
35
36/* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
37 consumer of an exception. We'll go along with this for now even on
38 32-bit machines. We'll need to provide some other option for
39 16-bit machines and for machines with > 8 bits per byte. */
40typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
41
42/* The unwind interface uses reason codes in several contexts to
43 identify the reasons for failures or other actions. */
44typedef enum
45{
46 _URC_NO_REASON = 0,
47 _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
48 _URC_FATAL_PHASE2_ERROR = 2,
49 _URC_FATAL_PHASE1_ERROR = 3,
50 _URC_NORMAL_STOP = 4,
51 _URC_END_OF_STACK = 5,
52 _URC_HANDLER_FOUND = 6,
53 _URC_INSTALL_CONTEXT = 7,
54 _URC_CONTINUE_UNWIND = 8
55} _Unwind_Reason_Code;
56
57
58/* The unwind interface uses a pointer to an exception header object
59 as its representation of an exception being thrown. In general, the
60 full representation of an exception object is language- and
61 implementation-specific, but it will be prefixed by a header
62 understood by the unwind interface. */
63
64struct _Unwind_Exception;
65
66typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
67 struct _Unwind_Exception *);
68
69struct _Unwind_Exception
70{
71 _Unwind_Exception_Class exception_class;
72 _Unwind_Exception_Cleanup_Fn exception_cleanup;
73 _Unwind_Word private_1;
74 _Unwind_Word private_2;
75
76 /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
77 Taking that literally does not make much sense generically. Instead we
78 provide the maximum alignment required by any type for the machine. */
79} __attribute__((__aligned__));
80
81
82/* The ACTIONS argument to the personality routine is a bitwise OR of one
83 or more of the following constants. */
84typedef int _Unwind_Action;
85
86#define _UA_SEARCH_PHASE 1
87#define _UA_CLEANUP_PHASE 2
88#define _UA_HANDLER_FRAME 4
89#define _UA_FORCE_UNWIND 8
90#define _UA_END_OF_STACK 16
91
92/* This is an opaque type used to refer to a system-specific data
93 structure used by the system unwinder. This context is created and
94 destroyed by the system, and passed to the personality routine
95 during unwinding. */
96struct _Unwind_Context;
97
98/* Raise an exception, passing along the given exception object. */
99extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
100
101/* Raise an exception for forced unwinding. */
102
103typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
104 (int, _Unwind_Action, _Unwind_Exception_Class,
105 struct _Unwind_Exception *, struct _Unwind_Context *, void *);
106
107extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
108 _Unwind_Stop_Fn,
109 void *);
110
111/* Helper to invoke the exception_cleanup routine. */
112extern void _Unwind_DeleteException (struct _Unwind_Exception *);
113
114/* Resume propagation of an existing exception. This is used after
115 e.g. executing cleanup code, and not to implement rethrowing. */
116extern void _Unwind_Resume (struct _Unwind_Exception *);
117
118/* These functions are used for communicating information about the unwind
119 context (i.e. the unwind descriptors and the user register state) between
120 the unwind library and the personality routine and landing pad. Only
121 selected registers maybe manipulated. */
122
123extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
124extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
125
126extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
127extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
128
129extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
130
131extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
132
133
134/* The personality routine is the function in the C++ (or other language)
135 runtime library which serves as an interface between the system unwind
136 library and language-specific exception handling semantics. It is
137 specific to the code fragment described by an unwind info block, and
138 it is always referenced via the pointer in the unwind info block, and
139 hence it has no ABI-specified name.
140
141 Note that this implies that two different C++ implementations can
142 use different names, and have different contents in the language
143 specific data area. Moreover, that the language specific data
144 area contains no version info because name of the function invoked
145 provides more effective versioning by detecting at link time the
146 lack of code to handle the different data format. */
147
148typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
149 (int, _Unwind_Action, _Unwind_Exception_Class,
150 struct _Unwind_Exception *, struct _Unwind_Context *);
151
152/* @@@ The following alternate entry points are for setjmp/longjmp
153 based unwinding. */
154
155struct SjLj_Function_Context;
156extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
157extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
158
159extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
160 (struct _Unwind_Exception *);
161extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
162 (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
163extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
164
165/* @@@ The following provide access to the base addresses for text
166 and data-relative addressing in the LDSA. In order to stay link
167 compatible with the standard ABI for IA-64, we inline these. */
168
169#ifdef __ia64__
170#include <stdlib.h>
171
172static inline _Unwind_Ptr
173_Unwind_GetDataRelBase (struct _Unwind_Context *_C)
174{
175 /* The GP is stored in R1. */
176 return _Unwind_GetGR (_C, 1);
177}
178
179static inline _Unwind_Ptr
180_Unwind_GetTextRelBase (struct _Unwind_Context *_C)
181{
182 abort ();
183 return 0;
184}
185#else
186extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
187extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
188#endif
189
190#ifdef __cplusplus
191}
192#endif
Note: See TracBrowser for help on using the repository browser.