[Dwarf-discuss] Encoding variant records: request for clarification.

Ron Brender ron.brender
Sat Aug 19 14:59:35 GMT 2006


Ahhh, now I understand the question. And it is a good one at that!
It appears that Section 5.6.9 in Version 3 survives unchanged from 
Version 2 (where the Section number was different). I don't recall any 
discussion of this particular matter during V3 development.

My take is

1) It is perfectly reasonable for the DW_TAG_variant_part in this 
example to not have any member child (just the DW_TAG_variant children).

2) The DW_AT_discr attribute of the DW_TAG_variant_part entry should 
refer to the earlier member entry for N as usual.

The wording in S5.6.9 does not obviously allow this, although it does 
allow no member child for a tagless variant (a Pascal thing, yes?). The 
text should be revised to clarify this. Further your example would be a 
good addition in D.2.2.

While we are at it, the third paragraph of 5.6.9 has me puzzled as to 

"If the variant part does not have a discriminant (tag field), the 
variant part entry has a DW_AT_type attribute to represent the tag type."

My puzzlement being: how can a non-existent tag have/need a type? What 
am I missing?


Paul Hilfinger wrote:
> Evidently, I did not make the source of my confusion sufficiently clear.
> Again, the type in question is
>      type R (N : Integer) is record
>         Data : String (1 .. N);
>         case N is
>         when 0 =>
>             Name : String (1 .. N);
>         when 1..20 =>
>             Id, Port : Integer;
>         when others =>
>             null;
>         end case;
>      end record;
> Both responders said essentially the same thing, viz.,
>> I think the answer to this question is covered by the example type REC2 
>> presented in D.2.2. See Figure 53 on p197 in particular. The key point, 
>> I think, is that there is only one entity named N and the other uses of 
>> N are references to it.
> Yes, I saw that section, and it's nice as far as it goes.  However, my
> issue was with the treatment of N in "case N is" part.  The Dwarf 3 
> standard says (5.6.9, pg. 79):
>     If the variant part has a discriminant, the discriminant is represented
>     by a separate debugging information entry which is a ->>CHILD OF THE 
>     VARIANT PART ENTRY.<<- ... The variant part entry will have a 
>     DW_AT_discr attribute whose value is a reference to the member entry
>     for the discriminant.
> So field N would be a child of the variant_part representing 
>    case N is ... end case
> But N is ALREADY a child of the structure_type (or whatever) that represents
>     type R (N: Integer) is record ... end record;
> So what gives?
> Thanks for your help.
> Paul Hilfinger

More information about the Dwarf-discuss mailing list