[Dwarf-discuss] Proposal: Add support for "property" with getter/setter (based on Pascal properties)

Adrian Prantl aprantl@apple.com
Fri Jun 7 23:12:08 GMT 2024


Hello Martin,

Thanks for submitting your proposal! In order to prepare it for discussion I would suggest to first try pick a first choice for all the design options in the proposal and then once the direction is clear, distill the normative text changes that would need to be made in the DWARF specification.

Adding a new TAG called DW_TAG_property seems like a good approach. There is nothing that's overly specific about Pascal in the proposal, so using the generic name seems like a good choice.

I had a couple of initial questions that came up while reading through the proposal:

- What does it mean for a property to be default? I couldn't find that defined in the linked FreePascal documentation.
- Why is there both a DW_AT_Default_Property and a DW_TAG_Property_Default?
- What is the purpose of DW_TAG_Property_Stored? Maybe also add an example for this.
- DW_TAG_Property_Argument_List would also benefit from an example.

- If I understand correctly, the purpose of DW_AT_Property_Forward is to reference a getter or setter DW_TAG_subprogram.
  Is there a specific reason you decided for this representation over nesting a DW_TAG_subprogram with a DW_AT_property_getter (true) inside the DW_TAG_property?

- Why isn't the accessibility attribute on the linked DW_TAG_subprogram?

After having read the last example, I think I can answer my question from above: Pascal allows to specify an access path to a (nested) field as the read accessor.

- Why is DW_AT_property_object needed? Couldn't the debugger determine the location from following the DW_AT_Property_Forward link? Related: Does this need to be a new attribute, or could this be DW_AT_location?

thanks,
Adrian

> On May 9, 2024, at 10:48 AM, Cary Coutant via Dwarf-discuss <dwarf-discuss@lists.dwarfstd.org> wrote:
> 
> I've posted this as issue 240507.1.
> 
> -cary
> 
> On Wed, May 8, 2024 at 3:47 AM Martin via Dwarf-discuss <dwarf-discuss@lists.dwarfstd.org> wrote:
> Small correction
> 
>    property MyProp: integer read public MyFunc write MyMember;
> 
> Should be
>    property MyProp: integer read public MyFunc write MyMember; default;
> 
> As I added the  DW_AT_Default_Property flag in the example.
> In FreePascal, this would currently only be valid for properties with 
> array-indexes, but may be extended in future. For the example it just 
> shows where the attribute would go.
> 
> 
> 
> On 08/05/2024 12:35, Martin via Dwarf-discuss wrote:
> > Here are 2 examples of what it would look like
> > 
> > ## Property with different visibility
> > 
> > ```
> >    type
> >      TFoo = class
> >      private
> >        MyMember: integer;
> >        function MyFunc: integer;
> >      protected
> >        // "read public" is currently from oxygene, but may be added to 
> > FreePascal
> >        property MyProp: integer read public MyFunc write MyMember;
> >      end;
> > 
> >      TBar = clall(TFoo)
> >      public
> >        property MyProp; // elevate to public
> >      end;
> > ```
> > 
> > ```
> >    DW_TAG_Structure_type
> >      DW_AT_Name :  "TFoo"
> > L1:
> >      DW_TAG_Member
> >          DW_AT_Name            :  "MyMember"
> >          DW_AT_Type            :  <...>
> >          DW_AT_Member_location :  <...>
> > L2:
> >      DW_TAG_subprogram
> >          DW_AT_Name            :  "MyFunc"
> >          DW_AT_Type            :  <...>
> > 
> >      DW_TAG_Property
> >          DW_AT_Name             :  "MyProp"
> >          DW_AT_Type             :  <...>
> >          DW_AT_Accessibility    :  DW_ACCESS_protected
> >          DW_AT_Default_Property :  TRUE
> >        DW_TAG_Property_Getter
> >            DW_AT_Property_Forward :  reference to L2
> >            DW_AT_Accessibility    :  DW_ACCESS_public
> >        DW_TAG_Property_Setter
> >            DW_AT_Property_Forward :  reference to L1
> > 
> >    DW_TAG_Structure_type
> >      DW_AT_Name :  "TBar"
> >      DW_TAG_Inheritance
> >          <...>
> >      DW_TAG_Property
> >          DW_AT_Name             :  "MyProp"
> >          DW_AT_Accessibility    :  DW_ACCESS_public
> > ```
> > 
> > ## Property with access to nested field
> > 
> > 
> > ```
> >    type
> >      TFoo = class
> >        OtherData: DWORD;
> >        FNested: record
> >          MyMember: integer;
> >        end;
> >        property MyProp: integer read FNested.MyMember;
> >      end;
> > ```
> > 
> > ```
> > L1:
> >    DW_TAG_Structure_type
> > L2:
> >      DW_TAG_Member
> >          DW_AT_Name            :  "MyMember"
> >          DW_AT_Type            :  <...>
> >          DW_AT_Member_location :  <...>    ! inside FNested
> > 
> >    DW_TAG_Structure_type
> >      DW_AT_Name :  "TFoo"
> >      DW_TAG_Member
> >          DW_AT_Name :  "OtherData"
> >      DW_TAG_Member
> >          DW_AT_Name :  "FNested"
> >          DW_AT_Type            :  reference to L1
> >          DW_AT_Member_location :
> >                DW_OP_plus_uconst 4             ! where 4 == offset of 
> > MyMember in the instance data
> > 
> >      DW_TAG_Property
> >          DW_AT_Name             :  "MyProp"
> >          DW_AT_Type             :  <...>
> >        DW_TAG_Property_Getter
> >            DW_AT_Property_Forward :  reference to L2
> >            DW_AT_Property_Object  :
> >                DW_OP_push_object_address  ! maybe should be on stack by 
> > default
> >                DW_OP_plus_uconst 4        ! where 4 == offset of 
> > MyMember in the instance data
> >                                           ! There could be several 
> > levels of nesting, so that expression could be more complex
> > ```
> > 
> > In the example the property does not have a reference to FNested itself. 
> > All it needs is the object_address of FNested, so it can calculate the 
> > location of the referenced field MyMember (using the member_location).
> > 
> > 
> 
> -- 
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
> -- 
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss



More information about the Dwarf-discuss mailing list