Hi all,
I am one of the Free Pascal developers and also work on a debugger,
aimed towards Free Pascal.
Now in Pascal there are 'properties'. Maybe you know these from c# which
has something alike. Basically a property is an alias in a structure
that links to other members of the same structure for reading, writing
and/or storage-information.
Example:
type
TMyClass=class
private
FProp: Integer;
FPropIsStored: Boolean;
protected
function GetProp: Integer;
function GetItem(const Index: Integer): string;
public
property IndividualItem[Index: Integer]: string read GetItem;
published
property Prop: Integer read GetProp stored FPropIsStored;
property OtherProp: Integer read FProp write FProp;
property Item2: string index 2 read GetItem;
end;
var
MyClass = TMyClass;
Reading MyClass.Prop effectively calls GetProp.
MyClass.Prop is read-only, and during streaming the information in
FPropIsStored is being used.
MyClass.OtherProp is read/write, and is more or less an alias for the
private FProp field.
MyClass.IndividualItem[6] is accessible like it is an array. And Item2
has a fixed index.
I want to encode this propery into the Dwarf debug-information. At this
moment we only generate debug-information for cases similar to
MyClass.OtherProp by duplicating the debug-information of FProp with
another visibility-class.
I've added the following attributes:
DW_AT_FPC_property_read (0x3230)
DW_AT_FPC_property_write (0x3231)
DW_AT_FPC_property_stored (0x3232)
And then those attributes contain a link to the corresponding
DW_TAG_members. This to keep the debug-information as compact as
possible. Furthermore I've added the tag DW_TAG_FPC_property (0x4230) or
else other debuggers may be confused when they encounter a DW_TAG_member
with only one or more of these specific fpc-attributes.
I'll also have to add something like DW_AT_FPC_property_index to store
the value of a fixed index.
I have two questions:
1. Am I on the good track, or did I miss something?
2. Maybe implementation specific, but maybe someone might have an idea:
to generate the proposed debug-info, I need to add a label to every
DW_TAG_member. Using global labels inside these structures though, may
lead to all kinds of troubles, for example when a linker regards these
labels as the start of a new section. Or on Darwin/macOS. Calculating
the location of these tags is in principle possible I think, but
difficult. Any tips here?
This is a dwarfdump of the class-definition above with my current additions:
< 1><0x00000123> DW_TAG_class_type
DW_AT_name TMyClass
DW_AT_byte_size 0x00000010
< 2><0x0000012e> DW_TAG_inheritance
DW_AT_accessibility DW_ACCESS_public
DW_AT_data_member_location DW_OP_plus_uconst 0
DW_AT_type <GOFF=0x00005122>
< 2><0x00000137> DW_TAG_member
DW_AT_name FProp
DW_AT_data_member_location DW_OP_plus_uconst 8
DW_AT_accessibility DW_ACCESS_private
DW_AT_type <GOFF=0x000000f3>
< 2><0x00000146> DW_TAG_member
DW_AT_name FPropIsStored
DW_AT_data_member_location DW_OP_plus_uconst 12
DW_AT_accessibility DW_ACCESS_private
DW_AT_type <GOFF=0x000057a7>
< 2><0x0000015d> <Unknown TAG value 0x4230>
DW_AT_name IndividualItem
<Unknown AT value 0x3230> <GOFF=0x0000020c>
DW_AT_type <GOFF=0x000057c4>
< 2><0x00000175> <Unknown TAG value 0x4230>
DW_AT_name Prop
<Unknown AT value 0x3230> <GOFF=0x000001ad>
<Unknown AT value 0x3232> <GOFF=0x00000146>
DW_AT_type <GOFF=0x000000f3>
< 2><0x00000187> <Unknown TAG value 0x4230>
DW_AT_name OtherProp
<Unknown AT value 0x3230> <GOFF=0x00000137>
<Unknown AT value 0x3231> <GOFF=0x00000137>
DW_AT_type <GOFF=0x000000f3>
< 2><0x0000019e> <Unknown TAG value 0x4230>
DW_AT_name Item2
<Unknown AT value 0x3230> <GOFF=0x0000020c>
DW_AT_type <GOFF=0x000057c4>
< 2><0x000001ad> DW_TAG_subprogram
DW_AT_name GetProp
DW_AT_prototyped yes(1)
DW_AT_calling_convention
DW_CC_GNU_borland_fastcall_i386
DW_AT_external yes(1)
DW_AT_accessibility DW_ACCESS_protected
DW_AT_type <GOFF=0x000000f3>
DW_AT_low_pc 0x00404840
DW_AT_high_pc 0x00404867
< 3><0x000001ce> DW_TAG_formal_parameter
DW_AT_name this
DW_AT_location 0x7678 DW_OP_breg6-8
DW_AT_artificial yes(1)
DW_AT_type <GOFF=0x00000110>
< 3><0x000001dc> DW_TAG_variable
DW_AT_name $result
DW_AT_location 0x7674 DW_OP_breg6-12
DW_AT_type <GOFF=0x000000f3>
< 3><0x000001ec> DW_TAG_variable
DW_AT_name GETPROP
DW_AT_location 0x7674 DW_OP_breg6-12
DW_AT_type <GOFF=0x000000f3>
< 3><0x000001fc> DW_TAG_variable
DW_AT_name RESULT
DW_AT_location 0x7674 DW_OP_breg6-12
DW_AT_type <GOFF=0x000000f3>
< 2><0x0000020c> DW_TAG_subprogram
DW_AT_name GetItem
DW_AT_prototyped yes(1)
DW_AT_calling_convention
DW_CC_GNU_borland_fastcall_i386
DW_AT_external yes(1)
DW_AT_accessibility DW_ACCESS_protected
DW_AT_type <GOFF=0x000057c4>
DW_AT_low_pc 0x00404870
DW_AT_high_pc 0x00404889
< 3><0x0000022d> DW_TAG_formal_parameter
DW_AT_name this
DW_AT_location 0x7670 DW_OP_breg6-16
DW_AT_artificial yes(1)
DW_AT_type <GOFF=0x00000110>
< 3><0x0000023b> DW_TAG_variable
DW_AT_name $result
DW_AT_location 0x766806
DW_OP_breg6-24 DW_OP_deref
DW_AT_type <GOFF=0x000057c4>
< 3><0x0000024c> DW_TAG_formal_parameter
DW_AT_name Index
DW_AT_location 0x7678 DW_OP_breg6-8
DW_AT_type <GOFF=0x000000f3>
< 3><0x0000025a> DW_TAG_variable
DW_AT_name GETITEM
DW_AT_location 0x766806
DW_OP_breg6-24 DW_OP_deref
DW_AT_type <GOFF=0x000057c4>
< 3><0x0000026b> DW_TAG_variable
DW_AT_name RESULT
DW_AT_location 0x766806
DW_OP_breg6-24 DW_OP_deref
DW_AT_type <GOFF=0x000057c4>
_______________________________________________
Dwarf-Discuss mailing list
Dwarf-Discuss@lists.dwarfstd.org
http://lists.dwarfstd.org/listinfo.cgi/dwarf-discuss-dwarfstd.org