On Fri, Aug 12, 2016 at 07:57:42PM +0200, Jakub Jelinek wrote: > On Fri, Aug 12, 2016 at 01:47:14PM -0400, Jason Merrill wrote: > > On 07/21/2016 12:53 PM, Jakub Jelinek wrote: > > > size = int_size_in_bytes (TREE_TYPE (szdecl)); > > ... > > >+ if (size != DWARF2_ADDR_SIZE) > > >+ add_AT_unsigned (array_die, DW_AT_byte_size, size); > > > > For DWARF5, where DW_AT_byte_size is always the size of the array type, I > > think this should be DW_AT_string_length_byte_size. > > Sure, but this is just reindenting existing code, > DW_AT_string_length_byte_size isn't yet in dwarf2.def nor anywhere else. > When DWARF5 will make it into the public beta, I'll try to spend some time > on implementing the 5 support, but I think it would be better done > incrementally then, not part of this patch.
I've committed the patch with following incremental patch on top of it for the trunk (and for 6.2 just the original patch): 2016-08-15 Jakub Jelinek <ja...@redhat.com> * dwarf2.def (DW_AT_string_length_bit_size, DW_AT_string_length_byte_size): New attributes. * dwarf2out.c (struct checksum_attributes): Add at_string_length_bit_size and at_string_length_byte_size fields. (collect_checksum_attributes): Handle DW_AT_string_length_bit_size and DW_AT_string_length_byte_size. (die_checksum_ordered): Handle at_string_length_bit_size and at_string_length_byte_size. (gen_array_type_die): For dwarf_version >= 5 emit DW_AT_string_length_byte_size instead of DW_AT_byte_size. (adjust_string_types): For dwarf_version >= 5 remove DW_AT_string_length_byte_size instead of DW_AT_byte_size. (resolve_addr): Likewise. --- include/dwarf2.def.jj 2016-08-12 11:12:47.000000000 +0200 +++ include/dwarf2.def 2016-08-15 11:03:44.742465435 +0200 @@ -309,6 +309,8 @@ DW_AT (DW_AT_const_expr, 0x6c) DW_AT (DW_AT_enum_class, 0x6d) DW_AT (DW_AT_linkage_name, 0x6e) /* DWARF 5. */ +DW_AT (DW_AT_string_length_bit_size, 0x6f) +DW_AT (DW_AT_string_length_byte_size, 0x70) DW_AT (DW_AT_noreturn, 0x87) DW_AT (DW_AT_deleted, 0x8a) DW_AT (DW_AT_defaulted, 0x8b) --- gcc/dwarf2out.c.jj 2016-08-15 11:02:41.000000000 +0200 +++ gcc/dwarf2out.c 2016-08-15 11:11:40.023507518 +0200 @@ -6363,6 +6363,8 @@ struct checksum_attributes dw_attr_node *at_small; dw_attr_node *at_segment; dw_attr_node *at_string_length; + dw_attr_node *at_string_length_bit_size; + dw_attr_node *at_string_length_byte_size; dw_attr_node *at_threads_scaled; dw_attr_node *at_upper_bound; dw_attr_node *at_use_location; @@ -6502,6 +6504,12 @@ collect_checksum_attributes (struct chec case DW_AT_string_length: attrs->at_string_length = a; break; + case DW_AT_string_length_bit_size: + attrs->at_string_length_bit_size = a; + break; + case DW_AT_string_length_byte_size: + attrs->at_string_length_byte_size = a; + break; case DW_AT_threads_scaled: attrs->at_threads_scaled = a; break; @@ -6588,6 +6596,8 @@ die_checksum_ordered (dw_die_ref die, st CHECKSUM_ATTR (attrs.at_small); CHECKSUM_ATTR (attrs.at_segment); CHECKSUM_ATTR (attrs.at_string_length); + CHECKSUM_ATTR (attrs.at_string_length_bit_size); + CHECKSUM_ATTR (attrs.at_string_length_byte_size); CHECKSUM_ATTR (attrs.at_threads_scaled); CHECKSUM_ATTR (attrs.at_upper_bound); CHECKSUM_ATTR (attrs.at_use_location); @@ -19355,7 +19365,9 @@ gen_array_type_die (tree type, dw_die_re add_AT_location_description (array_die, DW_AT_string_length, loc); if (size != DWARF2_ADDR_SIZE) - add_AT_unsigned (array_die, DW_AT_byte_size, size); + add_AT_unsigned (array_die, dwarf_version >= 5 + ? DW_AT_string_length_byte_size + : DW_AT_byte_size, size); } } } @@ -19448,7 +19460,9 @@ adjust_string_types (void) else { remove_AT (array_die, DW_AT_string_length); - remove_AT (array_die, DW_AT_byte_size); + remove_AT (array_die, dwarf_version >= 5 + ? DW_AT_string_length_byte_size + : DW_AT_byte_size); } } } @@ -26909,8 +26923,8 @@ copy_deref_exprloc (dw_loc_descr_ref exp /* For DW_AT_string_length attribute with DW_OP_call4 reference to a variable or argument, adjust it if needed and return: - -1 if the DW_AT_string_length attribute and DW_AT_byte_size attribute - if present should be removed + -1 if the DW_AT_string_length attribute and DW_AT_{string_length_,}byte_size + attribute if present should be removed 0 keep the attribute as is if the referenced var or argument has only DWARF expression that covers all ranges 1 if the attribute has been successfully adjusted. */ @@ -27083,8 +27097,8 @@ resolve_addr (dw_die_ref die) case -1: remove_AT (die, a->dw_attr); ix--; - /* For DWARF4 and earlier, if we drop DW_AT_string_length, - we need to drop also DW_AT_byte_size. */ + /* If we drop DW_AT_string_length, we need to drop also + DW_AT_{string_length_,}byte_size. */ remove_AT_byte_size = true; continue; default: @@ -27181,7 +27195,9 @@ resolve_addr (dw_die_ref die) } if (remove_AT_byte_size) - remove_AT (die, DW_AT_byte_size); + remove_AT (die, dwarf_version >= 5 + ? DW_AT_string_length_byte_size + : DW_AT_byte_size); FOR_EACH_CHILD (die, c, resolve_addr (c)); } Jakub