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