gdb/DWARF: dynamic subrange type of dynamic subrange type.
authorJoel Brobecker <brobecker@adacore.com>
Mon, 5 Jan 2015 14:39:02 +0000 (18:39 +0400)
committerJoel Brobecker <brobecker@adacore.com>
Thu, 29 Jan 2015 08:05:36 +0000 (12:05 +0400)
commitddb87a81ac5b031da67fb251b2c11a94e9834ae3
treeea1db610084dd2f9986ef1468793804e5917ff11
parent7a270e0c9ba0eb738a4c30258ab29c09963fcd4d
gdb/DWARF: dynamic subrange type of dynamic subrange type.

Consider the following code:

   type Record_Type (N : Integer) is record
      A : Array_Type (1 .. N);
   end record;
   [...]
   R : Record_Type := Get (10);

Trying to print the bounds of the array R.A yielded:

    (gdb) p r.a'last
    $4 = cannot find reference address for offset property

A slightly different example, but from the same cause:

    (gdb) ptype r
    type = <ref> record
        n: integer;
        a: array (cannot find reference address for offset property

Looking at the debugging info, "A" is described as...

        .uleb128 0x11   # (DIE (0x181) DW_TAG_member)
        .ascii "a\0"    # DW_AT_name
        .long   0x15d   # DW_AT_type
        [...]

... which is an array...

        .uleb128 0x12   # (DIE (0x15d) DW_TAG_array_type)
        .long   .LASF18 # DW_AT_name: "foo__record_type__T4b"
        .long   0x194   # DW_AT_type
        .long   0x174   # DW_AT_sibling

... whose bounds are described as:

        .uleb128 0x13   # (DIE (0x16a) DW_TAG_subrange_type)
        .long   0x174   # DW_AT_type
        .long   0x153   # DW_AT_upper_bound
        .byte   0       # end of children of DIE 0x15d

We can see above that the range has an implict lower value of
1, and an upper value which is a reference 0x153="n". All Good.

But looking at the array's subrange subtype, we see...

        .uleb128 0x14   # (DIE (0x174) DW_TAG_subrange_type)
        .long   0x153   # DW_AT_upper_bound
        .long   .LASF19 # DW_AT_name: "foo__record_type__T3b"
        .long   0x18d   # DW_AT_type

... another subrange type whose bounds are exactly described
the same way. So we have a subrange of a subrange, both with
one bound that's dynamic.

What happens in the case above is that GDB's resolution of "R.A"
yields a array whose index type has static bounds. However, the
subtype of the array's index type was left untouched, so, when
taking the subtype of the array's subrange type, we were left
with the unresolved subrange type, triggering the error above.

gdb/ChangeLog:

        * gdbtypes.c (is_dynamic_type_internal) <TYPE_CODE_RANGE>: Return
        nonzero if the type's subtype is dynamic.
        (resolve_dynamic_range): Also resolve the range's subtype.

Tested on x86_64-linux, no regression.
gdb/ChangeLog
gdb/gdbtypes.c
This page took 0.041025 seconds and 4 git commands to generate.