Update.
[glibc.git] / sysdeps / generic / unwind-dw2-fde.h
blob83b4470ce5a280002a6cb123838062d34d7eb95c
1 /* Subroutines needed for unwinding stack frames for exception handling. */
2 /* Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Jason Merrill <jason@cygnus.com>.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 In addition to the permissions in the GNU General Public License, the
13 Free Software Foundation gives you unlimited permission to link the
14 compiled version of this file into combinations with other programs,
15 and to distribute those combinations without any restriction coming
16 from the use of this file. (The General Public License restrictions
17 do apply in other respects; for example, they cover modification of
18 the file, and distribution when not linked into a combine
19 executable.)
21 GNU CC is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 GNU General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with GNU CC; see the file COPYING. If not, write to
28 the Free Software Foundation, 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. */
32 struct fde_vector
34 void *orig_data;
35 size_t count;
36 struct dwarf_fde *array __flexarr;
39 #ifdef _LIBC
40 #include <gccframe.h>
41 #else
42 struct object
44 void *pc_begin;
45 void *tbase;
46 void *dbase;
47 union {
48 struct dwarf_fde *single;
49 struct dwarf_fde **array;
50 struct fde_vector *sort;
51 } u;
53 union {
54 struct {
55 unsigned long sorted : 1;
56 unsigned long from_array : 1;
57 unsigned long mixed_encoding : 1;
58 unsigned long encoding : 8;
59 /* ??? Wish there was an easy way to detect a 64-bit host here;
60 we've got 32 bits left to play with... */
61 unsigned long count : 21;
62 } b;
63 size_t i;
64 } s;
66 struct object *next;
68 #endif
70 /* This is the original definition of struct object. While the struct
71 itself was opaque to users, they did know how large it was, and
72 allocate one statically in crtbegin for each DSO. Keep this around
73 so that we're aware of the static size limitations for the new struct. */
74 struct old_object
76 void *pc_begin;
77 void *pc_end;
78 struct dwarf_fde *fde_begin;
79 struct dwarf_fde **fde_array;
80 size_t count;
81 struct old_object *next;
84 struct dwarf_eh_bases
86 void *tbase;
87 void *dbase;
88 void *func;
92 extern void __register_frame_info_bases (void *, struct object *,
93 void *, void *);
94 extern void __register_frame_info (void *, struct object *);
95 extern void __register_frame (void *);
96 extern void __register_frame_info_table_bases (void *, struct object *,
97 void *, void *);
98 extern void __register_frame_info_table (void *, struct object *);
99 extern void __register_frame_table (void *);
100 extern void *__deregister_frame_info (void *);
101 extern void *__deregister_frame_info_bases (void *);
102 extern void __deregister_frame (void *);
105 typedef int sword __attribute__ ((mode (SI)));
106 typedef unsigned int uword __attribute__ ((mode (SI)));
107 typedef unsigned int uaddr __attribute__ ((mode (pointer)));
108 typedef int saddr __attribute__ ((mode (pointer)));
109 typedef unsigned char ubyte;
111 /* Terminology:
112 CIE - Common Information Element
113 FDE - Frame Descriptor Element
115 There is one per function, and it describes where the function code
116 is located, and what the register lifetimes and stack layout are
117 within the function.
119 The data structures are defined in the DWARF specfication, although
120 not in a very readable way (see LITERATURE).
122 Every time an exception is thrown, the code needs to locate the FDE
123 for the current function, and starts to look for exception regions
124 from that FDE. This works in a two-level search:
125 a) in a linear search, find the shared image (i.e. DLL) containing
126 the PC
127 b) using the FDE table for that shared object, locate the FDE using
128 binary search (which requires the sorting). */
130 /* The first few fields of a CIE. The CIE_id field is 0 for a CIE,
131 to distinguish it from a valid FDE. FDEs are aligned to an addressing
132 unit boundary, but the fields within are unaligned. */
133 struct dwarf_cie
135 uword length;
136 sword CIE_id;
137 ubyte version;
138 unsigned char augmentation __flexarr;
139 } __attribute__ ((packed, aligned (__alignof__ (void *))));
141 /* The first few fields of an FDE. */
142 struct dwarf_fde
144 uword length;
145 sword CIE_delta;
146 unsigned char pc_begin __flexarr;
147 } __attribute__ ((packed, aligned (__alignof__ (void *))));
149 typedef struct dwarf_fde fde;
151 /* Locate the CIE for a given FDE. */
153 static inline struct dwarf_cie *
154 get_cie (struct dwarf_fde *f)
156 return (void *)&f->CIE_delta - f->CIE_delta;
159 static inline fde *
160 next_fde (fde *f)
162 return (fde *)((char *)f + f->length + sizeof (f->length));
165 extern fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);