1/* Debug hooks for GCC.
2   Copyright (C) 2001-2015 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>.  */
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.  */
24struct gcc_debug_hooks
25{
26  /* Initialize debug output.  MAIN_FILENAME is the name of the main
27     input file.  */
28  void (* init) (const char *main_filename);
29
30  /* Output debug symbols.  */
31  void (* finish) (const char *main_filename);
32
33  /* Called from cgraph_optimize before starting to assemble
34     functions/variables/toplevel asms.  */
35  void (* assembly_start) (void);
36
37  /* Macro defined on line LINE with name and expansion TEXT.  */
38  void (* define) (unsigned int line, const char *text);
39
40  /* MACRO undefined on line LINE.  */
41  void (* undef) (unsigned int line, const char *macro);
42
43  /* Record the beginning of a new source file FILE from LINE number
44     in the previous one.  */
45  void (* start_source_file) (unsigned int line, const char *file);
46
47  /* Record the resumption of a source file.  LINE is the line number
48     in the source file we are returning to.  */
49  void (* end_source_file) (unsigned int line);
50
51  /* Record the beginning of block N, counting from 1 and not
52     including the function-scope block, at LINE.  */
53  void (* begin_block) (unsigned int line, unsigned int n);
54
55  /* Record the end of a block.  Arguments as for begin_block.  */
56  void (* end_block) (unsigned int line, unsigned int n);
57
58  /* Returns nonzero if it is appropriate not to emit any debugging
59     information for BLOCK, because it doesn't contain any
60     instructions.  This may not be the case for blocks containing
61     nested functions, since we may actually call such a function even
62     though the BLOCK information is messed up.  Defaults to true.  */
63  bool (* ignore_block) (const_tree);
64
65  /* Record a source file location at (FILE, LINE, DISCRIMINATOR).  */
66  void (* source_line) (unsigned int line, const char *file,
67                        int discriminator, bool is_stmt);
68
69  /* Called at start of prologue code.  LINE is the first line in the
70     function.  */
71  void (* begin_prologue) (unsigned int line, const char *file);
72
73  /* Called at end of prologue code.  LINE is the first line in the
74     function.  */
75  void (* end_prologue) (unsigned int line, const char *file);
76
77  /* Called at beginning of epilogue code.  */
78  void (* begin_epilogue) (unsigned int line, const char *file);
79
80  /* Record end of epilogue code.  */
81  void (* end_epilogue) (unsigned int line, const char *file);
82
83  /* Called at start of function DECL, before it is declared.  */
84  void (* begin_function) (tree decl);
85
86  /* Record end of function.  LINE is highest line number in function.  */
87  void (* end_function) (unsigned int line);
88
89  /* Register UNIT as the main translation unit.  Called from front-ends when
90     they create their main translation unit.  */
91  void (* register_main_translation_unit) (tree);
92
93  /* Debug information for a function DECL.  This might include the
94     function name (a symbol), its parameters, and the block that
95     makes up the function's body, and the local variables of the
96     function.  */
97  void (* function_decl) (tree decl);
98
99  /* Debug information for a global DECL.  Called from toplev.c after
100     compilation proper has finished.  */
101  void (* global_decl) (tree decl);
102
103  /* Debug information for a type DECL.  Called from toplev.c after
104     compilation proper, also from various language front ends to
105     record built-in types.  The second argument is properly a
106     boolean, which indicates whether or not the type is a "local"
107     type as determined by the language.  (It's not a boolean for
108     legacy reasons.)  */
109  void (* type_decl) (tree decl, int local);
110
111  /* Debug information for imported modules and declarations.  */
112  void (* imported_module_or_decl) (tree decl, tree name,
113				    tree context, bool child);
114
115  /* DECL is an inline function, whose body is present, but which is
116     not being output at this point.  */
117  void (* deferred_inline_function) (tree decl);
118
119  /* DECL is an inline function which is about to be emitted out of
120     line.  The hook is useful to, e.g., emit abstract debug info for
121     the inline before it gets mangled by optimization.  */
122  void (* outlining_inline_function) (tree decl);
123
124  /* Called from final_scan_insn for any CODE_LABEL insn whose
125     LABEL_NAME is non-null.  */
126  void (* label) (rtx_code_label *);
127
128  /* Called after the start and before the end of writing a PCH file.
129     The parameter is 0 if after the start, 1 if before the end.  */
130  void (* handle_pch) (unsigned int);
131
132  /* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note.  */
133  void (* var_location) (rtx_insn *);
134
135  /* Called from final_scan_insn if there is a switch between hot and cold
136     text sections.  */
137  void (* switch_text_section) (void);
138
139  /* Called from grokdeclarator.  Replaces the anonymous name with the
140     type name.  */
141  void (* set_name) (tree, tree);
142
143  /* This is 1 if the debug writer wants to see start and end commands for the
144     main source files, and 0 otherwise.  */
145  int start_end_main_source_file;
146
147  /* The type of symtab field used by these debug hooks.  This is one
148     of the TYPE_SYMTAB_IS_xxx values defined in tree.h.  */
149  int tree_type_symtab_field;
150};
151
152extern const struct gcc_debug_hooks *debug_hooks;
153
154/* The do-nothing hooks.  */
155extern void debug_nothing_void (void);
156extern void debug_nothing_charstar (const char *);
157extern void debug_nothing_int_charstar (unsigned int, const char *);
158extern void debug_nothing_int_charstar_int_bool (unsigned int, const char *,
159                                                 int, bool);
160extern void debug_nothing_int (unsigned int);
161extern void debug_nothing_int_int (unsigned int, unsigned int);
162extern void debug_nothing_tree (tree);
163extern void debug_nothing_tree_tree (tree, tree);
164extern void debug_nothing_tree_int (tree, int);
165extern void debug_nothing_tree_tree_tree_bool (tree, tree, tree, bool);
166extern bool debug_true_const_tree (const_tree);
167extern void debug_nothing_rtx_insn (rtx_insn *);
168extern void debug_nothing_rtx_code_label (rtx_code_label *);
169
170/* Hooks for various debug formats.  */
171extern const struct gcc_debug_hooks do_nothing_debug_hooks;
172extern const struct gcc_debug_hooks dbx_debug_hooks;
173extern const struct gcc_debug_hooks sdb_debug_hooks;
174extern const struct gcc_debug_hooks xcoff_debug_hooks;
175extern const struct gcc_debug_hooks dwarf2_debug_hooks;
176extern const struct gcc_debug_hooks vmsdbg_debug_hooks;
177
178/* Dwarf2 frame information.  */
179
180extern void dwarf2out_begin_prologue (unsigned int, const char *);
181extern void dwarf2out_vms_end_prologue (unsigned int, const char *);
182extern void dwarf2out_vms_begin_epilogue (unsigned int, const char *);
183extern void dwarf2out_end_epilogue (unsigned int, const char *);
184extern void dwarf2out_frame_finish (void);
185/* Decide whether we want to emit frame unwind information for the current
186   translation unit.  */
187extern bool dwarf2out_do_frame (void);
188extern bool dwarf2out_do_cfi_asm (void);
189extern void dwarf2out_switch_text_section (void);
190
191const char *remap_debug_filename (const char *);
192void add_debug_prefix_map (const char *);
193
194/* For -fdump-go-spec.  */
195
196extern const struct gcc_debug_hooks *
197dump_go_spec_init (const char *, const struct gcc_debug_hooks *);
198
199#endif /* !GCC_DEBUG_H  */
200