aix: Switch AIX configurtion to DWARF2 debugging
[official-gcc.git] / gcc / debug.h
blobcd265ffbc99b548f824a53211078d8fc511d0014
1 /* Debug hooks for GCC.
2 Copyright (C) 2001-2021 Free Software Foundation, Inc.
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.
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.
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/>. */
18 #ifndef GCC_DEBUG_H
19 #define GCC_DEBUG_H
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 /* 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. */
28 struct gcc_debug_hooks
30 /* Initialize debug output. MAIN_FILENAME is the name of the main
31 input file. */
32 void (* init) (const char *main_filename);
34 /* Output debug symbols. */
35 void (* finish) (const char *main_filename);
37 /* Run cleanups necessary after early debug generation. */
38 void (* early_finish) (const char *main_filename);
40 /* Called from cgraph_optimize before starting to assemble
41 functions/variables/toplevel asms. */
42 void (* assembly_start) (void);
44 /* Macro defined on line LINE with name and expansion TEXT. */
45 void (* define) (unsigned int line, const char *text);
47 /* MACRO undefined on line LINE. */
48 void (* undef) (unsigned int line, const char *macro);
50 /* Record the beginning of a new source file FILE from LINE number
51 in the previous one. */
52 void (* start_source_file) (unsigned int line, const char *file);
54 /* Record the resumption of a source file. LINE is the line number
55 in the source file we are returning to. */
56 void (* end_source_file) (unsigned int line);
58 /* Record the beginning of block N, counting from 1 and not
59 including the function-scope block, at LINE. */
60 void (* begin_block) (unsigned int line, unsigned int n);
62 /* Record the end of a block. Arguments as for begin_block. */
63 void (* end_block) (unsigned int line, unsigned int n);
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. */
70 bool (* ignore_block) (const_tree);
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);
76 /* Called at start of prologue code. LINE is the first line in the
77 function. */
78 void (* begin_prologue) (unsigned int line, unsigned int column,
79 const char *file);
81 /* Called at end of prologue code. LINE is the first line in the
82 function. */
83 void (* end_prologue) (unsigned int line, const char *file);
85 /* Called at beginning of epilogue code. */
86 void (* begin_epilogue) (unsigned int line, const char *file);
88 /* Record end of epilogue code. */
89 void (* end_epilogue) (unsigned int line, const char *file);
91 /* Called at start of function DECL, before it is declared. */
92 void (* begin_function) (tree decl);
94 /* Record end of function. LINE is highest line number in function. */
95 void (* end_function) (unsigned int line);
97 /* Register UNIT as the main translation unit. Called from front-ends when
98 they create their main translation unit. */
99 void (* register_main_translation_unit) (tree);
101 /* Debug information for a function DECL. This might include the
102 function name (a symbol), its parameters, and the block that
103 makes up the function's body, and the local variables of the
104 function.
106 This is only called for FUNCTION_DECLs. It is part of the late
107 debug pass and is called from rest_of_handle_final.
109 Location information is available at this point.
111 See the documentation for early_global_decl and late_global_decl
112 for other entry points into the debugging back-ends for DECLs. */
113 void (* function_decl) (tree decl);
115 /* Debug information for a global DECL. Called from the parser
116 after the parsing process has finished.
118 This gets called for both variables and functions.
120 Location information is not available at this point, but it is a
121 good probe point to get access to symbols before they get
122 optimized away.
124 This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up
125 to the hook to use what it needs. */
126 void (* early_global_decl) (tree decl);
128 /* Augment debug information generated by early_global_decl with
129 more complete debug info (if applicable). Called from toplev.c
130 after the compilation proper has finished and cgraph information
131 is available.
133 This gets called for both variables and functions.
135 Location information is usually available at this point, unless
136 the hook is being called for a decl that has been optimized away.
138 This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up
139 to the hook to use what it needs. */
140 void (* late_global_decl) (tree decl);
142 /* Debug information for a type DECL. Called from toplev.c after
143 compilation proper, also from various language front ends to
144 record built-in types. The second argument is properly a
145 boolean, which indicates whether or not the type is a "local"
146 type as determined by the language. (It's not a boolean for
147 legacy reasons.) */
148 void (* type_decl) (tree decl, int local);
150 /* Debug information for imported modules and declarations. */
151 void (* imported_module_or_decl) (tree decl, tree name,
152 tree context, bool child,
153 bool implicit);
155 /* Return true if a DIE for the tree is available and return a symbol
156 and offset that can be used to refer to it externally. */
157 bool (* die_ref_for_decl) (tree, const char **, unsigned HOST_WIDE_INT *);
159 /* Early debug information for the tree is available at symbol plus
160 offset externally. */
161 void (* register_external_die) (tree, const char *, unsigned HOST_WIDE_INT);
163 /* DECL is an inline function, whose body is present, but which is
164 not being output at this point. */
165 void (* deferred_inline_function) (tree decl);
167 /* DECL is an inline function which is about to be emitted out of
168 line. The hook is useful to, e.g., emit abstract debug info for
169 the inline before it gets mangled by optimization. */
170 void (* outlining_inline_function) (tree decl);
172 /* Called from final_scan_insn for any CODE_LABEL insn whose
173 LABEL_NAME is non-null. */
174 void (* label) (rtx_code_label *);
176 /* Called after the start and before the end of writing a PCH file.
177 The parameter is 0 if after the start, 1 if before the end. */
178 void (* handle_pch) (unsigned int);
180 /* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note. */
181 void (* var_location) (rtx_insn *);
183 /* Called from final_scan_insn for any NOTE_INSN_INLINE_ENTRY note. */
184 void (* inline_entry) (tree block);
186 /* Called from finalize_size_functions for size functions so that their body
187 can be encoded in the debug info to describe the layout of variable-length
188 structures. */
189 void (* size_function) (tree decl);
191 /* Called from final_scan_insn if there is a switch between hot and cold
192 text sections. */
193 void (* switch_text_section) (void);
195 /* Called from grokdeclarator. Replaces the anonymous name with the
196 type name. */
197 void (* set_name) (tree, tree);
199 /* This is 1 if the debug writer wants to see start and end commands for the
200 main source files, and 0 otherwise. */
201 int start_end_main_source_file;
203 /* The type of symtab field used by these debug hooks. This is one
204 of the TYPE_SYMTAB_IS_xxx values defined in tree.h. */
205 int tree_type_symtab_field;
208 extern const struct gcc_debug_hooks *debug_hooks;
210 /* The do-nothing hooks. */
211 extern void debug_nothing_void (void);
212 extern void debug_nothing_charstar (const char *);
213 extern void debug_nothing_int_int_charstar (unsigned int, unsigned int,
214 const char *);
215 extern void debug_nothing_int_charstar (unsigned int, const char *);
216 extern void debug_nothing_int_int_charstar_int_bool (unsigned int,
217 unsigned int,
218 const char *,
219 int, bool);
220 extern void debug_nothing_int (unsigned int);
221 extern void debug_nothing_int_int (unsigned int, unsigned int);
222 extern void debug_nothing_tree (tree);
223 extern void debug_nothing_tree_tree (tree, tree);
224 extern void debug_nothing_tree_int (tree, int);
225 extern void debug_nothing_tree_tree_tree_bool_bool (tree, tree, tree,
226 bool, bool);
227 extern bool debug_true_const_tree (const_tree);
228 extern void debug_nothing_rtx_insn (rtx_insn *);
229 extern void debug_nothing_rtx_code_label (rtx_code_label *);
230 extern bool debug_false_tree_charstarstar_uhwistar (tree, const char **,
231 unsigned HOST_WIDE_INT *);
232 extern void debug_nothing_tree_charstar_uhwi (tree, const char *,
233 unsigned HOST_WIDE_INT);
235 /* Hooks for various debug formats. */
236 extern const struct gcc_debug_hooks do_nothing_debug_hooks;
237 extern const struct gcc_debug_hooks dbx_debug_hooks;
238 extern const struct gcc_debug_hooks xcoff_debug_hooks;
239 extern const struct gcc_debug_hooks dwarf2_debug_hooks;
240 extern const struct gcc_debug_hooks dwarf2_lineno_debug_hooks;
241 extern const struct gcc_debug_hooks vmsdbg_debug_hooks;
243 /* Dwarf2 frame information. */
245 extern void dwarf2out_begin_prologue (unsigned int, unsigned int,
246 const char *);
247 extern void dwarf2out_vms_end_prologue (unsigned int, const char *);
248 extern void dwarf2out_vms_begin_epilogue (unsigned int, const char *);
249 extern void dwarf2out_end_epilogue (unsigned int, const char *);
250 extern void dwarf2out_frame_finish (void);
251 extern bool dwarf2out_do_eh_frame (void);
252 extern bool dwarf2out_do_frame (void);
253 extern bool dwarf2out_do_cfi_asm (void);
254 extern void dwarf2out_switch_text_section (void);
255 extern bool dwarf2out_default_as_loc_support (void);
256 extern bool dwarf2out_default_as_locview_support (void);
258 /* For -fdump-go-spec. */
260 extern const struct gcc_debug_hooks *
261 dump_go_spec_init (const char *, const struct gcc_debug_hooks *);
263 /* Instance discriminator mapping table. See final.c. */
264 typedef hash_map<const_tree, int> decl_to_instance_map_t;
265 extern decl_to_instance_map_t *decl_to_instance_map;
267 /* Allocate decl_to_instance_map with COUNT slots to begin wtih, if it
268 * hasn't been allocated yet. */
270 static inline decl_to_instance_map_t *
271 maybe_create_decl_to_instance_map (int count = 13)
273 if (!decl_to_instance_map)
274 decl_to_instance_map = new decl_to_instance_map_t (count);
275 return decl_to_instance_map;
278 #endif /* !GCC_DEBUG_H */