xref: /dflybsd-src/contrib/gcc-4.7/gcc/dwarf2out.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* dwarf2out.h - Various declarations for functions found in dwarf2out.c
2*e4b17023SJohn Marino    Copyright (C) 1998, 1999, 2000, 2003, 2007, 2010, 2011
3*e4b17023SJohn Marino    Free Software Foundation, Inc.
4*e4b17023SJohn Marino 
5*e4b17023SJohn Marino This file is part of GCC.
6*e4b17023SJohn Marino 
7*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify it under
8*e4b17023SJohn Marino the terms of the GNU General Public License as published by the Free
9*e4b17023SJohn Marino Software Foundation; either version 3, or (at your option) any later
10*e4b17023SJohn Marino version.
11*e4b17023SJohn Marino 
12*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13*e4b17023SJohn Marino WARRANTY; without even the implied warranty of MERCHANTABILITY or
14*e4b17023SJohn Marino FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15*e4b17023SJohn Marino for more details.
16*e4b17023SJohn Marino 
17*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
18*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
19*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
20*e4b17023SJohn Marino 
21*e4b17023SJohn Marino #ifndef GCC_DWARF2OUT_H
22*e4b17023SJohn Marino #define GCC_DWARF2OUT_H 1
23*e4b17023SJohn Marino 
24*e4b17023SJohn Marino #include "dwarf2.h"	/* ??? Remove this once only used by dwarf2foo.c.  */
25*e4b17023SJohn Marino 
26*e4b17023SJohn Marino typedef struct die_struct *dw_die_ref;
27*e4b17023SJohn Marino typedef const struct die_struct *const_dw_die_ref;
28*e4b17023SJohn Marino 
29*e4b17023SJohn Marino typedef struct dw_val_struct *dw_val_ref;
30*e4b17023SJohn Marino typedef struct dw_cfi_struct *dw_cfi_ref;
31*e4b17023SJohn Marino typedef struct dw_loc_descr_struct *dw_loc_descr_ref;
32*e4b17023SJohn Marino typedef struct dw_loc_list_struct *dw_loc_list_ref;
33*e4b17023SJohn Marino 
34*e4b17023SJohn Marino 
35*e4b17023SJohn Marino /* Call frames are described using a sequence of Call Frame
36*e4b17023SJohn Marino    Information instructions.  The register number, offset
37*e4b17023SJohn Marino    and address fields are provided as possible operands;
38*e4b17023SJohn Marino    their use is selected by the opcode field.  */
39*e4b17023SJohn Marino 
40*e4b17023SJohn Marino enum dw_cfi_oprnd_type {
41*e4b17023SJohn Marino   dw_cfi_oprnd_unused,
42*e4b17023SJohn Marino   dw_cfi_oprnd_reg_num,
43*e4b17023SJohn Marino   dw_cfi_oprnd_offset,
44*e4b17023SJohn Marino   dw_cfi_oprnd_addr,
45*e4b17023SJohn Marino   dw_cfi_oprnd_loc
46*e4b17023SJohn Marino };
47*e4b17023SJohn Marino 
48*e4b17023SJohn Marino typedef union GTY(()) dw_cfi_oprnd_struct {
49*e4b17023SJohn Marino   unsigned int GTY ((tag ("dw_cfi_oprnd_reg_num"))) dw_cfi_reg_num;
50*e4b17023SJohn Marino   HOST_WIDE_INT GTY ((tag ("dw_cfi_oprnd_offset"))) dw_cfi_offset;
51*e4b17023SJohn Marino   const char * GTY ((tag ("dw_cfi_oprnd_addr"))) dw_cfi_addr;
52*e4b17023SJohn Marino   struct dw_loc_descr_struct * GTY ((tag ("dw_cfi_oprnd_loc"))) dw_cfi_loc;
53*e4b17023SJohn Marino }
54*e4b17023SJohn Marino dw_cfi_oprnd;
55*e4b17023SJohn Marino 
56*e4b17023SJohn Marino typedef struct GTY(()) dw_cfi_struct {
57*e4b17023SJohn Marino   enum dwarf_call_frame_info dw_cfi_opc;
58*e4b17023SJohn Marino   dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd1_desc (%1.dw_cfi_opc)")))
59*e4b17023SJohn Marino     dw_cfi_oprnd1;
60*e4b17023SJohn Marino   dw_cfi_oprnd GTY ((desc ("dw_cfi_oprnd2_desc (%1.dw_cfi_opc)")))
61*e4b17023SJohn Marino     dw_cfi_oprnd2;
62*e4b17023SJohn Marino }
63*e4b17023SJohn Marino dw_cfi_node;
64*e4b17023SJohn Marino 
65*e4b17023SJohn Marino DEF_VEC_P (dw_cfi_ref);
66*e4b17023SJohn Marino DEF_VEC_ALLOC_P (dw_cfi_ref, heap);
67*e4b17023SJohn Marino DEF_VEC_ALLOC_P (dw_cfi_ref, gc);
68*e4b17023SJohn Marino 
69*e4b17023SJohn Marino typedef VEC(dw_cfi_ref, gc) *cfi_vec;
70*e4b17023SJohn Marino 
71*e4b17023SJohn Marino typedef struct dw_fde_struct *dw_fde_ref;
72*e4b17023SJohn Marino 
73*e4b17023SJohn Marino /* All call frame descriptions (FDE's) in the GCC generated DWARF
74*e4b17023SJohn Marino    refer to a single Common Information Entry (CIE), defined at
75*e4b17023SJohn Marino    the beginning of the .debug_frame section.  This use of a single
76*e4b17023SJohn Marino    CIE obviates the need to keep track of multiple CIE's
77*e4b17023SJohn Marino    in the DWARF generation routines below.  */
78*e4b17023SJohn Marino 
79*e4b17023SJohn Marino typedef struct GTY(()) dw_fde_struct {
80*e4b17023SJohn Marino   tree decl;
81*e4b17023SJohn Marino   const char *dw_fde_begin;
82*e4b17023SJohn Marino   const char *dw_fde_current_label;
83*e4b17023SJohn Marino   const char *dw_fde_end;
84*e4b17023SJohn Marino   const char *dw_fde_vms_end_prologue;
85*e4b17023SJohn Marino   const char *dw_fde_vms_begin_epilogue;
86*e4b17023SJohn Marino   const char *dw_fde_second_begin;
87*e4b17023SJohn Marino   const char *dw_fde_second_end;
88*e4b17023SJohn Marino   cfi_vec dw_fde_cfi;
89*e4b17023SJohn Marino   int dw_fde_switch_cfi_index; /* Last CFI before switching sections.  */
90*e4b17023SJohn Marino   HOST_WIDE_INT stack_realignment;
91*e4b17023SJohn Marino 
92*e4b17023SJohn Marino   unsigned funcdef_number;
93*e4b17023SJohn Marino   unsigned fde_index;
94*e4b17023SJohn Marino 
95*e4b17023SJohn Marino   /* Dynamic realign argument pointer register.  */
96*e4b17023SJohn Marino   unsigned int drap_reg;
97*e4b17023SJohn Marino   /* Virtual dynamic realign argument pointer register.  */
98*e4b17023SJohn Marino   unsigned int vdrap_reg;
99*e4b17023SJohn Marino   /* These 3 flags are copied from rtl_data in function.h.  */
100*e4b17023SJohn Marino   unsigned all_throwers_are_sibcalls : 1;
101*e4b17023SJohn Marino   unsigned uses_eh_lsda : 1;
102*e4b17023SJohn Marino   unsigned nothrow : 1;
103*e4b17023SJohn Marino   /* Whether we did stack realign in this call frame.  */
104*e4b17023SJohn Marino   unsigned stack_realign : 1;
105*e4b17023SJohn Marino   /* Whether dynamic realign argument pointer register has been saved.  */
106*e4b17023SJohn Marino   unsigned drap_reg_saved: 1;
107*e4b17023SJohn Marino   /* True iff dw_fde_begin label is in text_section or cold_text_section.  */
108*e4b17023SJohn Marino   unsigned in_std_section : 1;
109*e4b17023SJohn Marino   /* True iff dw_fde_second_begin label is in text_section or
110*e4b17023SJohn Marino      cold_text_section.  */
111*e4b17023SJohn Marino   unsigned second_in_std_section : 1;
112*e4b17023SJohn Marino }
113*e4b17023SJohn Marino dw_fde_node;
114*e4b17023SJohn Marino 
115*e4b17023SJohn Marino 
116*e4b17023SJohn Marino /* This is how we define the location of the CFA. We use to handle it
117*e4b17023SJohn Marino    as REG + OFFSET all the time,  but now it can be more complex.
118*e4b17023SJohn Marino    It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
119*e4b17023SJohn Marino    Instead of passing around REG and OFFSET, we pass a copy
120*e4b17023SJohn Marino    of this structure.  */
121*e4b17023SJohn Marino typedef struct GTY(()) cfa_loc {
122*e4b17023SJohn Marino   HOST_WIDE_INT offset;
123*e4b17023SJohn Marino   HOST_WIDE_INT base_offset;
124*e4b17023SJohn Marino   /* REG is in DWARF_FRAME_REGNUM space, *not* normal REGNO space.  */
125*e4b17023SJohn Marino   unsigned int reg;
126*e4b17023SJohn Marino   BOOL_BITFIELD indirect : 1;  /* 1 if CFA is accessed via a dereference.  */
127*e4b17023SJohn Marino   BOOL_BITFIELD in_use : 1;    /* 1 if a saved cfa is stored here.  */
128*e4b17023SJohn Marino } dw_cfa_location;
129*e4b17023SJohn Marino 
130*e4b17023SJohn Marino 
131*e4b17023SJohn Marino /* Each DIE may have a series of attribute/value pairs.  Values
132*e4b17023SJohn Marino    can take on several forms.  The forms that are used in this
133*e4b17023SJohn Marino    implementation are listed below.  */
134*e4b17023SJohn Marino 
135*e4b17023SJohn Marino enum dw_val_class
136*e4b17023SJohn Marino {
137*e4b17023SJohn Marino   dw_val_class_none,
138*e4b17023SJohn Marino   dw_val_class_addr,
139*e4b17023SJohn Marino   dw_val_class_offset,
140*e4b17023SJohn Marino   dw_val_class_loc,
141*e4b17023SJohn Marino   dw_val_class_loc_list,
142*e4b17023SJohn Marino   dw_val_class_range_list,
143*e4b17023SJohn Marino   dw_val_class_const,
144*e4b17023SJohn Marino   dw_val_class_unsigned_const,
145*e4b17023SJohn Marino   dw_val_class_const_double,
146*e4b17023SJohn Marino   dw_val_class_vec,
147*e4b17023SJohn Marino   dw_val_class_flag,
148*e4b17023SJohn Marino   dw_val_class_die_ref,
149*e4b17023SJohn Marino   dw_val_class_fde_ref,
150*e4b17023SJohn Marino   dw_val_class_lbl_id,
151*e4b17023SJohn Marino   dw_val_class_lineptr,
152*e4b17023SJohn Marino   dw_val_class_str,
153*e4b17023SJohn Marino   dw_val_class_macptr,
154*e4b17023SJohn Marino   dw_val_class_file,
155*e4b17023SJohn Marino   dw_val_class_data8,
156*e4b17023SJohn Marino   dw_val_class_decl_ref,
157*e4b17023SJohn Marino   dw_val_class_vms_delta
158*e4b17023SJohn Marino };
159*e4b17023SJohn Marino 
160*e4b17023SJohn Marino /* Describe a floating point constant value, or a vector constant value.  */
161*e4b17023SJohn Marino 
162*e4b17023SJohn Marino typedef struct GTY(()) dw_vec_struct {
163*e4b17023SJohn Marino   unsigned char * GTY((length ("%h.length"))) array;
164*e4b17023SJohn Marino   unsigned length;
165*e4b17023SJohn Marino   unsigned elt_size;
166*e4b17023SJohn Marino }
167*e4b17023SJohn Marino dw_vec_const;
168*e4b17023SJohn Marino 
169*e4b17023SJohn Marino /* The dw_val_node describes an attribute's value, as it is
170*e4b17023SJohn Marino    represented internally.  */
171*e4b17023SJohn Marino 
172*e4b17023SJohn Marino typedef struct GTY(()) dw_val_struct {
173*e4b17023SJohn Marino   enum dw_val_class val_class;
174*e4b17023SJohn Marino   union dw_val_struct_union
175*e4b17023SJohn Marino     {
176*e4b17023SJohn Marino       rtx GTY ((tag ("dw_val_class_addr"))) val_addr;
177*e4b17023SJohn Marino       unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_offset"))) val_offset;
178*e4b17023SJohn Marino       dw_loc_list_ref GTY ((tag ("dw_val_class_loc_list"))) val_loc_list;
179*e4b17023SJohn Marino       dw_loc_descr_ref GTY ((tag ("dw_val_class_loc"))) val_loc;
180*e4b17023SJohn Marino       HOST_WIDE_INT GTY ((default)) val_int;
181*e4b17023SJohn Marino       unsigned HOST_WIDE_INT GTY ((tag ("dw_val_class_unsigned_const"))) val_unsigned;
182*e4b17023SJohn Marino       double_int GTY ((tag ("dw_val_class_const_double"))) val_double;
183*e4b17023SJohn Marino       dw_vec_const GTY ((tag ("dw_val_class_vec"))) val_vec;
184*e4b17023SJohn Marino       struct dw_val_die_union
185*e4b17023SJohn Marino 	{
186*e4b17023SJohn Marino 	  dw_die_ref die;
187*e4b17023SJohn Marino 	  int external;
188*e4b17023SJohn Marino 	} GTY ((tag ("dw_val_class_die_ref"))) val_die_ref;
189*e4b17023SJohn Marino       unsigned GTY ((tag ("dw_val_class_fde_ref"))) val_fde_index;
190*e4b17023SJohn Marino       struct indirect_string_node * GTY ((tag ("dw_val_class_str"))) val_str;
191*e4b17023SJohn Marino       char * GTY ((tag ("dw_val_class_lbl_id"))) val_lbl_id;
192*e4b17023SJohn Marino       unsigned char GTY ((tag ("dw_val_class_flag"))) val_flag;
193*e4b17023SJohn Marino       struct dwarf_file_data * GTY ((tag ("dw_val_class_file"))) val_file;
194*e4b17023SJohn Marino       unsigned char GTY ((tag ("dw_val_class_data8"))) val_data8[8];
195*e4b17023SJohn Marino       tree GTY ((tag ("dw_val_class_decl_ref"))) val_decl_ref;
196*e4b17023SJohn Marino       struct dw_val_vms_delta_union
197*e4b17023SJohn Marino 	{
198*e4b17023SJohn Marino 	  char * lbl1;
199*e4b17023SJohn Marino 	  char * lbl2;
200*e4b17023SJohn Marino 	} GTY ((tag ("dw_val_class_vms_delta"))) val_vms_delta;
201*e4b17023SJohn Marino     }
202*e4b17023SJohn Marino   GTY ((desc ("%1.val_class"))) v;
203*e4b17023SJohn Marino }
204*e4b17023SJohn Marino dw_val_node;
205*e4b17023SJohn Marino 
206*e4b17023SJohn Marino /* Locations in memory are described using a sequence of stack machine
207*e4b17023SJohn Marino    operations.  */
208*e4b17023SJohn Marino 
209*e4b17023SJohn Marino typedef struct GTY(()) dw_loc_descr_struct {
210*e4b17023SJohn Marino   dw_loc_descr_ref dw_loc_next;
211*e4b17023SJohn Marino   ENUM_BITFIELD (dwarf_location_atom) dw_loc_opc : 8;
212*e4b17023SJohn Marino   /* Used to distinguish DW_OP_addr with a direct symbol relocation
213*e4b17023SJohn Marino      from DW_OP_addr with a dtp-relative symbol relocation.  */
214*e4b17023SJohn Marino   unsigned int dtprel : 1;
215*e4b17023SJohn Marino   int dw_loc_addr;
216*e4b17023SJohn Marino   dw_val_node dw_loc_oprnd1;
217*e4b17023SJohn Marino   dw_val_node dw_loc_oprnd2;
218*e4b17023SJohn Marino }
219*e4b17023SJohn Marino dw_loc_descr_node;
220*e4b17023SJohn Marino 
221*e4b17023SJohn Marino 
222*e4b17023SJohn Marino /* Interface from dwarf2out.c to dwarf2cfi.c.  */
223*e4b17023SJohn Marino extern struct dw_loc_descr_struct *build_cfa_loc
224*e4b17023SJohn Marino   (dw_cfa_location *, HOST_WIDE_INT);
225*e4b17023SJohn Marino extern struct dw_loc_descr_struct *build_cfa_aligned_loc
226*e4b17023SJohn Marino   (dw_cfa_location *, HOST_WIDE_INT offset, HOST_WIDE_INT alignment);
227*e4b17023SJohn Marino extern struct dw_loc_descr_struct *mem_loc_descriptor
228*e4b17023SJohn Marino   (rtx, enum machine_mode mode, enum machine_mode mem_mode,
229*e4b17023SJohn Marino    enum var_init_status);
230*e4b17023SJohn Marino extern bool loc_descr_equal_p (dw_loc_descr_ref, dw_loc_descr_ref);
231*e4b17023SJohn Marino extern enum machine_mode get_address_mode (rtx mem);
232*e4b17023SJohn Marino extern dw_fde_ref dwarf2out_alloc_current_fde (void);
233*e4b17023SJohn Marino 
234*e4b17023SJohn Marino extern unsigned long size_of_locs (dw_loc_descr_ref);
235*e4b17023SJohn Marino extern void output_loc_sequence (dw_loc_descr_ref, int);
236*e4b17023SJohn Marino extern void output_loc_sequence_raw (dw_loc_descr_ref);
237*e4b17023SJohn Marino 
238*e4b17023SJohn Marino /* Interface from dwarf2cfi.c to dwarf2out.c.  */
239*e4b17023SJohn Marino extern void lookup_cfa_1 (dw_cfi_ref cfi, dw_cfa_location *loc,
240*e4b17023SJohn Marino 			  dw_cfa_location *remember);
241*e4b17023SJohn Marino extern bool cfa_equal_p (const dw_cfa_location *, const dw_cfa_location *);
242*e4b17023SJohn Marino 
243*e4b17023SJohn Marino extern void output_cfi (dw_cfi_ref, dw_fde_ref, int);
244*e4b17023SJohn Marino 
245*e4b17023SJohn Marino extern GTY(()) cfi_vec cie_cfi_vec;
246*e4b17023SJohn Marino 
247*e4b17023SJohn Marino /* Interface from dwarf2*.c to the rest of the compiler.  */
248*e4b17023SJohn Marino extern enum dw_cfi_oprnd_type dw_cfi_oprnd1_desc
249*e4b17023SJohn Marino   (enum dwarf_call_frame_info cfi);
250*e4b17023SJohn Marino extern enum dw_cfi_oprnd_type dw_cfi_oprnd2_desc
251*e4b17023SJohn Marino   (enum dwarf_call_frame_info cfi);
252*e4b17023SJohn Marino 
253*e4b17023SJohn Marino extern void output_cfi_directive (FILE *f, struct dw_cfi_struct *cfi);
254*e4b17023SJohn Marino 
255*e4b17023SJohn Marino extern void dwarf2out_decl (tree);
256*e4b17023SJohn Marino extern void dwarf2out_emit_cfi (dw_cfi_ref cfi);
257*e4b17023SJohn Marino 
258*e4b17023SJohn Marino extern void debug_dwarf (void);
259*e4b17023SJohn Marino struct die_struct;
260*e4b17023SJohn Marino extern void debug_dwarf_die (struct die_struct *);
261*e4b17023SJohn Marino extern void dwarf2out_set_demangle_name_func (const char *(*) (const char *));
262*e4b17023SJohn Marino #ifdef VMS_DEBUGGING_INFO
263*e4b17023SJohn Marino extern void dwarf2out_vms_debug_main_pointer (void);
264*e4b17023SJohn Marino #endif
265*e4b17023SJohn Marino 
266*e4b17023SJohn Marino struct array_descr_info
267*e4b17023SJohn Marino {
268*e4b17023SJohn Marino   int ndimensions;
269*e4b17023SJohn Marino   tree element_type;
270*e4b17023SJohn Marino   tree base_decl;
271*e4b17023SJohn Marino   tree data_location;
272*e4b17023SJohn Marino   tree allocated;
273*e4b17023SJohn Marino   tree associated;
274*e4b17023SJohn Marino   struct array_descr_dimen
275*e4b17023SJohn Marino     {
276*e4b17023SJohn Marino       tree lower_bound;
277*e4b17023SJohn Marino       tree upper_bound;
278*e4b17023SJohn Marino       tree stride;
279*e4b17023SJohn Marino     } dimen[10];
280*e4b17023SJohn Marino };
281*e4b17023SJohn Marino 
282*e4b17023SJohn Marino #endif /* GCC_DWARF2OUT_H */
283