debug.h 8.0 KB

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