DWARF Standard


121112.1 Kendrick Wong DW_TAG_refine_type add additional attributes to type Enhancement Withdrawn Kendrick Wong

Section 5 - TYPE ENTRIES, pg 104
Applicable to Section 5 - TYPE ENTRIES
(The next logical subsection is 5.16 - Type Refining Entries)
Adding DW_TAG_refine_type to provide additional attributes to a type without having its base 
type characteristics duplicated.

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 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

subroutine s()
type (dt(n))               :: t1
type (dt(n)), pointer      :: t2
type (dt(n)), allocatable  :: t3
end subroutine


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'.  Doing so would mean we have to generate 3 
different DW_TAG_structure_type DIEs to describe this program.

If we place the descriptor related attributes on the variable, then the descriptor
related attributes would have to be duplicated for each variable of the same type. i.e.
  type (dt(n)), allocatable  :: t3, t4
would result in both t3 and t4 having the same dynamic type attributes.


New subsection to Section 5, tentatively: 5.16 "Type Refining Entries"

Some type attributes are tied more closely to the variable than the type itself.  For
example, Fortran dynamic type properties (i.e. DW_AT_allocated and DW_AT_associated) 
can be different for each variable of the same type.  In such cases, the dynamic type 
properties can be attached to a type refining entry.

A type refining entry is represented by a debugging information entry with the tag 
DW_TAG_refine_type. The type refining entry has a DW_AT_type attribute to describe 
the type of object, whose additional attributes applies to.  Any other attributes 
and/or children debugging information entries on the type refining entry would 
behave identically as if the attributes and/or children DIEs are attached to the 
referencing type entry.

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_refine_type            ! plain version
      DW_AT_data_location (...)
      DW_AT_type ($11)

$14: DW_TAG_refine_type
      DW_AT_data_location (...)
      DW_AT_associated (...)       ! 'pointer'
      DW_AT_type ($11)

$15: DW_TAG_refine_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 (...)

This issue was withdrawn and replaced by 130318.1.
See http://www.dwarfstd.org/ShowIssue.php?issue=130318.1.

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2007-2017 by DWARF Standards Committee.