DWARF Standard


161109.1 Jakub Jelinek No way to describe Fortran derived types with deferred length components Error Incomplete Jakub Jelinek

Section 5.11, pg 126
When the producer implements Fortran derived type components with deferred length, e.g.
  type t
    integer :: j
    character(len=:), allocatable :: f
    integer :: i
  end type
like in C:
  struct t
    int j;
    void *f;
    int i;
    int _f_length; // The string length *f points to.
the current DWARF doesn't really allow to express this, at least not in the type
DIEs and their children (basically, for each variable of such type one would have
to create a new distinct set of type DIEs where the DW_AT_string_length attribute 
would use a particular location expression specific to the particular variable.

The problem is that the string length is not stored in the CHARACTER(len=:) 
objects themselves, but is shared by all the elements of the array.  The 
DW_AT_string_length must appear on the DW_TAG_string_type DIE, so 
DW_OP_push_object_address on it pushes the address of a particular array 
element.  Where one can evaluate the string length is the DW_TAG_array_type, 
where one could DW_OP_push_object_address, and is used for DW_AT_data_location 
etc.  We could e.g. allow DW_AT_string_length on DW_AT_array_type and have some
form of DW_AT_string_length or some new attribute on DW_TAG_string_type say that 
DW_AT_string_length location isn't provided here, but on the parent (or grand 
parent etc.) DW_TAG_array_type.  Or have some DW_OP_* that would push address 
of the containing array object instead of the current object's address.

12/06/2016 -- Defer to DWARF Version 6.

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