1 /* Debug hooks for GCC.
2 Copyright (C) 2001-2016 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
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/>. */
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
26 /* Initialize debug output. MAIN_FILENAME is the name of the main
28 void (* init
) (const char *main_filename
);
30 /* Output debug symbols. */
31 void (* finish
) (const char *main_filename
);
33 /* Run cleanups necessary after early debug generation. */
34 void (* early_finish
) (const char *main_filename
);
36 /* Called from cgraph_optimize before starting to assemble
37 functions/variables/toplevel asms. */
38 void (* assembly_start
) (void);
40 /* Macro defined on line LINE with name and expansion TEXT. */
41 void (* define
) (unsigned int line
, const char *text
);
43 /* MACRO undefined on line LINE. */
44 void (* undef
) (unsigned int line
, const char *macro
);
46 /* Record the beginning of a new source file FILE from LINE number
47 in the previous one. */
48 void (* start_source_file
) (unsigned int line
, const char *file
);
50 /* Record the resumption of a source file. LINE is the line number
51 in the source file we are returning to. */
52 void (* end_source_file
) (unsigned int line
);
54 /* Record the beginning of block N, counting from 1 and not
55 including the function-scope block, at LINE. */
56 void (* begin_block
) (unsigned int line
, unsigned int n
);
58 /* Record the end of a block. Arguments as for begin_block. */
59 void (* end_block
) (unsigned int line
, unsigned int n
);
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. */
66 bool (* ignore_block
) (const_tree
);
68 /* Record a source file location at (FILE, LINE, DISCRIMINATOR). */
69 void (* source_line
) (unsigned int line
, const char *file
,
70 int discriminator
, bool is_stmt
);
72 /* Called at start of prologue code. LINE is the first line in the
74 void (* begin_prologue
) (unsigned int line
, const char *file
);
76 /* Called at end of prologue code. LINE is the first line in the
78 void (* end_prologue
) (unsigned int line
, const char *file
);
80 /* Called at beginning of epilogue code. */
81 void (* begin_epilogue
) (unsigned int line
, const char *file
);
83 /* Record end of epilogue code. */
84 void (* end_epilogue
) (unsigned int line
, const char *file
);
86 /* Called at start of function DECL, before it is declared. */
87 void (* begin_function
) (tree decl
);
89 /* Record end of function. LINE is highest line number in function. */
90 void (* end_function
) (unsigned int line
);
92 /* Register UNIT as the main translation unit. Called from front-ends when
93 they create their main translation unit. */
94 void (* register_main_translation_unit
) (tree
);
96 /* Debug information for a function DECL. This might include the
97 function name (a symbol), its parameters, and the block that
98 makes up the function's body, and the local variables of the
101 This is only called for FUNCTION_DECLs. It is part of the late
102 debug pass and is called from rest_of_handle_final.
104 Location information is available at this point.
106 See the documentation for early_global_decl and late_global_decl
107 for other entry points into the debugging back-ends for DECLs. */
108 void (* function_decl
) (tree decl
);
110 /* Debug information for a global DECL. Called from the parser
111 after the parsing process has finished.
113 This gets called for both variables and functions.
115 Location information is not available at this point, but it is a
116 good probe point to get access to symbols before they get
119 This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up
120 to the hook to use what it needs. */
121 void (* early_global_decl
) (tree decl
);
123 /* Augment debug information generated by early_global_decl with
124 more complete debug info (if applicable). Called from toplev.c
125 after the compilation proper has finished and cgraph information
128 This gets called for both variables and functions.
130 Location information is usually available at this point, unless
131 the hook is being called for a decl that has been optimized away.
133 This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up
134 to the hook to use what it needs. */
135 void (* late_global_decl
) (tree decl
);
137 /* Debug information for a type DECL. Called from toplev.c after
138 compilation proper, also from various language front ends to
139 record built-in types. The second argument is properly a
140 boolean, which indicates whether or not the type is a "local"
141 type as determined by the language. (It's not a boolean for
143 void (* type_decl
) (tree decl
, int local
);
145 /* Debug information for imported modules and declarations. */
146 void (* imported_module_or_decl
) (tree decl
, tree name
,
147 tree context
, bool child
);
149 /* DECL is an inline function, whose body is present, but which is
150 not being output at this point. */
151 void (* deferred_inline_function
) (tree decl
);
153 /* DECL is an inline function which is about to be emitted out of
154 line. The hook is useful to, e.g., emit abstract debug info for
155 the inline before it gets mangled by optimization. */
156 void (* outlining_inline_function
) (tree decl
);
158 /* Called from final_scan_insn for any CODE_LABEL insn whose
159 LABEL_NAME is non-null. */
160 void (* label
) (rtx_code_label
*);
162 /* Called after the start and before the end of writing a PCH file.
163 The parameter is 0 if after the start, 1 if before the end. */
164 void (* handle_pch
) (unsigned int);
166 /* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note. */
167 void (* var_location
) (rtx_insn
*);
169 /* Called from finalize_size_functions for size functions so that their body
170 can be encoded in the debug info to describe the layout of variable-length
172 void (* size_function
) (tree decl
);
174 /* Called from final_scan_insn if there is a switch between hot and cold
176 void (* switch_text_section
) (void);
178 /* Called from grokdeclarator. Replaces the anonymous name with the
180 void (* set_name
) (tree
, tree
);
182 /* This is 1 if the debug writer wants to see start and end commands for the
183 main source files, and 0 otherwise. */
184 int start_end_main_source_file
;
186 /* The type of symtab field used by these debug hooks. This is one
187 of the TYPE_SYMTAB_IS_xxx values defined in tree.h. */
188 int tree_type_symtab_field
;
191 extern const struct gcc_debug_hooks
*debug_hooks
;
193 /* The do-nothing hooks. */
194 extern void debug_nothing_void (void);
195 extern void debug_nothing_charstar (const char *);
196 extern void debug_nothing_int_charstar (unsigned int, const char *);
197 extern void debug_nothing_int_charstar_int_bool (unsigned int, const char *,
199 extern void debug_nothing_int (unsigned int);
200 extern void debug_nothing_int_int (unsigned int, unsigned int);
201 extern void debug_nothing_tree (tree
);
202 extern void debug_nothing_tree_tree (tree
, tree
);
203 extern void debug_nothing_tree_int (tree
, int);
204 extern void debug_nothing_tree_tree_tree_bool (tree
, tree
, tree
, bool);
205 extern bool debug_true_const_tree (const_tree
);
206 extern void debug_nothing_rtx_insn (rtx_insn
*);
207 extern void debug_nothing_rtx_code_label (rtx_code_label
*);
209 /* Hooks for various debug formats. */
210 extern const struct gcc_debug_hooks do_nothing_debug_hooks
;
211 extern const struct gcc_debug_hooks dbx_debug_hooks
;
212 extern const struct gcc_debug_hooks sdb_debug_hooks
;
213 extern const struct gcc_debug_hooks xcoff_debug_hooks
;
214 extern const struct gcc_debug_hooks dwarf2_debug_hooks
;
215 extern const struct gcc_debug_hooks dwarf2_lineno_debug_hooks
;
216 extern const struct gcc_debug_hooks vmsdbg_debug_hooks
;
218 /* Dwarf2 frame information. */
220 extern void dwarf2out_begin_prologue (unsigned int, const char *);
221 extern void dwarf2out_vms_end_prologue (unsigned int, const char *);
222 extern void dwarf2out_vms_begin_epilogue (unsigned int, const char *);
223 extern void dwarf2out_end_epilogue (unsigned int, const char *);
224 extern void dwarf2out_frame_finish (void);
225 /* Decide whether we want to emit frame unwind information for the current
227 extern bool dwarf2out_do_frame (void);
228 extern bool dwarf2out_do_cfi_asm (void);
229 extern void dwarf2out_switch_text_section (void);
231 const char *remap_debug_filename (const char *);
232 void add_debug_prefix_map (const char *);
234 /* For -fdump-go-spec. */
236 extern const struct gcc_debug_hooks
*
237 dump_go_spec_init (const char *, const struct gcc_debug_hooks
*);
239 #endif /* !GCC_DEBUG_H */