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