0
|
1 /* Exception Handling interface routines.
|
|
2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
|
3 2007, 2008 Free Software Foundation, Inc.
|
|
4 Contributed by Mike Stump <mrs@cygnus.com>.
|
|
5
|
|
6 This file is part of GCC.
|
|
7
|
|
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
|
|
11 version.
|
|
12
|
|
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
|
|
16 for more details.
|
|
17
|
|
18 You should have received a copy of the GNU General Public License
|
|
19 along with GCC; see the file COPYING3. If not see
|
|
20 <http://www.gnu.org/licenses/>. */
|
|
21
|
|
22
|
|
23 struct function;
|
|
24
|
|
25 /* Per-function EH data. Used only in except.c, but GC and others
|
|
26 manipulate pointers to the opaque type. */
|
|
27 struct eh_status;
|
|
28
|
|
29 /* Internal structure describing a region. */
|
|
30 struct eh_region;
|
|
31
|
|
32 /* Test: is exception handling turned on? */
|
|
33 extern int doing_eh (int);
|
|
34
|
|
35 /* Note that the current EH region (if any) may contain a throw, or a
|
|
36 call to a function which itself may contain a throw. */
|
|
37 extern void note_eh_region_may_contain_throw (struct eh_region *);
|
|
38
|
|
39 /* Invokes CALLBACK for every exception handler label. Only used by old
|
|
40 loop hackery; should not be used by new code. */
|
|
41 extern void for_each_eh_label (void (*) (rtx));
|
|
42
|
|
43 /* Invokes CALLBACK for every exception region in the current function. */
|
|
44 extern void for_each_eh_region (void (*) (struct eh_region *));
|
|
45
|
|
46 /* Determine if the given INSN can throw an exception. */
|
|
47 extern bool can_throw_internal_1 (int, bool);
|
|
48 extern bool can_throw_internal (const_rtx);
|
|
49 extern bool can_throw_external_1 (int, bool);
|
|
50 extern bool can_throw_external (const_rtx);
|
|
51
|
|
52 /* Set TREE_NOTHROW and cfun->all_throwers_are_sibcalls. */
|
|
53 extern unsigned int set_nothrow_function_flags (void);
|
|
54
|
|
55 /* After initial rtl generation, call back to finish generating
|
|
56 exception support code. */
|
|
57 extern void finish_eh_generation (void);
|
|
58
|
|
59 extern void init_eh (void);
|
|
60 extern void init_eh_for_function (void);
|
|
61
|
|
62 extern rtx reachable_handlers (rtx);
|
|
63 extern void maybe_remove_eh_handler (rtx);
|
|
64
|
|
65 extern void convert_from_eh_region_ranges (void);
|
|
66 extern unsigned int convert_to_eh_region_ranges (void);
|
|
67 extern void find_exception_handler_labels (void);
|
|
68 extern bool current_function_has_exception_handlers (void);
|
|
69 extern void output_function_exception_table (const char *);
|
|
70
|
|
71 extern void expand_builtin_unwind_init (void);
|
|
72 extern rtx expand_builtin_eh_return_data_regno (tree);
|
|
73 extern rtx expand_builtin_extract_return_addr (tree);
|
|
74 extern void expand_builtin_init_dwarf_reg_sizes (tree);
|
|
75 extern rtx expand_builtin_frob_return_addr (tree);
|
|
76 extern rtx expand_builtin_dwarf_sp_column (void);
|
|
77 extern void expand_builtin_eh_return (tree, tree);
|
|
78 extern void expand_eh_return (void);
|
|
79 extern rtx expand_builtin_extend_pointer (tree);
|
|
80 extern rtx get_exception_pointer (void);
|
|
81 extern rtx get_exception_filter (void);
|
|
82 typedef tree (*duplicate_eh_regions_map) (tree, void *);
|
|
83 extern int duplicate_eh_regions (struct function *, duplicate_eh_regions_map,
|
|
84 void *, int, int);
|
|
85
|
|
86 extern void sjlj_emit_function_exit_after (rtx);
|
|
87 extern void default_init_unwind_resume_libfunc (void);
|
|
88
|
|
89 extern struct eh_region *gen_eh_region_cleanup (struct eh_region *,
|
|
90 struct eh_region *);
|
|
91 extern struct eh_region *gen_eh_region_try (struct eh_region *);
|
|
92 extern struct eh_region *gen_eh_region_catch (struct eh_region *, tree);
|
|
93 extern struct eh_region *gen_eh_region_allowed (struct eh_region *, tree);
|
|
94 extern struct eh_region *gen_eh_region_must_not_throw (struct eh_region *);
|
|
95 extern int get_eh_region_number (struct eh_region *);
|
|
96 extern bool get_eh_region_may_contain_throw (struct eh_region *);
|
|
97 extern tree get_eh_region_tree_label (struct eh_region *);
|
|
98 extern void set_eh_region_tree_label (struct eh_region *, tree);
|
|
99
|
|
100 extern void foreach_reachable_handler (int, bool,
|
|
101 void (*) (struct eh_region *, void *),
|
|
102 void *);
|
|
103
|
|
104 extern void collect_eh_region_array (void);
|
|
105 extern void expand_resx_expr (tree);
|
|
106 extern void verify_eh_tree (struct function *);
|
|
107 extern void dump_eh_tree (FILE *, struct function *);
|
|
108 extern bool eh_region_outer_p (struct function *, int, int);
|
|
109 extern int eh_region_outermost (struct function *, int, int);
|
|
110
|
|
111 /* If non-NULL, this is a function that returns an expression to be
|
|
112 executed if an unhandled exception is propagated out of a cleanup
|
|
113 region. For example, in C++, an exception thrown by a destructor
|
|
114 during stack unwinding is required to result in a call to
|
|
115 `std::terminate', so the C++ version of this function returns a
|
|
116 CALL_EXPR for `std::terminate'. */
|
|
117 extern gimple (*lang_protect_cleanup_actions) (void);
|
|
118
|
|
119 /* Return true if type A catches type B. */
|
|
120 extern int (*lang_eh_type_covers) (tree a, tree b);
|
|
121
|
|
122 /* Map a type to a runtime object to match type. */
|
|
123 extern tree (*lang_eh_runtime_type) (tree);
|
|
124
|
|
125
|
|
126 /* Just because the user configured --with-sjlj-exceptions=no doesn't
|
|
127 mean that we can use call frame exceptions. Detect that the target
|
|
128 has appropriate support. */
|
|
129
|
|
130 #ifndef MUST_USE_SJLJ_EXCEPTIONS
|
|
131 # if defined (EH_RETURN_DATA_REGNO) \
|
|
132 && (defined (TARGET_UNWIND_INFO) \
|
|
133 || (DWARF2_UNWIND_INFO \
|
|
134 && (defined (EH_RETURN_HANDLER_RTX) \
|
|
135 || defined (HAVE_eh_return))))
|
|
136 # define MUST_USE_SJLJ_EXCEPTIONS 0
|
|
137 # else
|
|
138 # define MUST_USE_SJLJ_EXCEPTIONS 1
|
|
139 # endif
|
|
140 #endif
|
|
141
|
|
142 #ifdef CONFIG_SJLJ_EXCEPTIONS
|
|
143 # if CONFIG_SJLJ_EXCEPTIONS == 1
|
|
144 # define USING_SJLJ_EXCEPTIONS 1
|
|
145 # endif
|
|
146 # if CONFIG_SJLJ_EXCEPTIONS == 0
|
|
147 # define USING_SJLJ_EXCEPTIONS 0
|
|
148 # if !defined(EH_RETURN_DATA_REGNO)
|
|
149 #error "EH_RETURN_DATA_REGNO required"
|
|
150 # endif
|
|
151 # if ! (defined(TARGET_UNWIND_INFO) || DWARF2_UNWIND_INFO)
|
|
152 #error "{DWARF2,TARGET}_UNWIND_INFO required"
|
|
153 # endif
|
|
154 # if !defined(TARGET_UNWIND_INFO) \
|
|
155 && !(defined(EH_RETURN_HANDLER_RTX) || defined(HAVE_eh_return))
|
|
156 #error "EH_RETURN_HANDLER_RTX or eh_return required"
|
|
157 # endif
|
|
158 /* Usually the above error checks will have already triggered an
|
|
159 error, but backends may set MUST_USE_SJLJ_EXCEPTIONS for their own
|
|
160 reasons. */
|
|
161 # if MUST_USE_SJLJ_EXCEPTIONS
|
|
162 #error "Must use SJLJ exceptions but configured not to"
|
|
163 # endif
|
|
164 # endif
|
|
165 #else
|
|
166 # define USING_SJLJ_EXCEPTIONS MUST_USE_SJLJ_EXCEPTIONS
|
|
167 #endif
|
|
168
|
|
169 struct throw_stmt_node GTY(())
|
|
170 {
|
|
171 gimple stmt;
|
|
172 int region_nr;
|
|
173 };
|
|
174
|
|
175 extern struct htab *get_eh_throw_stmt_table (struct function *);
|
|
176 extern void set_eh_throw_stmt_table (struct function *, struct htab *);
|