Issue 101203.1: Describing Fortran descriptors
Section 5.14, pg 102
Overview:
Adding DW_TAG_descriptor_type to describe descriptors-specific attributes.
Background:
Some languages, such as Fortran, provide types whose values may be dynamically
allocated or associated with a variable under explicit program control. Currently,
these attributes, such as DW_AT_allocated and DW_AT_associated are placed on the
corresponding type DIE. This approach forces creation of duplicate types for a
single Fortran type.
Consider this Fortran example:
type :: dt (l)
integer, len :: l
integer :: arr(l)
end type
integer :: n = 4
contains
subroutine s()
type (dt(n)) :: t1
type (dt(n)), pointer :: t2
type (dt(n)), allocatable :: t3
end subroutine
end
t1, t2 and t3 all share the same type 'dt'. The current DWARF spec
places all descriptor related attributes (DW_AT_data_location, DW_AT_associated
and DW_AT_allocated) on the DW_TAG_structure_type DIE for 'dt'. However, we
can't put all the descriptor specific attributes on the same DW_TAG_structure_type
DIE because there is a need to differentiate between t1, t2 and t3. This forces 3
different 'dt' DW_TAG_structure_type to be created to describe this program.
Proposal:
This would modify the wording to 5.14 "Dynamic Type Properties".
A base or user-defined type may be accessed through a descriptor. A descriptor
is represented in DWARF by the debug information entry with the tag
DW_TAG_descriptor_type. It has a DW_AT_type attribute, whose value is a reference
to a debugging information entry describing a base type, a user-defined type or a
type modifier.
5.14.1 Data Location
The DW_AT_data_location attribute may be used with DW_TAG_descriptor_type that
provides one or more levels of hidden indirection and/or run-time parameters in its
representation. (Rest of text same as current text...)
5.14.2 Allocation and Association Status
The DW_AT_allocated attribute may optionally be used with DW_TAG_descriptor_type
for which objects of the associated type can be explicitly allocated and deallocated.
(Rest of text same as current text...)
The DW_AT_associated attribute may optionally be used with DW_TAG_descriptor_type
for which objects of the associated type can be dynamically associated with other
objects. (Rest of text same as current text...)
The new DWARF for the example program would look like:
$11: DW_TAG_structure_type
DW_AT_name (dt)
$12: DW_TAG_member ...
$13: DW_TAG_descriptor_type ! plain version
DW_AT_data_location (...)
DW_AT_type ($11)
$14: DW_TAG_descriptor_type
DW_AT_data_location (...)
DW_AT_associated (...) ! 'pointer'
DW_AT_type ($11)
$15: DW_TAG_descriptor_type
DW_AT_data_location (...)
DW_AT_allocated (...) ! 'allocatable'
DW_AT_type ($11)
$16: DW_TAG_variable
DW_AT_name (t1)
DW_AT_type ($13)
DW_AT_location (...)
$17: DW_TAG_variable
DW_AT_name (t2)
DW_AT_type ($14)
DW_AT_location (...)
$18: DW_TAG_variable
DW_AT_name (t3)
DW_AT_type ($15)
DW_AT_location (...)
====
Possibly merge with 090824.1
12/27/12 -- Withdrawn, see 121112.1