This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Support for DWARF describing Ada unconstrained arrays


Hello,

The following patch series adds support for Ada unconstrained when
described in the debugging info using standard DWARF constructs.
GNAT current lays out unconstrained arrays using what we call
a "fat pointer", which is a structure with 2 fields, one being
a pointer to the array itself, and one being a pointer to another
structure containing the value of the bounds.

To describe such arrays using standard DWARF constructs instead
of the GNAT encoding, we are modifying the compiler to generate
the following:

 <1><25>: Abbrev Number: 4 (DW_TAG_array_type)
    <26>   DW_AT_name        : foo__array_type
    <36>   DW_AT_type        : <0x1a>
    <3a>   DW_AT_data_location: DW_OP_push_object_address; DW_OP_deref
    <3d>   DW_AT_external    : 1
 <2><3e>: Abbrev Number: 5 (DW_TAG_subrange_type)
    <3f>   DW_AT_type        : <0x1a>
    <43>   DW_AT_lower_bound : DW_OP_push_object_address;
                               DW_OP_plus_uconst: 8; DW_OP_deref;
                               DW_OP_deref_size: 4
    <4a>   DW_AT_upper_bound : DW_OP_push_object_address;
                               DW_OP_plus_uconst: 8; DW_OP_deref;
                               DW_OP_plus_uconst: 4; DW_OP_deref_size: 4)

What this does is that it provides a DW_AT_data_location attribute
which tells us where to look for the array's actual contents.
And it also uses expressions for the array's index bounds.

This requires GDB to support DW_AT_data_location and
DW_OP_push_object_address, which is the goal of the first 2 patches.
The first 2 patches are heavily inspired from the first 2 patches
from Keven Boell's Fortran VLA series #2. Patch #1 only needed some
minor formatting adjustements, but I found that patch #2 had a number
of issues with it (unwanted sharing of the new data location stuff
between original and resolved type, improper allocation of the new
data-location struct, setting value addresses at the wrong place),
and hopefully my version fixes all of them without introducing any
new issues.

Patch #3 is an enhancement in the Ada type "printer" which is required
to start handling dynamic range types.  Otherwise, we get an exception
when trying to "ptype" a dynamic array type.

And patch #4 adds a testcase testing everything I could think of
in terms of command referencing this type of array described using
the DWARF expressions shown above. The use of 2 arrays is deliberate
and there to reveal a bug detected by code inspection in Keven's
version of patch #2.

Everything was tested on x86_64-linux, and pushed.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]