[Dwarf-discuss] Recovering type definitions

Nettleton, Brian brian.nettleton
Thu May 26 14:37:02 GMT 2005


The example isn't as good as it could be.  The standard allows for the
upper bound on the subrange type for field VEC2 to point to N.  In
section 5.11 "Subrange Type Entries" it says that the value of
DW_AT_upper_bound is described in section 2.18 "Static and Dynamic
Properties of Types".  In section 2.18 it says that the value may be "a
reference to another entity whose value is the value of the attribute."
It seems pretty clear to me that it would be fine to have the
DW_AT_upper_bound simply contain a reference to the entry for "N".  So
it's just a matter of compiler implementation quality.

-Brian Nettleton
Wind River Systems


> -----Original Message-----
> From: dwarf-discuss-bounces at base3.freestandards.org 
> [mailto:dwarf-discuss-bounces at base3.freestandards.org] On 
> Behalf Of Paul Hilfinger
> Sent: Wednesday, May 25, 2005 7:59 PM
> To: dwarf-discuss at base3.freestandards.org
> Subject: [Dwarf-discuss] Recovering type definitions
> 
> 
> I was looking at the Ada example in D.2.2, which contains
> 
>     subtype TEENY is INTEGER range 1..100; 
>     type ARR is array (INTEGER range <>) of INTEGER; 
>     type REC2(N : TEENY := 100) is record 
>        VEC2 : ARR(1..N);  -- < 
>     end record; 
> 
> The suggested encoding for the type REC2 gives the location 
> of VEC2's upper bound as a DWARF expression:
> 
>     DW_OP_push_object_address, 
>     DW_OP_lit<n> ! where n == offset(REC2, VEC2) - offset(REC2, N) 
>     DW_OP_neg 
>     DW_OP_plus
> 
> It occurs to me that one has to work a bit to recover from 
> this the information that, e.g., GDB would print in response to 
> 
>     ptype REC2
> 
> which would be expected to resemble the original type 
> declaration to some extent, e.g.,
> 
>      type rec2 is record
>         n : teeny;
> 	vec2: arr ( 1 .. n );
>      end record;
> 
> Indeed, while it is possible to recover that the upper bound 
> is N (by symbolically analyzing the expression and 
> discovering that the indicated location happens to coincide 
> with that of N), it is impossible from the suggested encoding 
> to reproduce the type names Teeny for N and Arr for Vec2 (as 
> the text says, there is no notion of subtype in Dwarf).
> 
> It might seem that the problem of type names could be solved 
> by giving names to the types of n and vec2, but would the 
> resulting name duplication cause confusion?  
> 
> Also, recovering that the upper bound is N in this case looks 
> easy enough, but things look to become harder with more 
> complex types in which several fields are dynamic, as for VEC3 in 
> 
>     type REC3(M, N : TEENY) is record 
>        VEC2 : ARR(M..N);
>        VEC3 : ARR(1..M);
>     end record; 
> 
> (in the particular Ada implementations of interest, VEC2 and 
> VEC3 are unboxed).  I am not sanguine about extracting a 
> general algorithm for 'ptype'-like operations given examples 
> like this.
> 
> Is there a better way of encoding these examples in DWARF?  
> 
> Paul Hilfinger
> AdaCore, Inc.
> 
> 
> 
> 
> 
> _______________________________________________
> Dwarf-discuss mailing list
> Dwarf-discuss at mail.freestandards.org
> http://mail.freestandards.org/mailman/listinfo/dwarf-discuss
> 




More information about the Dwarf-discuss mailing list