1 /* Subroutines needed for unwinding stack frames for exception handling. */
2 /* Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2009
3 Free Software Foundation, Inc.
4 Contributed by Jason Merrill <jason@cygnus.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. */
27 #ifndef GCC_UNWIND_DW2_FDE_H
28 #define GCC_UNWIND_DW2_FDE_H
31 #pragma GCC visibility push(default)
36 const void *orig_data
;
38 const struct dwarf_fde
*array
[];
47 const struct dwarf_fde
*single
;
48 struct dwarf_fde
**array
;
49 struct fde_vector
*sort
;
54 unsigned long sorted
: 1;
55 unsigned long from_array
: 1;
56 unsigned long mixed_encoding
: 1;
57 unsigned long encoding
: 8;
58 /* ??? Wish there was an easy way to detect a 64-bit host here;
59 we've got 32 bits left to play with... */
60 unsigned long count
: 21;
65 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
72 /* This is the original definition of struct object. While the struct
73 itself was opaque to users, they did know how large it was, and
74 allocate one statically in crtbegin for each DSO. Keep this around
75 so that we're aware of the static size limitations for the new struct. */
80 struct dwarf_fde
*fde_begin
;
81 struct dwarf_fde
**fde_array
;
83 struct old_object
*next
;
94 extern void __register_frame_info_bases (const void *, struct object
*,
96 extern void __register_frame_info (const void *, struct object
*);
97 extern void __register_frame (void *);
98 extern void __register_frame_info_table_bases (void *, struct object
*,
100 extern void __register_frame_info_table (void *, struct object
*);
101 extern void __register_frame_table (void *);
102 extern void *__deregister_frame_info (const void *);
103 extern void *__deregister_frame_info_bases (const void *);
104 extern void __deregister_frame (void *);
107 typedef int sword
__attribute__ ((mode (SI
)));
108 typedef unsigned int uword
__attribute__ ((mode (SI
)));
109 typedef unsigned int uaddr
__attribute__ ((mode (pointer
)));
110 typedef int saddr
__attribute__ ((mode (pointer
)));
111 typedef unsigned char ubyte
;
114 CIE - Common Information Element
115 FDE - Frame Descriptor Element
117 There is one per function, and it describes where the function code
118 is located, and what the register lifetimes and stack layout are
121 The data structures are defined in the DWARF specification, although
122 not in a very readable way (see LITERATURE).
124 Every time an exception is thrown, the code needs to locate the FDE
125 for the current function, and starts to look for exception regions
126 from that FDE. This works in a two-level search:
127 a) in a linear search, find the shared image (i.e. DLL) containing
129 b) using the FDE table for that shared object, locate the FDE using
130 binary search (which requires the sorting). */
132 /* The first few fields of a CIE. The CIE_id field is 0 for a CIE,
133 to distinguish it from a valid FDE. FDEs are aligned to an addressing
134 unit boundary, but the fields within are unaligned. */
140 unsigned char augmentation
[];
141 } __attribute__ ((packed
, aligned (__alignof__ (void *))));
143 /* The first few fields of an FDE. */
148 unsigned char pc_begin
[];
149 } __attribute__ ((packed
, aligned (__alignof__ (void *))));
151 typedef struct dwarf_fde fde
;
153 /* Locate the CIE for a given FDE. */
155 static inline const struct dwarf_cie
*
156 get_cie (const struct dwarf_fde
*f
)
158 return (const void *)&f
->CIE_delta
- f
->CIE_delta
;
161 static inline const fde
*
162 next_fde (const fde
*f
)
164 return (const fde
*) ((const char *) f
+ f
->length
+ sizeof (f
->length
));
167 extern const fde
* _Unwind_Find_FDE (void *, struct dwarf_eh_bases
*);
170 last_fde (struct object
*obj
__attribute__ ((__unused__
)), const fde
*f
)
172 #ifdef DWARF2_OBJECT_END_PTR_EXTENSION
173 return (char *)f
== obj
->fde_end
|| f
->length
== 0;
175 return f
->length
== 0;
180 #pragma GCC visibility pop
183 #endif /* unwind-dw2-fde.h */