[Dwarf-Discuss] What is a byte's size?

Michael Eager eager@eagercon.com
Mon Jul 21 17:56:11 GMT 2008


Jan van Dongen wrote:
> Dear Michael,
> 
> You wrote:
>> Jan van Dongen wrote:
>>> Hi,
>>>
>>> I've an issue with one of our users about the meaning of the 
>>> DW_AT_byte_size attribute.
>>>
>>> In my interpretation a value of '1' means '1' minimal addressable 
>>> unit. On an architecture with 16-bit memory, this
>>> then means one '16-bit' byte.
>>>
>>> The user (or actually his debugger provider) interprets the value '1' 
>>> as one '8-bit' byte. Iow: a byte is always
>>> 8-bit in size. A 16-bit 'short int' then should have a 
>>> 'DW_AT_byte_size' with value '2'.
>>>
>>> The DWARF3 standard defines: A base type entry has a DW_AT_byte_size 
>>> attribute, whose value (see Section 2.19) is the
>>> size in bytes of the storage unit used to represent an object of the 
>>> given type.
>>>
>>> The phrase 'bytes of the storage unit used' to me explains that the 
>>> size of a byte depends on the architecture and
>>> thus is not an 8-bit entity by definition. Unfortunately, the DWARF 
>>> document nowhere gives an explanation of the term
>>> 'byte'.
>>>
>>> Even worse, of course a 'byte' in an object file does not have to 
>>> match a 'byte' on the architecture, so there can be
>>> confusion everywhere.
>>>
>>> Can anyone provide me the proper interpretation?
>>>
>>> Kind regards, Jan van Dongen
>>
>> Section 5.1 of the DWARF 3 Standard has this definition of 
>> DW_AT_byte_size:
>>    A base type entry has a DW_AT_byte_size attribute, whose value (see 
>> Section 2.19)
>>    is the size in bytes of the storage unit used to represent an 
>> object of the given type.
>>
>> "Storage unit" in this sentence is the container (e.g., memory) which 
>> contains
>> an object of a particular type.  "Storage unit" is only used in this 
>> section and
>> in the other two uses it is clear that it is describing a container of 
>> arbitrary
>> size, not referring to an architecture-dependent addressing unit.
>>
>> Unfortunately, the standard doesn't explicitly define 'byte'.  If it 
>> did, this
>> possible ambiguity would not arise.  Byte is used with a single 
>> consistent
>> machine-independent fashion throughout the standard.
> 
> Somehow I feel stupid to ask these questions, but I have to be sure:

Don't be concerned.  It's much better if you confirm assumptions.

> This container 'container of arbitrary size' then is something the producer
> (compiler) and consumer (debugger) have to agree on.

Nope.  The container's size is described by the DW_AT_byte_size attribute.

A double float type would normally be contained in a "storage
unit" which had DW_AT_byte_size = 8.  There's nothing that the
compiler and debugger have to agree upon; it's explicit in the
type description.

-- 
Michael Eager	 eager at eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077




More information about the Dwarf-discuss mailing list