Issue 130623.1: DW_AT_string_length_bit_size

Author: Ron Brender
Champion: Ron Brender
Date submitted: 2013-06-23
Date revised:
Date closed:
Type: Enhancement
Status: Accepted
DWARF Version: 5
Section 

Background
----------

During the development of DWARF V4 we made an effort to regularize
the allowed uses of DW_AT_byte_size and DW_AT_bit_size so that they
could be used in all the same places. We stopped short of doing this
for string types because we were reluctant to make its byte size
anomaly even worse.

When we adopted 110110.1 as revised, we added a new
DW_AT_string_length_byte_size
attribute to specify the size of the string length datum itself, but a
parallel DW_AT_string_length_bit_size attribute was not included.

Quite honestly I thought we had added DW_AT_string_length_bit_size as well--
I know I intended to propose we do so to maintain the bit/byte parallelism, but
maybe I missed that discussion. But I can find no justification for that
belief in the minutes.

dwarf5.20130622.pdf reflects my flawed recollection--for which I apologize.
Adopting this proposal will correct that. If this proposal is not adopted, I
will of course have more work to do...

Proposal Text
-------------

Change the whole of 5.11 String Type Entries to read as follows:

*A "string" is a sequence of characters that have specific semantics
and operations that distinguish them from arrays of characters. Fortran is 
one of the languages that has a string type. Note that "string" in this 
context refers to a target machine concept, not the class string as used 
in this document (except for the name attribute).*

A string type is represented by a debugging information entry with the tag
DW_TAG_string_type. If a name has been given to the string type in the source
program, then the corresponding string type entry has a DW_AT_name attribute
whose value is a null-terminated string containing the string type name as it
appears in the source program.

The string type entry may have a DW_AT_byte_size attribute or
DW_AT_bit_size attribute, whose value (see Section 2.21 on page 41) is the
amount of storage needed to hold a value of the string type.

The string type entry may also have a DW_AT_string_length attribute whose
value is a location description yielding the location where the length
of the string is stored in the program. If the DW_AT_string_length attribute 
is not present, the size of the string is assumed to be the amount of storage 
that is allocated for the string (as specified by the DW_AT_byte_size or 
DW_AT_bit_size attribute).

The string type entry may also have a DW_AT_string_length_byte_size attribute
or DW_AT_string_length_bit_size attribute, whose value (see Section 2.21 on
page 41) is the size of the data to be retrieved from the location
referenced by the string length attribute. If no (byte or bit) size 
attribute is present, the size of the data to be retrieved is the same as 
the size of an address on the target machine.

*Prior to DWARF Version 5, the meaning of a DW_AT_byte_size attribute 
depends on the presence of the DW_AT_string_length attribute:
 - If DW_AT_string_length is present, DW_AT_byte_size specifies the size of the
   length data to be retrieved from the location specified by the
   DW_AT_string_length attribute.
 - If DW_AT_string_length is not present, DW_AT_byte_size specifies the amount
   of storage allocated for objects of the string type.
In DWARF Version 5, DW_AT_byte_size always specifies the amount of storage
allocated for objects of the string type.*"

In addition:
 o add DW_AT_string_length_bit_size to Tables 2.2, Table 7.3 (code 0x6f)
   and 7.25
 o add the following to the end of the first paragraph of 2.21:
           "The DW_AT_string_length_byte_size and DW_AT_string_length_bit_size
                attributes are similar."

---

Accepted 8/20/2013.