]>
Commit | Line | Data |
---|---|---|
a51d908e | 1 | /* Debug hooks for GCC. |
8d9254fc | 2 | Copyright (C) 2001-2020 Free Software Foundation, Inc. |
a51d908e | 3 | |
9dcd6f09 NC |
4 | This program is free software; you can redistribute it and/or modify it |
5 | under the terms of the GNU General Public License as published by the | |
6 | Free Software Foundation; either version 3, or (at your option) any | |
7 | later version. | |
a51d908e | 8 | |
9dcd6f09 NC |
9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU General Public License for more details. | |
a51d908e | 13 | |
9dcd6f09 NC |
14 | You should have received a copy of the GNU General Public License |
15 | along with this program; see the file COPYING3. If not see | |
16 | <http://www.gnu.org/licenses/>. */ | |
a51d908e NB |
17 | |
18 | #ifndef GCC_DEBUG_H | |
19 | #define GCC_DEBUG_H | |
20 | ||
21 | /* This structure contains hooks for the debug information output | |
22 | functions, accessed through the global instance debug_hooks set in | |
23 | toplev.c according to command line options. */ | |
24 | struct gcc_debug_hooks | |
25 | { | |
4912a07c | 26 | /* Initialize debug output. MAIN_FILENAME is the name of the main |
e2a12aca | 27 | input file. */ |
f55ade6e | 28 | void (* init) (const char *main_filename); |
a51d908e | 29 | |
e2a12aca | 30 | /* Output debug symbols. */ |
f55ade6e | 31 | void (* finish) (const char *main_filename); |
7f905405 | 32 | |
d7438551 | 33 | /* Run cleanups necessary after early debug generation. */ |
68317985 | 34 | void (* early_finish) (const char *main_filename); |
d7438551 | 35 | |
3df9609a JJ |
36 | /* Called from cgraph_optimize before starting to assemble |
37 | functions/variables/toplevel asms. */ | |
38 | void (* assembly_start) (void); | |
39 | ||
7f905405 | 40 | /* Macro defined on line LINE with name and expansion TEXT. */ |
f55ade6e | 41 | void (* define) (unsigned int line, const char *text); |
7f905405 NB |
42 | |
43 | /* MACRO undefined on line LINE. */ | |
f55ade6e | 44 | void (* undef) (unsigned int line, const char *macro); |
7f905405 NB |
45 | |
46 | /* Record the beginning of a new source file FILE from LINE number | |
47 | in the previous one. */ | |
f55ade6e | 48 | void (* start_source_file) (unsigned int line, const char *file); |
7f905405 NB |
49 | |
50 | /* Record the resumption of a source file. LINE is the line number | |
51 | in the source file we are returning to. */ | |
f55ade6e | 52 | void (* end_source_file) (unsigned int line); |
a5a42b92 NB |
53 | |
54 | /* Record the beginning of block N, counting from 1 and not | |
e2a12aca | 55 | including the function-scope block, at LINE. */ |
f55ade6e | 56 | void (* begin_block) (unsigned int line, unsigned int n); |
a5a42b92 NB |
57 | |
58 | /* Record the end of a block. Arguments as for begin_block. */ | |
f55ade6e | 59 | void (* end_block) (unsigned int line, unsigned int n); |
e2a12aca | 60 | |
e1772ac0 NB |
61 | /* Returns nonzero if it is appropriate not to emit any debugging |
62 | information for BLOCK, because it doesn't contain any | |
63 | instructions. This may not be the case for blocks containing | |
64 | nested functions, since we may actually call such a function even | |
65 | though the BLOCK information is messed up. Defaults to true. */ | |
9678086d | 66 | bool (* ignore_block) (const_tree); |
e1772ac0 | 67 | |
497b7c47 JJ |
68 | /* Record a source file location at (FILE, LINE, COLUMN, DISCRIMINATOR). */ |
69 | void (* source_line) (unsigned int line, unsigned int column, | |
70 | const char *file, int discriminator, bool is_stmt); | |
653e276c NB |
71 | |
72 | /* Called at start of prologue code. LINE is the first line in the | |
ed5ef2e4 | 73 | function. */ |
497b7c47 JJ |
74 | void (* begin_prologue) (unsigned int line, unsigned int column, |
75 | const char *file); | |
653e276c NB |
76 | |
77 | /* Called at end of prologue code. LINE is the first line in the | |
78 | function. */ | |
f55ade6e | 79 | void (* end_prologue) (unsigned int line, const char *file); |
e2a12aca | 80 | |
67ad2ae7 DR |
81 | /* Called at beginning of epilogue code. */ |
82 | void (* begin_epilogue) (unsigned int line, const char *file); | |
83 | ||
e2a12aca | 84 | /* Record end of epilogue code. */ |
f55ade6e | 85 | void (* end_epilogue) (unsigned int line, const char *file); |
e2a12aca | 86 | |
653e276c | 87 | /* Called at start of function DECL, before it is declared. */ |
f55ade6e | 88 | void (* begin_function) (tree decl); |
653e276c | 89 | |
e2a12aca | 90 | /* Record end of function. LINE is highest line number in function. */ |
f55ade6e | 91 | void (* end_function) (unsigned int line); |
2b85879e | 92 | |
881a5e60 PMR |
93 | /* Register UNIT as the main translation unit. Called from front-ends when |
94 | they create their main translation unit. */ | |
95 | void (* register_main_translation_unit) (tree); | |
96 | ||
2b85879e NB |
97 | /* Debug information for a function DECL. This might include the |
98 | function name (a symbol), its parameters, and the block that | |
99 | makes up the function's body, and the local variables of the | |
d7438551 AH |
100 | function. |
101 | ||
102 | This is only called for FUNCTION_DECLs. It is part of the late | |
103 | debug pass and is called from rest_of_handle_final. | |
104 | ||
105 | Location information is available at this point. | |
106 | ||
107 | See the documentation for early_global_decl and late_global_decl | |
108 | for other entry points into the debugging back-ends for DECLs. */ | |
f55ade6e | 109 | void (* function_decl) (tree decl); |
2b85879e | 110 | |
d7438551 AH |
111 | /* Debug information for a global DECL. Called from the parser |
112 | after the parsing process has finished. | |
113 | ||
114 | This gets called for both variables and functions. | |
115 | ||
116 | Location information is not available at this point, but it is a | |
117 | good probe point to get access to symbols before they get | |
118 | optimized away. | |
119 | ||
120 | This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up | |
121 | to the hook to use what it needs. */ | |
122 | void (* early_global_decl) (tree decl); | |
123 | ||
124 | /* Augment debug information generated by early_global_decl with | |
125 | more complete debug info (if applicable). Called from toplev.c | |
126 | after the compilation proper has finished and cgraph information | |
127 | is available. | |
128 | ||
129 | This gets called for both variables and functions. | |
130 | ||
131 | Location information is usually available at this point, unless | |
132 | the hook is being called for a decl that has been optimized away. | |
133 | ||
134 | This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up | |
135 | to the hook to use what it needs. */ | |
136 | void (* late_global_decl) (tree decl); | |
2b85879e | 137 | |
21d13d83 ZW |
138 | /* Debug information for a type DECL. Called from toplev.c after |
139 | compilation proper, also from various language front ends to | |
140 | record built-in types. The second argument is properly a | |
141 | boolean, which indicates whether or not the type is a "local" | |
142 | type as determined by the language. (It's not a boolean for | |
143 | legacy reasons.) */ | |
144 | void (* type_decl) (tree decl, int local); | |
145 | ||
6097b0c3 | 146 | /* Debug information for imported modules and declarations. */ |
a64f5186 | 147 | void (* imported_module_or_decl) (tree decl, tree name, |
e071b767 JJ |
148 | tree context, bool child, |
149 | bool implicit); | |
6097b0c3 | 150 | |
1ea85365 RB |
151 | /* Return true if a DIE for the tree is available and return a symbol |
152 | and offset that can be used to refer to it externally. */ | |
153 | bool (* die_ref_for_decl) (tree, const char **, unsigned HOST_WIDE_INT *); | |
154 | ||
155 | /* Early debug information for the tree is available at symbol plus | |
156 | offset externally. */ | |
157 | void (* register_external_die) (tree, const char *, unsigned HOST_WIDE_INT); | |
158 | ||
2b85879e NB |
159 | /* DECL is an inline function, whose body is present, but which is |
160 | not being output at this point. */ | |
f55ade6e | 161 | void (* deferred_inline_function) (tree decl); |
e1772ac0 NB |
162 | |
163 | /* DECL is an inline function which is about to be emitted out of | |
164 | line. The hook is useful to, e.g., emit abstract debug info for | |
165 | the inline before it gets mangled by optimization. */ | |
f55ade6e | 166 | void (* outlining_inline_function) (tree decl); |
e1772ac0 NB |
167 | |
168 | /* Called from final_scan_insn for any CODE_LABEL insn whose | |
169 | LABEL_NAME is non-null. */ | |
f630fc6a | 170 | void (* label) (rtx_code_label *); |
33b49800 | 171 | |
f55ade6e | 172 | /* Called after the start and before the end of writing a PCH file. |
33b49800 | 173 | The parameter is 0 if after the start, 1 if before the end. */ |
f55ade6e | 174 | void (* handle_pch) (unsigned int); |
014a1138 JZ |
175 | |
176 | /* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note. */ | |
f630fc6a | 177 | void (* var_location) (rtx_insn *); |
9e9945c5 | 178 | |
102d484d AO |
179 | /* Called from final_scan_insn for any NOTE_INSN_INLINE_ENTRY note. */ |
180 | void (* inline_entry) (tree block); | |
181 | ||
986ccd21 PMR |
182 | /* Called from finalize_size_functions for size functions so that their body |
183 | can be encoded in the debug info to describe the layout of variable-length | |
184 | structures. */ | |
185 | void (* size_function) (tree decl); | |
186 | ||
87c8b4be CT |
187 | /* Called from final_scan_insn if there is a switch between hot and cold |
188 | text sections. */ | |
189 | void (* switch_text_section) (void); | |
190 | ||
af04e659 CM |
191 | /* Called from grokdeclarator. Replaces the anonymous name with the |
192 | type name. */ | |
a417cdd9 CM |
193 | void (* set_name) (tree, tree); |
194 | ||
9e9945c5 DB |
195 | /* This is 1 if the debug writer wants to see start and end commands for the |
196 | main source files, and 0 otherwise. */ | |
197 | int start_end_main_source_file; | |
c6a13190 ILT |
198 | |
199 | /* The type of symtab field used by these debug hooks. This is one | |
200 | of the TYPE_SYMTAB_IS_xxx values defined in tree.h. */ | |
201 | int tree_type_symtab_field; | |
a51d908e NB |
202 | }; |
203 | ||
54b6670a | 204 | extern const struct gcc_debug_hooks *debug_hooks; |
a51d908e NB |
205 | |
206 | /* The do-nothing hooks. */ | |
f55ade6e AJ |
207 | extern void debug_nothing_void (void); |
208 | extern void debug_nothing_charstar (const char *); | |
497b7c47 JJ |
209 | extern void debug_nothing_int_int_charstar (unsigned int, unsigned int, |
210 | const char *); | |
f55ade6e | 211 | extern void debug_nothing_int_charstar (unsigned int, const char *); |
497b7c47 JJ |
212 | extern void debug_nothing_int_int_charstar_int_bool (unsigned int, |
213 | unsigned int, | |
214 | const char *, | |
215 | int, bool); | |
f55ade6e AJ |
216 | extern void debug_nothing_int (unsigned int); |
217 | extern void debug_nothing_int_int (unsigned int, unsigned int); | |
218 | extern void debug_nothing_tree (tree); | |
a417cdd9 | 219 | extern void debug_nothing_tree_tree (tree, tree); |
21d13d83 | 220 | extern void debug_nothing_tree_int (tree, int); |
e071b767 JJ |
221 | extern void debug_nothing_tree_tree_tree_bool_bool (tree, tree, tree, |
222 | bool, bool); | |
9678086d | 223 | extern bool debug_true_const_tree (const_tree); |
f630fc6a DM |
224 | extern void debug_nothing_rtx_insn (rtx_insn *); |
225 | extern void debug_nothing_rtx_code_label (rtx_code_label *); | |
1ea85365 RB |
226 | extern bool debug_false_tree_charstarstar_uhwistar (tree, const char **, |
227 | unsigned HOST_WIDE_INT *); | |
228 | extern void debug_nothing_tree_charstar_uhwi (tree, const char *, | |
229 | unsigned HOST_WIDE_INT); | |
a51d908e | 230 | |
7f905405 | 231 | /* Hooks for various debug formats. */ |
54b6670a KG |
232 | extern const struct gcc_debug_hooks do_nothing_debug_hooks; |
233 | extern const struct gcc_debug_hooks dbx_debug_hooks; | |
54b6670a | 234 | extern const struct gcc_debug_hooks xcoff_debug_hooks; |
54b6670a | 235 | extern const struct gcc_debug_hooks dwarf2_debug_hooks; |
c9665100 | 236 | extern const struct gcc_debug_hooks dwarf2_lineno_debug_hooks; |
54b6670a | 237 | extern const struct gcc_debug_hooks vmsdbg_debug_hooks; |
a51d908e | 238 | |
e2a12aca NB |
239 | /* Dwarf2 frame information. */ |
240 | ||
497b7c47 JJ |
241 | extern void dwarf2out_begin_prologue (unsigned int, unsigned int, |
242 | const char *); | |
67ad2ae7 DR |
243 | extern void dwarf2out_vms_end_prologue (unsigned int, const char *); |
244 | extern void dwarf2out_vms_begin_epilogue (unsigned int, const char *); | |
f55ade6e | 245 | extern void dwarf2out_end_epilogue (unsigned int, const char *); |
f55ade6e | 246 | extern void dwarf2out_frame_finish (void); |
2f02b2c2 | 247 | extern bool dwarf2out_do_eh_frame (void); |
7644b3c7 RH |
248 | extern bool dwarf2out_do_frame (void); |
249 | extern bool dwarf2out_do_cfi_asm (void); | |
a4b6974e | 250 | extern void dwarf2out_switch_text_section (void); |
924c9e3e AO |
251 | extern bool dwarf2out_default_as_loc_support (void); |
252 | extern bool dwarf2out_default_as_locview_support (void); | |
7a0c8d71 | 253 | |
c6a13190 ILT |
254 | /* For -fdump-go-spec. */ |
255 | ||
256 | extern const struct gcc_debug_hooks * | |
257 | dump_go_spec_init (const char *, const struct gcc_debug_hooks *); | |
258 | ||
fa6fd7b7 AO |
259 | /* Instance discriminator mapping table. See final.c. */ |
260 | typedef hash_map<const_tree, int> decl_to_instance_map_t; | |
261 | extern decl_to_instance_map_t *decl_to_instance_map; | |
262 | ||
263 | /* Allocate decl_to_instance_map with COUNT slots to begin wtih, if it | |
264 | * hasn't been allocated yet. */ | |
265 | ||
266 | static inline decl_to_instance_map_t * | |
267 | maybe_create_decl_to_instance_map (int count = 13) | |
268 | { | |
269 | if (!decl_to_instance_map) | |
270 | decl_to_instance_map = new decl_to_instance_map_t (count); | |
271 | return decl_to_instance_map; | |
272 | } | |
273 | ||
a51d908e | 274 | #endif /* !GCC_DEBUG_H */ |