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