summaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.h
diff options
context:
space:
mode:
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>2015-12-17 14:09:36 +0000
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>2015-12-17 14:09:36 +0000
commitb20f41dd0c51e02bbe209ecf87ed37722984b673 (patch)
tree6573f30c629ae8d30ba6fe9220f370a4f44bd927 /gcc/dwarf2out.h
parentf78f10d634c81efcc0b64b006dd70d1ac44fcc4c (diff)
downloadgcc-b20f41dd0c51e02bbe209ecf87ed37722984b673.tar.gz
DWARF: handle variable-length records and variant parts
Enhance the DWARF back-end to emit proper descriptions for variable-length records as well as variant parts in records. In order to achieve this, generate DWARF expressions ("location descriptions" in dwarf2out's parlance) for size and data member location attributes. Also match QUAL_UNION_TYPE data types as variant parts, assuming the formers appear only to implement the latters (which is the case at the moment: only the Ada front-end emits them). Note that very few debuggers can handle these descriptions (GDB does not yet), so in order to ease the the transition enable these only when -fgnat-encodings=minimal. gcc/ada/ChangeLog: * gcc-interface/decl.c (gnat_to_gnu_entity): Disable ___XVS GNAT encodings when -fgnat-encodings=minimal. (components_to_record): Disable ___XVE, ___XVN, ___XVU and ___XVZ GNAT encodings when -fgnat-encodings=minimal. * gcc-interface/utils.c (maybe_pad_type): Disable __XVS GNAT encodings when -fgnat-encodings=minimal. gcc/ChangeLog: * debug.h (struct gcc_debug_hooks): Add a new size_function hook. * debug.c (do_nothing_debug_hooks): Set the size_function field to no-op. * dbxout.c (dbx_debug_hooks, xcoff_debug_hooks): Likewise. * sdbout.c (sdb_debug_hooks): Likewise. * vmsdbgout.c (vmsdbg_debug_hooks): Likewise. * stor-layout.c (finalize_size_functions): Let the debug info back-end know about the implementation of size functions. * dwarf2out.h (dw_discr_list_ref): New typedef. (enum dw_val_class): Add value classes for discriminant values and discriminant lists. (struct dw_discr_value): New structure. (struct dw_val_node): Add discriminant values and discriminant lists to the union. (struct dw_loc_descr_node): Add frame_offset_rel and dw_loc_frame_offset (only for checking) fields to handle DWARF procedures generation. (struct dw_discr_list_node): New structure. * dwarf2out.c (dwarf2out_size_function): New. (dwarf2_debug_hooks): Set the size_function field to dwarf2out_size_function. (dwarf2_lineno_debug_hooks): Set the size_function field to no-op. (new_loc_descr): Initialize the dw_loc_frame_offset field. (dwarf_proc_stack_usage_map): New. (dw_val_equal_p): Handle discriminants. (size_of_discr_value): New. (size_of_discr_list): New. (size_of_die): Handle discriminants. (add_loc_descr_to_each): New. (add_loc_list): New. (print_discr_value): New. (print_dw_val): Handle discriminants. (value_format): Handle discriminants. (output_discr_value): New. (output_die): Handle discriminants. (output_loc_operands): Handle DW_OP_call2 and DW_OP_call4. (uint_loc_descriptor): New. (uint_comparison_loc_list): New. (loc_list_from_uint_comparison): New. (add_discr_value): New. (add_discr_list): New. (AT_discr_list): New. (loc_descr_to_next_no_op): New. (free_loc_descr): New. (loc_descr_without_nops): New. (struct loc_descr_context): Add a dpi field. (struct dwarf_procedure_info): New helper structure. (new_dwarf_proc_die): New. (is_handled_procedure_type): New. (resolve_args_picking_1): New. (resolve_args_picking): New. (function_to_dwarf_procedure): New. (copy_dwarf_procedure): New. (copy_dwarf_procs_ref_in_attrs): New. (copy_dwarf_procs_ref_in_dies): New. (break_out_comdat_types): Copy DWARF procedures along with the types that reference them. (loc_list_from_tree): Rename into loc_list_from_tree_1. Handle CALL_EXPR in the cases suitable for DWARF procedures. Handle for PARM_DECL when generating a location description for a DWARF procedure. Handle big unsigned INTEGER_CST nodes. Handle NON_LVALUE_EXPR, EXACT_DIV_EXPR and all unsigned comparison operators. Add a wrapper for loc_list_from_tree that strips DW_OP_nop operations from the result. (type_byte_size): New. (struct vlr_context): New helper structure. (field_byte_offset): Change signature to return either a constant offset or a location description for dynamic ones. Handle dynamic byte offsets with constant bit offsets and handle fields in variant parts. (add_data_member_location): Change signature to handle dynamic member offsets and fields in variant parts. Update call to field_byte_offset. Handle location lists. Emit a variable data member location only when -fgnat-encodings=minimal. (add_bound_info): Emit self-referential bounds only when -fgnat-encodings=minimal. (add_byte_size_attribute): Use type_byte_size in order to handle dynamic type sizes. Emit variable byte size only when -fgnat-encodings=minimal and when the target DWARF version allows them. (add_bit_offset_attribute): Change signature to handle variable-length records. Update call to field_byte_offset. (gen_descr_array_type_die): Update call to gen_field_die. Update loc_descr_context literal. (gen_type_die_for_member): Likewise. (gen_subprogram_die): Update calls to get_decl_die. (gen_field_die): Change signature to handle variable-length records. Update calls to add_bit_offset_attribute and add_data_member_location_attribute. (gen_inheritance_die): Update call to add_data_member_location_attribute. (gen_decl_die): Change signature to handle variable-length records. Update call to gen_field_die. (gen_inheritance_die): Change signature to handle variable-length records. Update call to add_data_member_location_attribute. (is_variant_part): New. (analyze_discr_in_predicate): New. (get_discr_value): New. (analyze_variants_discr): New. (gen_variant_part): New. (gen_member_die): Update calls to gen_decl_die. Call instead gen_variant_part for variant parts. (gen_type_die_with_usage): Update calls to gen_decl_die. (process_scope_var): Likewise. (force_decl_die): Likewise. (declare_in_namespace): Likewise. (dwarf2out_decl): Likewise. (prune_unused_types_walk_loc_descr): New. (prune_unused_types_walk_attribs): Mark DIEs referenced by location descriptions and loc. descr. lists. (prune_unused_types_walk): Don't mark DWARF procedures by default. Mark variant parts since nothing is supposed to reference them. (dwarf2out_init): Allocate dwarf_proc_stack_usage_map. (dwarf2out_c_finalize): Deallocate and reset dwarf_proc_stack_usage_map. gcc/testsuite/ChangeLog: * gnat.dg/specs/debug1.ads: Update the expected number of DW_AT_artificial attribute in compiler output. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@231762 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/dwarf2out.h')
-rw-r--r--gcc/dwarf2out.h50
1 files changed, 49 insertions, 1 deletions
diff --git a/gcc/dwarf2out.h b/gcc/dwarf2out.h
index 4fe3527326a..4303e60b55f 100644
--- a/gcc/dwarf2out.h
+++ b/gcc/dwarf2out.h
@@ -29,6 +29,7 @@ typedef struct dw_val_node *dw_val_ref;
typedef struct dw_cfi_node *dw_cfi_ref;
typedef struct dw_loc_descr_node *dw_loc_descr_ref;
typedef struct dw_loc_list_struct *dw_loc_list_ref;
+typedef struct dw_discr_list_node *dw_discr_list_ref;
typedef wide_int *wide_int_ptr;
@@ -150,7 +151,9 @@ enum dw_val_class
dw_val_class_data8,
dw_val_class_decl_ref,
dw_val_class_vms_delta,
- dw_val_class_high_pc
+ dw_val_class_high_pc,
+ dw_val_class_discr_value,
+ dw_val_class_discr_list
};
/* Describe a floating point constant value, or a vector constant value. */
@@ -161,6 +164,25 @@ struct GTY(()) dw_vec_const {
unsigned elt_size;
};
+/* Describe a single value that a discriminant can match.
+
+ Discriminants (in the "record variant part" meaning) are scalars.
+ dw_discr_list_ref and dw_discr_value are a mean to describe a set of
+ discriminant values that are matched by a particular variant.
+
+ Discriminants can be signed or unsigned scalars, and can be discriminants
+ values. Both have to be consistent, though. */
+
+struct GTY(()) dw_discr_value {
+ int pos; /* Whether the discriminant value is positive (unsigned). */
+ union
+ {
+ HOST_WIDE_INT GTY ((tag ("0"))) sval;
+ unsigned HOST_WIDE_INT GTY ((tag ("1"))) uval;
+ }
+ GTY ((desc ("%1.pos"))) v;
+};
+
struct addr_table_entry;
/* The dw_val_node describes an attribute's value, as it is
@@ -197,6 +219,8 @@ struct GTY(()) dw_val_node {
char * lbl1;
char * lbl2;
} GTY ((tag ("dw_val_class_vms_delta"))) val_vms_delta;
+ dw_discr_value GTY ((tag ("dw_val_class_discr_value"))) val_discr_value;
+ dw_discr_list_ref GTY ((tag ("dw_val_class_discr_list"))) val_discr_list;
}
GTY ((desc ("%1.val_class"))) v;
};
@@ -210,11 +234,35 @@ struct GTY((chain_next ("%h.dw_loc_next"))) dw_loc_descr_node {
/* Used to distinguish DW_OP_addr with a direct symbol relocation
from DW_OP_addr with a dtp-relative symbol relocation. */
unsigned int dtprel : 1;
+ /* For DW_OP_pick operations: true iff. it targets a DWARF prodecure
+ argument. In this case, it needs to be relocated according to the current
+ frame offset. */
+ unsigned int frame_offset_rel : 1;
int dw_loc_addr;
+#if ENABLE_CHECKING
+ /* When translating a function into a DWARF procedure, contains the frame
+ offset *before* evaluating this operation. It is -1 when not yet
+ initialized. */
+ int dw_loc_frame_offset;
+#endif
dw_val_node dw_loc_oprnd1;
dw_val_node dw_loc_oprnd2;
};
+/* A variant (inside a record variant part) is selected when the corresponding
+ discriminant matches its set of values (see the comment for dw_discr_value).
+ The following datastructure holds such matching information. */
+
+struct GTY(()) dw_discr_list_node {
+ dw_discr_list_ref dw_discr_next;
+
+ dw_discr_value dw_discr_lower_bound;
+ dw_discr_value dw_discr_upper_bound;
+ /* This node represents only the value in dw_discr_lower_bound when it's
+ zero. It represents the range between the two fields (bounds included)
+ otherwise. */
+ int dw_discr_range;
+};
/* Interface from dwarf2out.c to dwarf2cfi.c. */
extern struct dw_loc_descr_node *build_cfa_loc