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