1*38fd1498Szrj /* Debug hooks for GCC. 2*38fd1498Szrj Copyright (C) 2001-2018 Free Software Foundation, Inc. 3*38fd1498Szrj 4*38fd1498Szrj This program is free software; you can redistribute it and/or modify it 5*38fd1498Szrj under the terms of the GNU General Public License as published by the 6*38fd1498Szrj Free Software Foundation; either version 3, or (at your option) any 7*38fd1498Szrj later version. 8*38fd1498Szrj 9*38fd1498Szrj This program is distributed in the hope that it will be useful, 10*38fd1498Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of 11*38fd1498Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12*38fd1498Szrj GNU General Public License for more details. 13*38fd1498Szrj 14*38fd1498Szrj You should have received a copy of the GNU General Public License 15*38fd1498Szrj along with this program; see the file COPYING3. If not see 16*38fd1498Szrj <http://www.gnu.org/licenses/>. */ 17*38fd1498Szrj 18*38fd1498Szrj #ifndef GCC_DEBUG_H 19*38fd1498Szrj #define GCC_DEBUG_H 20*38fd1498Szrj 21*38fd1498Szrj /* This structure contains hooks for the debug information output 22*38fd1498Szrj functions, accessed through the global instance debug_hooks set in 23*38fd1498Szrj toplev.c according to command line options. */ 24*38fd1498Szrj struct gcc_debug_hooks 25*38fd1498Szrj { 26*38fd1498Szrj /* Initialize debug output. MAIN_FILENAME is the name of the main 27*38fd1498Szrj input file. */ 28*38fd1498Szrj void (* init) (const char *main_filename); 29*38fd1498Szrj 30*38fd1498Szrj /* Output debug symbols. */ 31*38fd1498Szrj void (* finish) (const char *main_filename); 32*38fd1498Szrj 33*38fd1498Szrj /* Run cleanups necessary after early debug generation. */ 34*38fd1498Szrj void (* early_finish) (const char *main_filename); 35*38fd1498Szrj 36*38fd1498Szrj /* Called from cgraph_optimize before starting to assemble 37*38fd1498Szrj functions/variables/toplevel asms. */ 38*38fd1498Szrj void (* assembly_start) (void); 39*38fd1498Szrj 40*38fd1498Szrj /* Macro defined on line LINE with name and expansion TEXT. */ 41*38fd1498Szrj void (* define) (unsigned int line, const char *text); 42*38fd1498Szrj 43*38fd1498Szrj /* MACRO undefined on line LINE. */ 44*38fd1498Szrj void (* undef) (unsigned int line, const char *macro); 45*38fd1498Szrj 46*38fd1498Szrj /* Record the beginning of a new source file FILE from LINE number 47*38fd1498Szrj in the previous one. */ 48*38fd1498Szrj void (* start_source_file) (unsigned int line, const char *file); 49*38fd1498Szrj 50*38fd1498Szrj /* Record the resumption of a source file. LINE is the line number 51*38fd1498Szrj in the source file we are returning to. */ 52*38fd1498Szrj void (* end_source_file) (unsigned int line); 53*38fd1498Szrj 54*38fd1498Szrj /* Record the beginning of block N, counting from 1 and not 55*38fd1498Szrj including the function-scope block, at LINE. */ 56*38fd1498Szrj void (* begin_block) (unsigned int line, unsigned int n); 57*38fd1498Szrj 58*38fd1498Szrj /* Record the end of a block. Arguments as for begin_block. */ 59*38fd1498Szrj void (* end_block) (unsigned int line, unsigned int n); 60*38fd1498Szrj 61*38fd1498Szrj /* Returns nonzero if it is appropriate not to emit any debugging 62*38fd1498Szrj information for BLOCK, because it doesn't contain any 63*38fd1498Szrj instructions. This may not be the case for blocks containing 64*38fd1498Szrj nested functions, since we may actually call such a function even 65*38fd1498Szrj though the BLOCK information is messed up. Defaults to true. */ 66*38fd1498Szrj bool (* ignore_block) (const_tree); 67*38fd1498Szrj 68*38fd1498Szrj /* Record a source file location at (FILE, LINE, COLUMN, DISCRIMINATOR). */ 69*38fd1498Szrj void (* source_line) (unsigned int line, unsigned int column, 70*38fd1498Szrj const char *file, int discriminator, bool is_stmt); 71*38fd1498Szrj 72*38fd1498Szrj /* Called at start of prologue code. LINE is the first line in the 73*38fd1498Szrj function. */ 74*38fd1498Szrj void (* begin_prologue) (unsigned int line, unsigned int column, 75*38fd1498Szrj const char *file); 76*38fd1498Szrj 77*38fd1498Szrj /* Called at end of prologue code. LINE is the first line in the 78*38fd1498Szrj function. */ 79*38fd1498Szrj void (* end_prologue) (unsigned int line, const char *file); 80*38fd1498Szrj 81*38fd1498Szrj /* Called at beginning of epilogue code. */ 82*38fd1498Szrj void (* begin_epilogue) (unsigned int line, const char *file); 83*38fd1498Szrj 84*38fd1498Szrj /* Record end of epilogue code. */ 85*38fd1498Szrj void (* end_epilogue) (unsigned int line, const char *file); 86*38fd1498Szrj 87*38fd1498Szrj /* Called at start of function DECL, before it is declared. */ 88*38fd1498Szrj void (* begin_function) (tree decl); 89*38fd1498Szrj 90*38fd1498Szrj /* Record end of function. LINE is highest line number in function. */ 91*38fd1498Szrj void (* end_function) (unsigned int line); 92*38fd1498Szrj 93*38fd1498Szrj /* Register UNIT as the main translation unit. Called from front-ends when 94*38fd1498Szrj they create their main translation unit. */ 95*38fd1498Szrj void (* register_main_translation_unit) (tree); 96*38fd1498Szrj 97*38fd1498Szrj /* Debug information for a function DECL. This might include the 98*38fd1498Szrj function name (a symbol), its parameters, and the block that 99*38fd1498Szrj makes up the function's body, and the local variables of the 100*38fd1498Szrj function. 101*38fd1498Szrj 102*38fd1498Szrj This is only called for FUNCTION_DECLs. It is part of the late 103*38fd1498Szrj debug pass and is called from rest_of_handle_final. 104*38fd1498Szrj 105*38fd1498Szrj Location information is available at this point. 106*38fd1498Szrj 107*38fd1498Szrj See the documentation for early_global_decl and late_global_decl 108*38fd1498Szrj for other entry points into the debugging back-ends for DECLs. */ 109*38fd1498Szrj void (* function_decl) (tree decl); 110*38fd1498Szrj 111*38fd1498Szrj /* Debug information for a global DECL. Called from the parser 112*38fd1498Szrj after the parsing process has finished. 113*38fd1498Szrj 114*38fd1498Szrj This gets called for both variables and functions. 115*38fd1498Szrj 116*38fd1498Szrj Location information is not available at this point, but it is a 117*38fd1498Szrj good probe point to get access to symbols before they get 118*38fd1498Szrj optimized away. 119*38fd1498Szrj 120*38fd1498Szrj This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up 121*38fd1498Szrj to the hook to use what it needs. */ 122*38fd1498Szrj void (* early_global_decl) (tree decl); 123*38fd1498Szrj 124*38fd1498Szrj /* Augment debug information generated by early_global_decl with 125*38fd1498Szrj more complete debug info (if applicable). Called from toplev.c 126*38fd1498Szrj after the compilation proper has finished and cgraph information 127*38fd1498Szrj is available. 128*38fd1498Szrj 129*38fd1498Szrj This gets called for both variables and functions. 130*38fd1498Szrj 131*38fd1498Szrj Location information is usually available at this point, unless 132*38fd1498Szrj the hook is being called for a decl that has been optimized away. 133*38fd1498Szrj 134*38fd1498Szrj This hook may be called on VAR_DECLs or FUNCTION_DECLs. It is up 135*38fd1498Szrj to the hook to use what it needs. */ 136*38fd1498Szrj void (* late_global_decl) (tree decl); 137*38fd1498Szrj 138*38fd1498Szrj /* Debug information for a type DECL. Called from toplev.c after 139*38fd1498Szrj compilation proper, also from various language front ends to 140*38fd1498Szrj record built-in types. The second argument is properly a 141*38fd1498Szrj boolean, which indicates whether or not the type is a "local" 142*38fd1498Szrj type as determined by the language. (It's not a boolean for 143*38fd1498Szrj legacy reasons.) */ 144*38fd1498Szrj void (* type_decl) (tree decl, int local); 145*38fd1498Szrj 146*38fd1498Szrj /* Debug information for imported modules and declarations. */ 147*38fd1498Szrj void (* imported_module_or_decl) (tree decl, tree name, 148*38fd1498Szrj tree context, bool child, 149*38fd1498Szrj bool implicit); 150*38fd1498Szrj 151*38fd1498Szrj /* Return true if a DIE for the tree is available and return a symbol 152*38fd1498Szrj and offset that can be used to refer to it externally. */ 153*38fd1498Szrj bool (* die_ref_for_decl) (tree, const char **, unsigned HOST_WIDE_INT *); 154*38fd1498Szrj 155*38fd1498Szrj /* Early debug information for the tree is available at symbol plus 156*38fd1498Szrj offset externally. */ 157*38fd1498Szrj void (* register_external_die) (tree, const char *, unsigned HOST_WIDE_INT); 158*38fd1498Szrj 159*38fd1498Szrj /* DECL is an inline function, whose body is present, but which is 160*38fd1498Szrj not being output at this point. */ 161*38fd1498Szrj void (* deferred_inline_function) (tree decl); 162*38fd1498Szrj 163*38fd1498Szrj /* DECL is an inline function which is about to be emitted out of 164*38fd1498Szrj line. The hook is useful to, e.g., emit abstract debug info for 165*38fd1498Szrj the inline before it gets mangled by optimization. */ 166*38fd1498Szrj void (* outlining_inline_function) (tree decl); 167*38fd1498Szrj 168*38fd1498Szrj /* Called from final_scan_insn for any CODE_LABEL insn whose 169*38fd1498Szrj LABEL_NAME is non-null. */ 170*38fd1498Szrj void (* label) (rtx_code_label *); 171*38fd1498Szrj 172*38fd1498Szrj /* Called after the start and before the end of writing a PCH file. 173*38fd1498Szrj The parameter is 0 if after the start, 1 if before the end. */ 174*38fd1498Szrj void (* handle_pch) (unsigned int); 175*38fd1498Szrj 176*38fd1498Szrj /* Called from final_scan_insn for any NOTE_INSN_VAR_LOCATION note. */ 177*38fd1498Szrj void (* var_location) (rtx_insn *); 178*38fd1498Szrj 179*38fd1498Szrj /* Called from final_scan_insn for any NOTE_INSN_INLINE_ENTRY note. */ 180*38fd1498Szrj void (* inline_entry) (tree block); 181*38fd1498Szrj 182*38fd1498Szrj /* Called from finalize_size_functions for size functions so that their body 183*38fd1498Szrj can be encoded in the debug info to describe the layout of variable-length 184*38fd1498Szrj structures. */ 185*38fd1498Szrj void (* size_function) (tree decl); 186*38fd1498Szrj 187*38fd1498Szrj /* Called from final_scan_insn if there is a switch between hot and cold 188*38fd1498Szrj text sections. */ 189*38fd1498Szrj void (* switch_text_section) (void); 190*38fd1498Szrj 191*38fd1498Szrj /* Called from grokdeclarator. Replaces the anonymous name with the 192*38fd1498Szrj type name. */ 193*38fd1498Szrj void (* set_name) (tree, tree); 194*38fd1498Szrj 195*38fd1498Szrj /* This is 1 if the debug writer wants to see start and end commands for the 196*38fd1498Szrj main source files, and 0 otherwise. */ 197*38fd1498Szrj int start_end_main_source_file; 198*38fd1498Szrj 199*38fd1498Szrj /* The type of symtab field used by these debug hooks. This is one 200*38fd1498Szrj of the TYPE_SYMTAB_IS_xxx values defined in tree.h. */ 201*38fd1498Szrj int tree_type_symtab_field; 202*38fd1498Szrj }; 203*38fd1498Szrj 204*38fd1498Szrj extern const struct gcc_debug_hooks *debug_hooks; 205*38fd1498Szrj 206*38fd1498Szrj /* The do-nothing hooks. */ 207*38fd1498Szrj extern void debug_nothing_void (void); 208*38fd1498Szrj extern void debug_nothing_charstar (const char *); 209*38fd1498Szrj extern void debug_nothing_int_int_charstar (unsigned int, unsigned int, 210*38fd1498Szrj const char *); 211*38fd1498Szrj extern void debug_nothing_int_charstar (unsigned int, const char *); 212*38fd1498Szrj extern void debug_nothing_int_int_charstar_int_bool (unsigned int, 213*38fd1498Szrj unsigned int, 214*38fd1498Szrj const char *, 215*38fd1498Szrj int, bool); 216*38fd1498Szrj extern void debug_nothing_int (unsigned int); 217*38fd1498Szrj extern void debug_nothing_int_int (unsigned int, unsigned int); 218*38fd1498Szrj extern void debug_nothing_tree (tree); 219*38fd1498Szrj extern void debug_nothing_tree_tree (tree, tree); 220*38fd1498Szrj extern void debug_nothing_tree_int (tree, int); 221*38fd1498Szrj extern void debug_nothing_tree_tree_tree_bool_bool (tree, tree, tree, 222*38fd1498Szrj bool, bool); 223*38fd1498Szrj extern bool debug_true_const_tree (const_tree); 224*38fd1498Szrj extern void debug_nothing_rtx_insn (rtx_insn *); 225*38fd1498Szrj extern void debug_nothing_rtx_code_label (rtx_code_label *); 226*38fd1498Szrj extern bool debug_false_tree_charstarstar_uhwistar (tree, const char **, 227*38fd1498Szrj unsigned HOST_WIDE_INT *); 228*38fd1498Szrj extern void debug_nothing_tree_charstar_uhwi (tree, const char *, 229*38fd1498Szrj unsigned HOST_WIDE_INT); 230*38fd1498Szrj 231*38fd1498Szrj /* Hooks for various debug formats. */ 232*38fd1498Szrj extern const struct gcc_debug_hooks do_nothing_debug_hooks; 233*38fd1498Szrj extern const struct gcc_debug_hooks dbx_debug_hooks; 234*38fd1498Szrj extern const struct gcc_debug_hooks xcoff_debug_hooks; 235*38fd1498Szrj extern const struct gcc_debug_hooks dwarf2_debug_hooks; 236*38fd1498Szrj extern const struct gcc_debug_hooks dwarf2_lineno_debug_hooks; 237*38fd1498Szrj extern const struct gcc_debug_hooks vmsdbg_debug_hooks; 238*38fd1498Szrj 239*38fd1498Szrj /* Dwarf2 frame information. */ 240*38fd1498Szrj 241*38fd1498Szrj extern void dwarf2out_begin_prologue (unsigned int, unsigned int, 242*38fd1498Szrj const char *); 243*38fd1498Szrj extern void dwarf2out_vms_end_prologue (unsigned int, const char *); 244*38fd1498Szrj extern void dwarf2out_vms_begin_epilogue (unsigned int, const char *); 245*38fd1498Szrj extern void dwarf2out_end_epilogue (unsigned int, const char *); 246*38fd1498Szrj extern void dwarf2out_frame_finish (void); 247*38fd1498Szrj extern bool dwarf2out_do_eh_frame (void); 248*38fd1498Szrj extern bool dwarf2out_do_frame (void); 249*38fd1498Szrj extern bool dwarf2out_do_cfi_asm (void); 250*38fd1498Szrj extern void dwarf2out_switch_text_section (void); 251*38fd1498Szrj extern bool dwarf2out_default_as_loc_support (void); 252*38fd1498Szrj extern bool dwarf2out_default_as_locview_support (void); 253*38fd1498Szrj 254*38fd1498Szrj /* For -fdump-go-spec. */ 255*38fd1498Szrj 256*38fd1498Szrj extern const struct gcc_debug_hooks * 257*38fd1498Szrj dump_go_spec_init (const char *, const struct gcc_debug_hooks *); 258*38fd1498Szrj 259*38fd1498Szrj #endif /* !GCC_DEBUG_H */ 260