1 | /* Header file for unwinding stack frames for exception handling. */
|
---|
2 | /* Compile this one with gcc. */
|
---|
3 | /* Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
|
---|
4 | Contributed by Jason Merrill <jason@cygnus.com>.
|
---|
5 |
|
---|
6 | This file is part of GNU CC.
|
---|
7 |
|
---|
8 | GNU CC is free software; you can redistribute it and/or modify
|
---|
9 | it under the terms of the GNU General Public License as published by
|
---|
10 | the Free Software Foundation; either version 2, or (at your option)
|
---|
11 | any later version.
|
---|
12 |
|
---|
13 | GNU CC is distributed in the hope that it will be useful,
|
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | GNU General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License
|
---|
19 | along with GNU CC; see the file COPYING. If not, write to
|
---|
20 | the Free Software Foundation, 59 Temple Place - Suite 330,
|
---|
21 | Boston, MA 02111-1307, USA. */
|
---|
22 |
|
---|
23 |
|
---|
24 | /* Number of hardware registers known to the compiler.
|
---|
25 | We have 128 general registers, 128 floating point registers, 64 predicate
|
---|
26 | registers, 8 branch registers, and one frame pointer register. */
|
---|
27 |
|
---|
28 | /* ??? Should add ar.lc, ar.ec and probably also ar.pfs. */
|
---|
29 |
|
---|
30 | #define FIRST_PSEUDO_REGISTER 330
|
---|
31 |
|
---|
32 | #ifndef DWARF_FRAME_REGISTERS
|
---|
33 | #define DWARF_FRAME_REGISTERS FIRST_PSEUDO_REGISTER
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | typedef struct frame_state
|
---|
37 | {
|
---|
38 | void *cfa;
|
---|
39 | void *eh_ptr;
|
---|
40 | long cfa_offset;
|
---|
41 | long args_size;
|
---|
42 | long reg_or_offset[DWARF_FRAME_REGISTERS+1];
|
---|
43 | unsigned short cfa_reg;
|
---|
44 | unsigned short retaddr_column;
|
---|
45 | char saved[DWARF_FRAME_REGISTERS+1];
|
---|
46 | } frame_state;
|
---|
47 |
|
---|
48 | /* Values for 'saved' above. */
|
---|
49 | #define REG_UNSAVED 0
|
---|
50 | #define REG_SAVED_OFFSET 1
|
---|
51 | #define REG_SAVED_REG 2
|
---|
52 |
|
---|
53 | /* The representation for an "object" to be searched for frame unwind info.
|
---|
54 | For targets with named sections, one object is an executable or shared
|
---|
55 | library; for other targets, one object is one translation unit.
|
---|
56 |
|
---|
57 | A copy of this structure declaration is printed by collect2.c;
|
---|
58 | keep the copies synchronized! */
|
---|
59 |
|
---|
60 | struct object {
|
---|
61 | #ifdef IA64_UNWIND_INFO
|
---|
62 | void *pc_base; /* This field will be set by __do_frame_setup. */
|
---|
63 | #endif
|
---|
64 | void *pc_begin;
|
---|
65 | void *pc_end;
|
---|
66 | struct dwarf_fde *fde_begin;
|
---|
67 | struct dwarf_fde **fde_array;
|
---|
68 | size_t count;
|
---|
69 | struct object *next;
|
---|
70 | };
|
---|
71 |
|
---|
72 | /* Called from __throw to find the registers to restore for a given
|
---|
73 | PC_TARGET. The caller should allocate a local variable of `struct
|
---|
74 | frame_state' (declared in frame.h) and pass its address to STATE_IN.
|
---|
75 | Returns NULL on failure, otherwise returns STATE_IN. */
|
---|
76 |
|
---|
77 | extern struct frame_state *__frame_state_for (void *, struct frame_state *);
|
---|
78 |
|
---|
79 | #ifdef IA64_UNWIND_INFO
|
---|
80 |
|
---|
81 | /* This is the information required for unwind records in an ia64
|
---|
82 | object file. This is required by GAS and the compiler runtime. */
|
---|
83 |
|
---|
84 | /* These are the starting point masks for the various types of
|
---|
85 | unwind records. To create a record of type R3 for instance, one
|
---|
86 | starts by using the value UNW_R3 and or-ing in any other required values.
|
---|
87 | These values are also unique (in context), so they can be used to identify
|
---|
88 | the various record types as well. UNW_Bx and some UNW_Px do have the
|
---|
89 | same value, but Px can only occur in a prologue context, and Bx in
|
---|
90 | a body context. */
|
---|
91 |
|
---|
92 | #define UNW_R1 0x00
|
---|
93 | #define UNW_R2 0x40
|
---|
94 | #define UNW_R3 0x60
|
---|
95 | #define UNW_P1 0x80
|
---|
96 | #define UNW_P2 0xA0
|
---|
97 | #define UNW_P3 0xB0
|
---|
98 | #define UNW_P4 0xB8
|
---|
99 | #define UNW_P5 0xB9
|
---|
100 | #define UNW_P6 0xC0
|
---|
101 | #define UNW_P7 0xE0
|
---|
102 | #define UNW_P8 0xF0
|
---|
103 | #define UNW_P9 0xF1
|
---|
104 | #define UNW_P10 0xFF
|
---|
105 | #define UNW_X1 0xF9
|
---|
106 | #define UNW_X2 0xFA
|
---|
107 | #define UNW_X3 0xFB
|
---|
108 | #define UNW_X4 0xFC
|
---|
109 | #define UNW_B1 0x80
|
---|
110 | #define UNW_B2 0xC0
|
---|
111 | #define UNW_B3 0xE0
|
---|
112 | #define UNW_B4 0xF0
|
---|
113 |
|
---|
114 | /* These are all the various types of unwind records. */
|
---|
115 |
|
---|
116 | typedef enum
|
---|
117 | {
|
---|
118 | prologue, prologue_gr, body, mem_stack_f, mem_stack_v, psp_gr, psp_sprel,
|
---|
119 | rp_when, rp_gr, rp_br, rp_psprel, rp_sprel, pfs_when, pfs_gr, pfs_psprel,
|
---|
120 | pfs_sprel, preds_when, preds_gr, preds_psprel, preds_sprel,
|
---|
121 | fr_mem, frgr_mem, gr_gr, gr_mem, br_mem, br_gr, spill_base, spill_mask,
|
---|
122 | unat_when, unat_gr, unat_psprel, unat_sprel, lc_when, lc_gr, lc_psprel,
|
---|
123 | lc_sprel, fpsr_when, fpsr_gr, fpsr_psprel, fpsr_sprel,
|
---|
124 | priunat_when_gr, priunat_when_mem, priunat_gr, priunat_psprel,
|
---|
125 | priunat_sprel, bsp_when, bsp_gr, bsp_psprel, bsp_sprel, bspstore_when,
|
---|
126 | bspstore_gr, bspstore_psprel, bspstore_sprel, rnat_when, rnat_gr,
|
---|
127 | rnat_psprel, rnat_sprel, epilogue, label_state, copy_state,
|
---|
128 | spill_psprel, spill_sprel, spill_reg, spill_psprel_p, spill_sprel_p,
|
---|
129 | spill_reg_p
|
---|
130 | } unw_record_type;
|
---|
131 |
|
---|
132 |
|
---|
133 | /* These structures declare the fields that can be used in each of the
|
---|
134 | 4 record formats, R, P, B and X. */
|
---|
135 |
|
---|
136 | typedef struct unw_r_record
|
---|
137 | {
|
---|
138 | unsigned long rlen;
|
---|
139 | unsigned short mask;
|
---|
140 | unsigned short grsave;
|
---|
141 | } unw_r_record;
|
---|
142 |
|
---|
143 | typedef struct unw_p_record
|
---|
144 | {
|
---|
145 | void *imask;
|
---|
146 | unsigned long t;
|
---|
147 | unsigned long size;
|
---|
148 | unsigned long spoff;
|
---|
149 | unsigned long br;
|
---|
150 | unsigned long pspoff;
|
---|
151 | unsigned short gr;
|
---|
152 | unsigned short rmask;
|
---|
153 | unsigned short grmask;
|
---|
154 | unsigned long frmask;
|
---|
155 | unsigned short brmask;
|
---|
156 | } unw_p_record;
|
---|
157 |
|
---|
158 | typedef struct unw_b_record
|
---|
159 | {
|
---|
160 | unsigned long t;
|
---|
161 | unsigned long label;
|
---|
162 | unsigned short ecount;
|
---|
163 | } unw_b_record;
|
---|
164 |
|
---|
165 | typedef struct unw_x_record
|
---|
166 | {
|
---|
167 | unsigned long t;
|
---|
168 | unsigned long spoff;
|
---|
169 | unsigned long pspoff;
|
---|
170 | unsigned short reg;
|
---|
171 | unsigned short treg;
|
---|
172 | unsigned short qp;
|
---|
173 | unsigned short xy; /* Value of the XY field.. */
|
---|
174 | } unw_x_record;
|
---|
175 |
|
---|
176 | /* This structure is used to determine the specific record type and
|
---|
177 | its fields. */
|
---|
178 | typedef struct unwind_record
|
---|
179 | {
|
---|
180 | unw_record_type type;
|
---|
181 | union {
|
---|
182 | unw_r_record r;
|
---|
183 | unw_p_record p;
|
---|
184 | unw_b_record b;
|
---|
185 | unw_x_record x;
|
---|
186 | } record;
|
---|
187 | } unwind_record;
|
---|
188 |
|
---|
189 | /* This structure represents the start of an unwind information pointer.
|
---|
190 | 'unwind_descriptors' is the beginninng of the unwind descriptors, which
|
---|
191 | use up 'length' bytes of storage. */
|
---|
192 |
|
---|
193 | typedef struct unwind_info_ptr
|
---|
194 | {
|
---|
195 | unsigned short version;
|
---|
196 | unsigned short flags;
|
---|
197 | unsigned int length;
|
---|
198 | unsigned char unwind_descriptors[1];
|
---|
199 | } unwind_info_ptr;
|
---|
200 |
|
---|
201 |
|
---|
202 | #define IA64_UNW_LOC_TYPE_NONE 0
|
---|
203 | #define IA64_UNW_LOC_TYPE_MEM 1
|
---|
204 | #define IA64_UNW_LOC_TYPE_GR 2
|
---|
205 | #define IA64_UNW_LOC_TYPE_FR 3
|
---|
206 | #define IA64_UNW_LOC_TYPE_BR 4
|
---|
207 | #define IA64_UNW_LOC_TYPE_SPOFF 5
|
---|
208 | #define IA64_UNW_LOC_TYPE_PSPOFF 6
|
---|
209 | #define IA64_UNW_LOC_TYPE_OFFSET 7
|
---|
210 | #define IA64_UNW_LOC_TYPE_SPILLBASE 8
|
---|
211 |
|
---|
212 | typedef struct ia64_reg_loc
|
---|
213 | {
|
---|
214 | long when; /* PC relative offset from start of function. */
|
---|
215 | union { /* In memory or another register? */
|
---|
216 | void *mem;
|
---|
217 | int regno;
|
---|
218 | int offset;
|
---|
219 | } l;
|
---|
220 | short loc_type; /* Where to find value. */
|
---|
221 | short reg_size;
|
---|
222 | } ia64_reg_loc;
|
---|
223 |
|
---|
224 | /* Frame information record. */
|
---|
225 |
|
---|
226 | typedef struct ia64_frame_state
|
---|
227 | {
|
---|
228 | ia64_reg_loc gr[4]; /* gr4 to gr7. */
|
---|
229 | ia64_reg_loc fr[20]; /* fr2 to fr5, fr16 to fr31. */
|
---|
230 | ia64_reg_loc br[5]; /* br1 to br5. */
|
---|
231 | ia64_reg_loc rp;
|
---|
232 | ia64_reg_loc fpsr;
|
---|
233 | ia64_reg_loc bsp;
|
---|
234 | ia64_reg_loc bspstore;
|
---|
235 | ia64_reg_loc rnat;
|
---|
236 | ia64_reg_loc pfs;
|
---|
237 | ia64_reg_loc unat;
|
---|
238 | ia64_reg_loc lc;
|
---|
239 | ia64_reg_loc pr;
|
---|
240 | ia64_reg_loc priunat;
|
---|
241 | ia64_reg_loc sp;
|
---|
242 | ia64_reg_loc psp;
|
---|
243 | ia64_reg_loc spill_base;
|
---|
244 | void *my_sp;
|
---|
245 | void *my_bsp;
|
---|
246 | } ia64_frame_state;
|
---|
247 |
|
---|
248 |
|
---|
249 | extern unwind_info_ptr *build_ia64_frame_state (unsigned char *, ia64_frame_state *,
|
---|
250 | void *, void *);
|
---|
251 | extern void *get_real_reg_value (ia64_reg_loc *);
|
---|
252 | extern void *get_personality (unwind_info_ptr *);
|
---|
253 | extern void *get_except_table (unwind_info_ptr *);
|
---|
254 | extern void set_real_reg_value (ia64_reg_loc *, void *);
|
---|
255 | void *calc_caller_bsp (long, unsigned char *);
|
---|
256 |
|
---|
257 | #endif /* IA64_UNWIND_INFO */
|
---|
258 |
|
---|
259 | /* Note the following routines are exported interfaces from libgcc; do not
|
---|
260 | change these interfaces. Instead create new interfaces. Also note
|
---|
261 | references to these functions may be made weak in files where they
|
---|
262 | are referenced. */
|
---|
263 |
|
---|
264 | extern void __register_frame (void * );
|
---|
265 | extern void __register_frame_table (void *);
|
---|
266 | extern void __deregister_frame (void *);
|
---|
267 |
|
---|
268 | /* Called either from crtbegin.o or a static constructor to register the
|
---|
269 | unwind info for an object or translation unit, respectively. */
|
---|
270 |
|
---|
271 | extern void __register_frame_info (void *, struct object *);
|
---|
272 |
|
---|
273 | /* Similar, but BEGIN is actually a pointer to a table of unwind entries
|
---|
274 | for different translation units. Called from the file generated by
|
---|
275 | collect2. */
|
---|
276 | extern void __register_frame_info_table (void *, struct object *);
|
---|
277 |
|
---|
278 | /* Called from crtend.o to deregister the unwind info for an object. */
|
---|
279 |
|
---|
280 | extern void *__deregister_frame_info (void *);
|
---|
281 |
|
---|
282 |
|
---|