dwarf2out.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /* dwarf2out.h - Various declarations for functions found in dwarf2out.c
  2. Copyright (C) 1998-2019 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef GCC_DWARF2OUT_H
  16. #define GCC_DWARF2OUT_H 1
  17. #include "dwarf2.h" /* ??? Remove this once only used by dwarf2foo.c. */
  18. typedef struct die_struct *dw_die_ref;
  19. typedef const struct die_struct *const_dw_die_ref;
  20. typedef struct dw_val_node *dw_val_ref;
  21. typedef struct dw_cfi_node *dw_cfi_ref;
  22. typedef struct dw_loc_descr_node *dw_loc_descr_ref;
  23. typedef struct dw_loc_list_struct *dw_loc_list_ref;
  24. typedef struct dw_discr_list_node *dw_discr_list_ref;
  25. typedef wide_int *wide_int_ptr;
  26. /* Call frames are described using a sequence of Call Frame
  27. Information instructions. The register number, offset
  28. and address fields are provided as possible operands;
  29. their use is selected by the opcode field. */
  30. enum dw_cfi_oprnd_type {
  31. dw_cfi_oprnd_unused,
  32. dw_cfi_oprnd_reg_num,
  33. dw_cfi_oprnd_offset,
  34. dw_cfi_oprnd_addr,
  35. dw_cfi_oprnd_loc,
  36. dw_cfi_oprnd_cfa_loc
  37. };
  38. typedef union GTY(()) {
  39. unsigned int GTY ((tag ("dw_cfi_oprnd_reg_num"))) dw_cfi_reg_num;
  40. HOST_WIDE_INT GTY ((tag ("dw_cfi_oprnd_offset"))) dw_cfi_offset;
  41. const char * GTY ((tag ("dw_cfi_oprnd_addr"))) dw_cfi_addr;
  42. struct dw_loc_descr_node * GTY ((tag ("dw_cfi_oprnd_loc"))) dw_cfi_loc;
  43. struct dw_cfa_location * GTY ((tag ("dw_cfi_oprnd_cfa_loc")))
  44. dw_cfi_cfa_loc;
  45. } dw_cfi_oprnd;
  46. struct GTY(()) dw_cfi_node {
  47. enum dwarf_call_frame_info dw_cfi_opc;
  48. dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd1_desc (%1.dw_cfi_opc)")))
  49. dw_cfi_oprnd1;
  50. dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd2_desc (%1.dw_cfi_opc)")))
  51. dw_cfi_oprnd2;
  52. };
  53. typedef vec<dw_cfi_ref, va_gc> *cfi_vec;
  54. typedef struct dw_fde_node *dw_fde_ref;
  55. /* All call frame descriptions (FDE's) in the GCC generated DWARF
  56. refer to a single Common Information Entry (CIE), defined at
  57. the beginning of the .debug_frame section. This use of a single
  58. CIE obviates the need to keep track of multiple CIE's
  59. in the DWARF generation routines below. */
  60. struct GTY(()) dw_fde_node {
  61. tree decl;
  62. const char *dw_fde_begin;
  63. const char *dw_fde_current_label;
  64. const char *dw_fde_end;
  65. const char *dw_fde_vms_end_prologue;
  66. const char *dw_fde_vms_begin_epilogue;
  67. const char *dw_fde_second_begin;
  68. const char *dw_fde_second_end;
  69. cfi_vec dw_fde_cfi;
  70. int dw_fde_switch_cfi_index; /* Last CFI before switching sections. */
  71. HOST_WIDE_INT stack_realignment;
  72. unsigned funcdef_number;
  73. unsigned fde_index;
  74. /* Dynamic realign argument pointer register. */
  75. unsigned int drap_reg;
  76. /* Virtual dynamic realign argument pointer register. */
  77. unsigned int vdrap_reg;
  78. /* These 3 flags are copied from rtl_data in function.h. */
  79. unsigned all_throwers_are_sibcalls : 1;
  80. unsigned uses_eh_lsda : 1;
  81. unsigned nothrow : 1;
  82. /* Whether we did stack realign in this call frame. */
  83. unsigned stack_realign : 1;
  84. /* Whether dynamic realign argument pointer register has been saved. */
  85. unsigned drap_reg_saved: 1;
  86. /* True iff dw_fde_begin label is in text_section or cold_text_section. */
  87. unsigned in_std_section : 1;
  88. /* True iff dw_fde_second_begin label is in text_section or
  89. cold_text_section. */
  90. unsigned second_in_std_section : 1;
  91. };
  92. /* This is how we define the location of the CFA. We use to handle it
  93. as REG + OFFSET all the time, but now it can be more complex.
  94. It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
  95. Instead of passing around REG and OFFSET, we pass a copy
  96. of this structure. */
  97. struct GTY(()) dw_cfa_location {
  98. poly_int64_pod offset;
  99. poly_int64_pod base_offset;
  100. /* REG is in DWARF_FRAME_REGNUM space, *not* normal REGNO space. */
  101. unsigned int reg;
  102. BOOL_BITFIELD indirect : 1; /* 1 if CFA is accessed via a dereference. */
  103. BOOL_BITFIELD in_use : 1; /* 1 if a saved cfa is stored here. */
  104. };
  105. /* Each DIE may have a series of attribute/value pairs. Values
  106. can take on several forms. The forms that are used in this
  107. implementation are listed below. */
  108. enum dw_val_class
  109. {
  110. dw_val_class_none,
  111. dw_val_class_addr,
  112. dw_val_class_offset,
  113. dw_val_class_loc,
  114. dw_val_class_loc_list,
  115. dw_val_class_range_list,
  116. dw_val_class_const,
  117. dw_val_class_unsigned_const,
  118. dw_val_class_const_double,
  119. dw_val_class_wide_int,
  120. dw_val_class_vec,
  121. dw_val_class_flag,
  122. dw_val_class_die_ref,
  123. dw_val_class_fde_ref,
  124. dw_val_class_lbl_id,
  125. dw_val_class_lineptr,
  126. dw_val_class_str,
  127. dw_val_class_macptr,
  128. dw_val_class_loclistsptr,
  129. dw_val_class_file,
  130. dw_val_class_data8,
  131. dw_val_class_decl_ref,
  132. dw_val_class_vms_delta,
  133. dw_val_class_high_pc,
  134. dw_val_class_discr_value,
  135. dw_val_class_discr_list,
  136. dw_val_class_const_implicit,
  137. dw_val_class_unsigned_const_implicit,
  138. dw_val_class_file_implicit,
  139. dw_val_class_view_list,
  140. dw_val_class_symview
  141. };
  142. /* Describe a floating point constant value, or a vector constant value. */
  143. struct GTY(()) dw_vec_const {
  144. void * GTY((atomic)) array;
  145. unsigned length;
  146. unsigned elt_size;
  147. };
  148. /* Describe a single value that a discriminant can match.
  149. Discriminants (in the "record variant part" meaning) are scalars.
  150. dw_discr_list_ref and dw_discr_value are a mean to describe a set of
  151. discriminant values that are matched by a particular variant.
  152. Discriminants can be signed or unsigned scalars, and can be discriminants
  153. values. Both have to be consistent, though. */
  154. struct GTY(()) dw_discr_value {
  155. int pos; /* Whether the discriminant value is positive (unsigned). */
  156. union
  157. {
  158. HOST_WIDE_INT GTY ((tag ("0"))) sval;
  159. unsigned HOST_WIDE_INT GTY ((tag ("1"))) uval;
  160. }
  161. GTY ((desc ("%1.pos"))) v;
  162. };
  163. struct addr_table_entry;
  164. /* The dw_val_node describes an attribute's value, as it is
  165. represented internally. */
  166. struct GTY(()) dw_val_node {
  167. enum dw_val_class val_class;
  168. struct addr_table_entry * GTY(()) val_entry;
  169. union dw_val_struct_union
  170. {
  171. rtx GTY ((tag ("dw_val_class_addr"))) val_addr;
  172. unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_offset"))) val_offset;
  173. dw_loc_list_ref GTY ((tag ("dw_val_class_loc_list"))) val_loc_list;
  174. dw_die_ref GTY ((tag ("dw_val_class_view_list"))) val_view_list;
  175. dw_loc_descr_ref GTY ((tag ("dw_val_class_loc"))) val_loc;
  176. HOST_WIDE_INT GTY ((default)) val_int;
  177. unsigned HOST_WIDE_INT
  178. GTY ((tag ("dw_val_class_unsigned_const"))) val_unsigned;
  179. double_int GTY ((tag ("dw_val_class_const_double"))) val_double;
  180. wide_int_ptr GTY ((tag ("dw_val_class_wide_int"))) val_wide;
  181. dw_vec_const GTY ((tag ("dw_val_class_vec"))) val_vec;
  182. struct dw_val_die_union
  183. {
  184. dw_die_ref die;
  185. int external;
  186. } GTY ((tag ("dw_val_class_die_ref"))) val_die_ref;
  187. unsigned GTY ((tag ("dw_val_class_fde_ref"))) val_fde_index;
  188. struct indirect_string_node * GTY ((tag ("dw_val_class_str"))) val_str;
  189. char * GTY ((tag ("dw_val_class_lbl_id"))) val_lbl_id;
  190. unsigned char GTY ((tag ("dw_val_class_flag"))) val_flag;
  191. struct dwarf_file_data * GTY ((tag ("dw_val_class_file"))) val_file;
  192. struct dwarf_file_data *
  193. GTY ((tag ("dw_val_class_file_implicit"))) val_file_implicit;
  194. unsigned char GTY ((tag ("dw_val_class_data8"))) val_data8[8];
  195. tree GTY ((tag ("dw_val_class_decl_ref"))) val_decl_ref;
  196. struct dw_val_vms_delta_union
  197. {
  198. char * lbl1;
  199. char * lbl2;
  200. } GTY ((tag ("dw_val_class_vms_delta"))) val_vms_delta;
  201. dw_discr_value GTY ((tag ("dw_val_class_discr_value"))) val_discr_value;
  202. dw_discr_list_ref GTY ((tag ("dw_val_class_discr_list"))) val_discr_list;
  203. char * GTY ((tag ("dw_val_class_symview"))) val_symbolic_view;
  204. }
  205. GTY ((desc ("%1.val_class"))) v;
  206. };
  207. /* Locations in memory are described using a sequence of stack machine
  208. operations. */
  209. struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node {
  210. dw_loc_descr_ref dw_loc_next;
  211. ENUM_BITFIELD (dwarf_location_atom) dw_loc_opc : 8;
  212. /* Used to distinguish DW_OP_addr with a direct symbol relocation
  213. from DW_OP_addr with a dtp-relative symbol relocation. */
  214. unsigned int dtprel : 1;
  215. /* For DW_OP_pick, DW_OP_dup and DW_OP_over operations: true iff.
  216. it targets a DWARF prodecure argument. In this case, it needs to be
  217. relocated according to the current frame offset. */
  218. unsigned int frame_offset_rel : 1;
  219. int dw_loc_addr;
  220. dw_val_node dw_loc_oprnd1;
  221. dw_val_node dw_loc_oprnd2;
  222. };
  223. /* A variant (inside a record variant part) is selected when the corresponding
  224. discriminant matches its set of values (see the comment for dw_discr_value).
  225. The following datastructure holds such matching information. */
  226. struct GTY(()) dw_discr_list_node {
  227. dw_discr_list_ref dw_discr_next;
  228. dw_discr_value dw_discr_lower_bound;
  229. dw_discr_value dw_discr_upper_bound;
  230. /* This node represents only the value in dw_discr_lower_bound when it's
  231. zero. It represents the range between the two fields (bounds included)
  232. otherwise. */
  233. int dw_discr_range;
  234. };
  235. /* Interface from dwarf2out.c to dwarf2cfi.c. */
  236. extern struct dw_loc_descr_node *build_cfa_loc
  237. (dw_cfa_location *, poly_int64);
  238. extern struct dw_loc_descr_node *build_cfa_aligned_loc
  239. (dw_cfa_location *, poly_int64, HOST_WIDE_INT);
  240. extern struct dw_loc_descr_node *mem_loc_descriptor
  241. (rtx, machine_mode mode, machine_mode mem_mode,
  242. enum var_init_status);
  243. extern bool loc_descr_equal_p (dw_loc_descr_ref, dw_loc_descr_ref);
  244. extern dw_fde_ref dwarf2out_alloc_current_fde (void);
  245. extern unsigned long size_of_locs (dw_loc_descr_ref);
  246. extern void output_loc_sequence (dw_loc_descr_ref, int);
  247. extern void output_loc_sequence_raw (dw_loc_descr_ref);
  248. /* Interface from dwarf2cfi.c to dwarf2out.c. */
  249. extern void lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_location *loc,
  250. dw_cfa_location *remember);
  251. extern bool cfa_equal_p (const dw_cfa_location *, const dw_cfa_location *);
  252. extern void output_cfi (dw_cfi_ref, dw_fde_ref, int);
  253. extern GTY(()) cfi_vec cie_cfi_vec;
  254. /* Interface from dwarf2*.c to the rest of the compiler. */
  255. extern enum dw_cfi_oprnd_type dw_cfi_oprnd1_desc
  256. (enum dwarf_call_frame_info cfi);
  257. extern enum dw_cfi_oprnd_type dw_cfi_oprnd2_desc
  258. (enum dwarf_call_frame_info cfi);
  259. extern void output_cfi_directive (FILE *f, struct dw_cfi_node *cfi);
  260. extern void dwarf2out_emit_cfi (dw_cfi_ref cfi);
  261. extern void debug_dwarf (void);
  262. struct die_struct;
  263. extern void debug_dwarf_die (struct die_struct *);
  264. extern void debug_dwarf_loc_descr (dw_loc_descr_ref);
  265. extern void debug (die_struct &ref);
  266. extern void debug (die_struct *ptr);
  267. extern void dwarf2out_set_demangle_name_func (const char *(*) (const char *));
  268. #ifdef VMS_DEBUGGING_INFO
  269. extern void dwarf2out_vms_debug_main_pointer (void);
  270. #endif
  271. enum array_descr_ordering
  272. {
  273. array_descr_ordering_default,
  274. array_descr_ordering_row_major,
  275. array_descr_ordering_column_major
  276. };
  277. #define DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN 16
  278. struct array_descr_info
  279. {
  280. int ndimensions;
  281. enum array_descr_ordering ordering;
  282. tree element_type;
  283. tree base_decl;
  284. tree data_location;
  285. tree allocated;
  286. tree associated;
  287. tree stride;
  288. tree rank;
  289. bool stride_in_bits;
  290. struct array_descr_dimen
  291. {
  292. /* GCC uses sizetype for array indices, so lower_bound and upper_bound
  293. will likely be "sizetype" values. However, bounds may have another
  294. type in the original source code. */
  295. tree bounds_type;
  296. tree lower_bound;
  297. tree upper_bound;
  298. /* Only Fortran uses more than one dimension for array types. For other
  299. languages, the stride can be rather specified for the whole array. */
  300. tree stride;
  301. } dimen[DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN];
  302. };
  303. enum fixed_point_scale_factor
  304. {
  305. fixed_point_scale_factor_binary,
  306. fixed_point_scale_factor_decimal,
  307. fixed_point_scale_factor_arbitrary
  308. };
  309. struct fixed_point_type_info
  310. {
  311. /* A scale factor is the value one has to multiply with physical data in
  312. order to get the fixed point logical data. The DWARF standard enables one
  313. to encode it in three ways. */
  314. enum fixed_point_scale_factor scale_factor_kind;
  315. union
  316. {
  317. /* For binary scale factor, the scale factor is: 2 ** binary. */
  318. int binary;
  319. /* For decimal scale factor, the scale factor is: 10 ** binary. */
  320. int decimal;
  321. /* For arbitrary scale factor, the scale factor is:
  322. numerator / denominator. */
  323. struct
  324. {
  325. unsigned HOST_WIDE_INT numerator;
  326. HOST_WIDE_INT denominator;
  327. } arbitrary;
  328. } scale_factor;
  329. };
  330. void dwarf2out_c_finalize (void);
  331. #endif /* GCC_DWARF2OUT_H */