On Mon, 2016-11-14 at 12:08 +0100, Pierre-Marie de Rodat wrote: > Thank you for your answer! > > On 11/10/2016 01:38 PM, Mark Wielaard wrote: > > IMHO having an explicit DW_AT_type pointing at the base type with size > > and encoding for the DW_TAG_enumerator_type is better for consumers than > > having to try and interpret the DW_FORM used to encode the values. > > I’m curious about why you think this alternative is better for > consumers: after all, they always have to interpret the DW_FORM anyway > in order to decode the DIE stream.
Right, this comes from having these untyped (and unsized) forms in the constant class. And the constant class being used with and without context about how to interpret the constant (is it a bit pattern or a value). In this particular case the value is represented through a DW_AT_const_value attribute which can also be represented in block form. Without (type) context you also don't know anything about the size. You can either choose a signed/unsigned form not giving the consumer a hint about the size of the underlying constant value or one of the sized data forms that don't give a hint about the value representation/signedness. So in both cases the consumer looses without an actual (base) type telling them how to interpret the constant. If the type/context is known then for a consumer it is easy to just have a read signed/unsigned value method for attributes that provide a constant/value which doesn't care about the underlying form. That also means the producer can choose the smallest representation of the data without worrying that the consumer might misinterpret the value representation by the specific form chosen. Cheers, Mark