[fpc-devel] Help/Guidance please: Dwarf support for properties

Martin Frb lazarus at mfriebe.de
Sat Apr 27 13:45:52 CEST 2024


Ok, I would like to start another attempt to support properties when 
using fpdebug as debugger.

The idea is to add custom tags in the dwarf info. This can be done by a 
new option -godwarfporperties
Though, it may be better to go with -godwarffpdbg / similar to -godwarfcpp

Making it fpdebug specific will allow to add other info, that would 
benefit debugging Pascal, but isn't in Dwarf...


In 2022 Joost did an attempt:
https://gitlab.com/freepascal.org/fpc/source/-/compare/main...joost%2Fdwarfproperties?from_project_id=28644964&straight=false

I didn't understand the reasons behind (but then I am not familiar with 
the FPC codebase).
I do now get some guesses as to why...

-----------------
But anyway, I started my own attempt based on that.
https://gitlab.com/martin_frb/fpc-src/-/compare/main...martin-dwarf-properties?from_project_id=28644964&straight=false

The first problem is getting labels for items that need to be referenced.

2a267440b240be3aa99d0c14fd6c8dcf90a27f99
For procedures this is explained in the first commit => they currently 
have an (possible intentional) unbalanced dbg_state_writing.
Requiring them to have a label, conflicts with that.
I welcome feedback on the suggestions in my commit message.

19e6b4fea54b85df1ad8df221947231d01d98bb9
Just completing the above, and write the labels.

959566d705d6a464b3076a97ddaa8213c9d9ec9f
Same problem for DW_TAG_MEMBER
My "workaround" is certainly wrong.  But currently there is no SYM.
How can I get labels for it?
Such as that they also work, if the field is in the parent, in a diff 
unit => which on linux requires a global label, since the declaration is 
NOT copied into the current unit.

50f7d0d53a20cef541f87b474a7b8cc39558808d
Write the basic info.
Currently only works if the property field/getter is in the same object 
(or base class), but not if it is in a record belonging to the object.
The latter requires the structure address to be also written, and 
resolving the record to the field...

But before I go and spent time on that, I would like to first resolve 
all the issues that already exist.

-----------------
Using -godwarffpdbg would also allow for this:
https://gitlab.com/martin_frb/fpc-src/-/compare/main...martin-entry-pc?from_project_id=28644964&straight=false

Which makes sure there is an address for each of the functions that need 
to be called.

-----------------
Test implementation in Lazarus
https://gitlab.com/martin_frb/lazarus/-/commits/fpdebug-godwarfproperties

properties with getters aren't called yet. It shows the getter, as if it 
was an event variable.

But if the getter has an address, it can be called by adding "()" (and 
enabling function eval).
At least for datatypes supported in function calls.

Looking forward to some feedback.
Martin



More information about the fpc-devel mailing list