1 /* Debug hooks for GCC.
2 Copyright (C) 2001-2022 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 #include "hash-map.h" // sdcpp
23 /* This structure contains hooks for the debug information output
24 functions, accessed through the global instance debug_hooks set in
25 toplev.cc according to command line options. */
26 /* WARNING: Do not add new debug hook targets - DWARF will be the only
27 way to speak debug to the middle-end once we are able to get rid of
28 the remaining targets. If you need alternate output formats instead
29 generate them off the DWARF representation. */
30 struct gcc_debug_hooks
32 /* Initialize debug output. MAIN_FILENAME is the name of the main
34 void (* init
) (const char *main_filename
);
36 /* Output debug symbols. */
37 void (* finish
) (const char *main_filename
);
39 /* Run cleanups necessary after early debug generation. */
40 void (* early_finish
) (const char *main_filename
);
42 /* Called from cgraph_optimize before starting to assemble
43 functions/variables/toplevel asms. */
44 void (* assembly_start
) (void);
46 /* Macro defined on line LINE with name and expansion TEXT. */
47 void (* define
) (unsigned int line
, const char *text
);
49 /* MACRO undefined on line LINE. */
50 void (* undef
) (unsigned int line
, const char *macro
);
52 /* Record the beginning of a new source file FILE from LINE number
53 in the previous one. */
54 void (* start_source_file
) (unsigned int line
, const char *file
);
56 /* Record the resumption of a source file. LINE is the line number
57 in the source file we are returning to. */
58 void (* end_source_file
) (unsigned int line
);
60 /* Record the beginning of block N, counting from 1 and not
61 including the function-scope block, at LINE. */
62 void (* begin_block
) (unsigned int line
, unsigned int n
);
64 /* Record the end of a block. Arguments as for begin_block. */
65 void (* end_block
) (unsigned int line
, unsigned int n
);
67 /* Returns nonzero if it is appropriate not to emit any debugging
68 information for BLOCK, because it doesn't contain any
69 instructions. This may not be the case for blocks containing
70 nested functions, since we may actually call such a function even
71 though the BLOCK information is messed up. Defaults to true. */
72 bool (* ignore_block
) (const_tree
);
74 /* Record a source file location at (FILE, LINE, COLUMN, DISCRIMINATOR). */
75 void (* source_line
) (unsigned int line
, unsigned int column
,
76 const char *file
, int discriminator
, bool is_stmt
);
78 /* Record a source file location for a DECL_IGNORED_P function. */
79 void (* set_ignored_loc
) (unsigned int line
, unsigned int column
,
82 /* Called at start of prologue code. LINE is the first line in the
84 void (* begin_prologue
) (unsigned int line
, unsigned int column
,
87 /* Called at end of prologue code. LINE is the first line in the
89 void (* end_prologue
) (unsigned int line
, const char *file
);
91 /* Called at beginning of epilogue code. */
92 void (* begin_epilogue
) (unsigned int line
, const char *file
);
94 /* Record end of epilogue code. */
95 void (* end_epilogue
) (unsigned int line
, const char *file
);
97 /* Called at start of function DECL, before it is declared. */
98 void (* begin_function
) (tree decl
);
100 /* Record end of function. LINE is highest line number in function. */
101 void (* end_function
) (unsigned int line
);
103 /* Register UNIT as the main translation unit. Called from front-ends when
104 they create their main translation unit. */
105 void (* register_main_translation_unit
) (tree
);
107 /* Debug information for a function DECL. This might include the
108 function name (a symbol), its parameters, and the block that
109 makes up the function's body, and the local variables of the
112 This is only called for FUNCTION_DECLs. It is part of the late
113 debug pass and is called from rest_of_handle_final.
115 Location information is available at this point.
117 See the documentation for early_global_decl and late_global_decl
118 for other entry points into the debugging back-ends for DECLs. */
119 void (* function_decl
) (tree decl
);
121 /* Debug information for a global DECL. Called from the parser
122 after the parsing process has finished.
124 This gets called for both variables and functions.
126 Location information is not available at this point, but it is a
127 good probe point to get access to symbols before they get
130 This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up
131 to the hook to use what it needs. */
132 void (* early_global_decl
) (tree decl
);
134 /* Augment debug information generated by early_global_decl with
135 more complete debug info (if applicable). Called from toplev.cc
136 after the compilation proper has finished and cgraph information
139 This gets called for both variables and functions.
141 Location information is usually available at this point, unless
142 the hook is being called for a decl that has been optimized away.
144 This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up
145 to the hook to use what it needs. */
146 void (* late_global_decl
) (tree decl
);
148 /* Debug information for a type DECL. Called from toplev.cc after
149 compilation proper, also from various language front ends to
150 record built-in types. The second argument is properly a
151 boolean, which indicates whether or not the type is a "local"
152 type as determined by the language. (It's not a boolean for
154 void (* type_decl
) (tree decl
, int local
);
156 /* Debug information for imported modules and declarations. */
157 void (* imported_module_or_decl
) (tree decl
, tree name
,
158 tree context
, bool child
,
161 /* Return true if a DIE for the tree is available and return a symbol
162 and offset that can be used to refer to it externally. */
163 bool (* die_ref_for_decl
) (tree
, const char **, unsigned HOST_WIDE_INT
*);
165 /* Early debug information for the tree is available at symbol plus
166 offset externally. */
167 void (* register_external_die
) (tree
, const char *, unsigned HOST_WIDE_INT
);
169 /* DECL is an inline function, whose body is present, but which is
170 not being output at this point. */
171 void (* deferred_inline_function
) (tree decl
);
173 /* DECL is an inline function which is about to be emitted out of
174 line. The hook is useful to, e.g., emit abstract debug info for
175 the inline before it gets mangled by optimization. */
176 void (* outlining_inline_function
) (tree decl
);
178 /* Called from final_scan_insn for any CODE_LABEL insn whose
179 LABEL_NAME is non-null. */
180 void (* label
) (rtx_code_label
*);
182 /* Called after the start and before the end of writing a PCH file.
183 The parameter is 0 if after the start, 1 if before the end. */
184 void (* handle_pch
) (unsigned int);
186 /* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note. */
187 void (* var_location
) (rtx_insn
*);
189 /* Called from final_scan_insn for any NOTE_INSN_INLINE_ENTRY note. */
190 void (* inline_entry
) (tree block
);
192 /* Called from finalize_size_functions for size functions so that their body
193 can be encoded in the debug info to describe the layout of variable-length
195 void (* size_function
) (tree decl
);
197 /* Called from final_scan_insn if there is a switch between hot and cold
199 void (* switch_text_section
) (void);
201 /* Called from grokdeclarator. Replaces the anonymous name with the
203 void (* set_name
) (tree
, tree
);
205 /* This is 1 if the debug writer wants to see start and end commands for the
206 main source files, and 0 otherwise. */
207 int start_end_main_source_file
;
209 /* The type of symtab field used by these debug hooks. This is one
210 of the TYPE_SYMTAB_IS_xxx values defined in tree.h. */
211 int tree_type_symtab_field
;
214 extern const struct gcc_debug_hooks
*debug_hooks
;
216 /* The do-nothing hooks. */
217 extern void debug_nothing_void (void);
218 extern void debug_nothing_charstar (const char *);
219 extern void debug_nothing_int_int_charstar (unsigned int, unsigned int,
221 extern void debug_nothing_int_charstar (unsigned int, const char *);
222 extern void debug_nothing_int_int_charstar_int_bool (unsigned int,
226 extern void debug_nothing_int (unsigned int);
227 extern void debug_nothing_int_int (unsigned int, unsigned int);
228 extern void debug_nothing_tree (tree
);
229 extern void debug_nothing_tree_tree (tree
, tree
);
230 extern void debug_nothing_tree_int (tree
, int);
231 extern void debug_nothing_tree_tree_tree_bool_bool (tree
, tree
, tree
,
233 extern bool debug_true_const_tree (const_tree
);
234 extern void debug_nothing_rtx_insn (rtx_insn
*);
235 extern void debug_nothing_rtx_code_label (rtx_code_label
*);
236 extern bool debug_false_tree_charstarstar_uhwistar (tree
, const char **,
237 unsigned HOST_WIDE_INT
*);
238 extern void debug_nothing_tree_charstar_uhwi (tree
, const char *,
239 unsigned HOST_WIDE_INT
);
241 /* Hooks for various debug formats. */
242 extern const struct gcc_debug_hooks do_nothing_debug_hooks
;
243 extern const struct gcc_debug_hooks dbx_debug_hooks
;
244 extern const struct gcc_debug_hooks xcoff_debug_hooks
;
245 extern const struct gcc_debug_hooks dwarf2_debug_hooks
;
246 extern const struct gcc_debug_hooks dwarf2_lineno_debug_hooks
;
247 extern const struct gcc_debug_hooks vmsdbg_debug_hooks
;
249 /* Dwarf2 frame information. */
251 extern void dwarf2out_begin_prologue (unsigned int, unsigned int,
253 extern void dwarf2out_vms_end_prologue (unsigned int, const char *);
254 extern void dwarf2out_vms_begin_epilogue (unsigned int, const char *);
255 extern void dwarf2out_end_epilogue (unsigned int, const char *);
256 extern void dwarf2out_frame_finish (void);
257 extern bool dwarf2out_do_eh_frame (void);
258 extern bool dwarf2out_do_frame (void);
259 extern bool dwarf2out_do_cfi_asm (void);
260 extern void dwarf2out_switch_text_section (void);
261 extern bool dwarf2out_default_as_loc_support (void);
262 extern bool dwarf2out_default_as_locview_support (void);
264 /* For -fdump-go-spec. */
266 extern const struct gcc_debug_hooks
*
267 dump_go_spec_init (const char *, const struct gcc_debug_hooks
*);
269 /* Instance discriminator mapping table. See final.cc. */
270 typedef hash_map
<const_tree
, int> decl_to_instance_map_t
;
271 extern decl_to_instance_map_t
*decl_to_instance_map
;
273 /* Allocate decl_to_instance_map with COUNT slots to begin wtih, if it
274 * hasn't been allocated yet. */
276 static inline decl_to_instance_map_t
*
277 maybe_create_decl_to_instance_map (int count
= 13)
279 if (!decl_to_instance_map
)
280 decl_to_instance_map
= new decl_to_instance_map_t (count
);
281 return decl_to_instance_map
;
284 #endif /* !GCC_DEBUG_H */