In Ada, it is possible for a scalar type to have a biased representation in some contexts. For instance:

   1     type Small_Type is range 50 .. 57;
   3     type Record_Type is record
   4        A, B : Small_Type;
   5     end record;
   6     for Record_Type use record
   7        A at 0 range 0 .. 2;
   8        B at 0 range 3 .. 5;
   9     end record;

In Record_Type, the A and B fields will be represented on 3 bits each. This is possible because they have a biased representation:

So in this example, the representation for A and B have a bias of 50. The general principle is that given some type T, a bias B and a value V, the runtime representation for V is:

   V - B

There is no way to describe this representation in DWARF today.

Proposed extension

One new attribute is proposed to lift this limitation: DW_AT_GNU_bias, whose form is any constant form and which represents an integer (unsigned, unless the form represents a signed one). This attribute can appear on DW_TAG_subrange_type DIEs. The corresponding subrange and only this one must be decoded using the bias.

The bias is not inheritted in subranges that reference this one so that bias processing is consistent with bounds processing (DW_AT_lower_bound, DW_AT_upper_bound).

None: DW_AT_GNU_bias (last edited 2015-08-18 10:14:45 by pmderodat)