DWARF Standard


HOME
SPECIFICATIONS
FAQ
ISSUES



130318.1 Kendrick Wong DW_TAG_descriptor_type to describe descriptors Enhancement Accepted Kendrick Wong


Section 5.14, pg 
Applicable to Section 5.14 - Dynamic Type Properties

Overview:
Fortran objects are often accessed through a descriptor, with the address of the actual 
raw data embedded within the descriptor. (A descriptor has often been called a dope vector
in other contexts, although it is often a structure of some kind rather than a simple vector).
This proposal adds a DW_TAG_descriptor_type to describe such descriptor.

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 type DIE.  This approach, in some
cases, forces creation of multiple type DIEs for a single Fortran type.

Consider this Fortran example with parameterized derived type:
      program sample

      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, t4
      end subroutine

      end sample

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:

$21: DW_TAG_structure_type                      ! plain version
      DW_AT_name (dt)
      DW_AT_data_location (dwarf expression to locate raw data)
$21a:  DW_TAG_member ...
     
$22: DW_TAG_structure_type                      ! 'pointer' version
      DW_AT_name (dt)
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_associated (dwarf expression to test if associated)
$22a:  DW_TAG_member ...

$23: DW_TAG_structure_type                      ! 'allocatable' version
      DW_AT_name (dt)
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_allocated (dwarf expression to test is allocated)
$23a:  DW_TAG_member ...

$24: DW_TAG_variable
      DW_AT_name (t1)
      DW_AT_type ($21)
      DW_AT_location (dwarf expression to locate descriptor)
$25: DW_TAG_variable
      DW_AT_name (t2)
      DW_AT_type ($22)
      DW_AT_location (dwarf expression to locate descriptor)
$26: DW_TAG_variable
      DW_AT_name (t3)
      DW_AT_type ($23)
      DW_AT_location (dwarf expression to locate descriptor)
$27: DW_TAG_variable
      DW_AT_name (t4)
      DW_AT_type ($23)
      DW_AT_location (dwarf expression to locate descriptor)

An alternative approach is to place the descriptor related attributes on 
the variable, but doing so would cause t3 and t4 to have the same dynamic 
type attributes, which is also less than optimal:

$31: DW_TAG_structure_type
      DW_AT_name (dt)
$31a:  DW_TAG_member ...

$32: DW_TAG_variable                            ! plain version
      DW_AT_name (t1)
      DW_AT_type ($31)
      DW_AT_location (dwarf expression to locate descriptor)
      DW_AT_data_location (dwarf expression to locate raw data)
$33: DW_TAG_variable                            ! 'pointer' version
      DW_AT_name (t2)
      DW_AT_type ($31)
      DW_AT_location (dwarf expression to locate descriptor)
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_associated (dwarf expression to test if associated)
$34: DW_TAG_variable                            ! 'allocatable' version
      DW_AT_name (t3)
      DW_AT_type ($31)
      DW_AT_location (dwarf expression to locate descriptor)
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_allocated (dwarf expression to test is allocated)
$35: DW_TAG_variable                            ! 'allocatable' version
      DW_AT_name (t4)
      DW_AT_type ($31)
      DW_AT_location (dwarf expression to locate descriptor)
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_allocated (dwarf expression to test is allocated)

Proposal:

Revise Section 5.14: "Dynamic Type Properties"

Some languages may represent objects using descriptors to hold information, including a 
location and/or run-time parameters, about the data that reprsent the value for that object. 

A descriptor is represented by a debugging information entry with the tag 
DW_TAG_descriptor_type. The descriptor type 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 descriptor type 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)
$11a:  DW_TAG_member ...

$13: DW_TAG_descriptor_type                     ! plain version
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_type ($11)

$14: DW_TAG_descriptor_type                     ! 'pointer' version
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_associated (dwarf expression to test if associated)
      DW_AT_type ($11)

$15: DW_TAG_descriptor_type                     ! 'allocatable' version
      DW_AT_data_location (dwarf expression to locate raw data)
      DW_AT_allocated (dwarf expression to test is allocated)
      DW_AT_type ($11)

$16: DW_TAG_variable
      DW_AT_name (t1)
      DW_AT_type ($13)
      DW_AT_location (dwarf expression to locate descriptor)
$17: DW_TAG_variable
      DW_AT_name (t2)
      DW_AT_type ($14)
      DW_AT_location (dwarf expression to locate descriptor)
$18: DW_TAG_variable
      DW_AT_name (t3)
      DW_AT_type ($15)
      DW_AT_location (dwarf expression to locate descriptor)
$19: DW_TAG_variable
      DW_AT_name (t4)
      DW_AT_type ($15)
      DW_AT_location (dwarf expression to locate descriptor)
      
Appendix A:
Add to Figure 42: List of attributes allowed on DW_TAG_descriptor_type
DW_TAG_descriptor_type
  DW_AT_allocated
  DW_AT_associated
  DW_AT_data_location
  DW_AT_type
  DW_AT_sibling 

---
7/23/2013 - Accepted.
10/21/2013 - Updated to expand background and changes to standard Appendix A.


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.