Recent

Author Topic: questionable function definition display.  (Read 3644 times)

440bx

  • Hero Member
  • *****
  • Posts: 4194
questionable function definition display.
« on: April 05, 2024, 11:16:07 am »
Hello,

Please refer to the pictures in the attachment. 

The first picture in the attachment shows the little popup window displaying the definition of GetClientRect as taking as parameters a Wnd and a TRECT but that isn't correct.   GetClientRect takes a Wnd and a _pointer_ to a TRECT (which is specified either by "var" or by declaring the parameter as a PRECT instead of a TRECT.)

I am guessing the little popup window is directly or indirectly conrtolled/influenced by Codetools.

The second picture in the attachment shows FpDebug displaying the same incorrect definition for GetClientRect (I'm guessing it is using/reusing information created by Codetools.

Lazarus v3.2, Win 7 64 bit SP1

Useful comments welcome.

« Last Edit: April 05, 2024, 03:20:39 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9987
  • Debugger - SynEdit - and more
    • wiki
Re: Codetools (?) questionable function definition display.
« Reply #1 on: April 05, 2024, 12:53:02 pm »
Actually, FpDebug gets the information from the Dwarf info written by fpc.

Ok, so that is not about "Hwnd" being translated to QWord? (which is done by FPC)


As for "var rect: TRect", fpc (at least current versions) writes into the DWARF info.

- Type "TRect" is a structure. (this is given without pointer, i.e. as a record should be)
- "rect" is of type "TRect"
- The location of the data of "rect" is an expression.
   - Get the frame pointer
   - add a constant (location where in the stackframe the variable is)
   - "deref" (i.e. follow the pointer) in the stack frame.

Data location expressions can be arbitrary complex. Data could even be split across several registers and/or mem-locations. Strings and dyn array have such deref instructions too.

However, there is (in Dwarf) no direct indication if a parameter is declared const/var/...

For real pointers (pointers declared by the user), fpc will include a pointer type, and then make the variable to be that pointer type.

The exact way how such data is encoded has also changed over past versions of FPC. (IIRC)




440bx

  • Hero Member
  • *****
  • Posts: 4194
questionable function definition display.
« Reply #2 on: April 05, 2024, 01:38:32 pm »
Actually, FpDebug gets the information from the Dwarf info written by fpc.
That makes sense.

Ok, so that is not about "Hwnd" being translated to QWord? (which is done by FPC)
I figured it shows qword because that's the type behind an hWnd, it would be nice if it showed hWnd.  Is the parameter in dwarf described as qword or hwnd ?  I'm guessing qword and, from what you've stated, FpDebug is relying on how FPC has described it in Dwarf.

However, there is (in Dwarf) no direct indication if a parameter is declared const/var/...
I think that's a problem because it causes an incorrect definition to be displayed.

For real pointers (pointers declared by the user), fpc will include a pointer type, and then make the variable to be that pointer type.
That's right.  I just tried it and it does it as you described.

refer to the attachment for this next part.  The yellow window shows a bunch of stuff that I suppose is determined by the definition of TRect but, the contents are not really useful (lacks detail) and it makes the window take a fair amount of space.  I'd say the window should just show that a PRECT is a pointer to a TRECT (which is probably obvious but, at least it's only 1 or 2 lines) or show the complete definition of TRECT as well (which will definitely take some space but, could sometimes come in quite handy.)  I think either way is fine except for what it's showing right now (which consumes a fair amount of space yet gives very little useful information.)

ETA:

Removed "codetools" from the thread's title.

« Last Edit: April 05, 2024, 02:36:27 pm by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9987
  • Debugger - SynEdit - and more
    • wiki
Re: Codetools (?) questionable function definition display.
« Reply #3 on: April 05, 2024, 02:12:23 pm »
However, there is (in Dwarf) no direct indication if a parameter is declared const/var/...
I think that's a problem because it causes an incorrect definition to be displayed.
It needs to be addressed in FPC...

Well, FpDebug already has tiny bits of code, that rely on "implementation detail" => e.g., IIRC the difference between "array of char" and "string" is, if fpc wrote a default value or omitted it.... Or something like this. This is something that can break with any new fpc version. But so far, FPC does not encode that difference. (It may be either string<>array or string<>pchar or something of that kind....). It only works for Dwarf 3.

I really don't want to add to much "magic" of that kind. It will end up breaking, and may then not even be fixable....

And yes, it sound like it couldn't break: if there is a deref somewhere then it must have a hidden pointer. => But so does a TObject, which could be encoded that way (currently is not).
And if you have a nested function, the proper way to encode visible locals of the outer function would be using the same deref. (Also currently not done).
So looking for a hidden deref is not a good solution.

Quote
refer to the attachment for this next part.  The yellow window shows a bunch of stuff that I suppose is determined by the definition of TRect but, the contents are not really useful (lacks detail) and it makes the window take a fair amount of space.  I'd say the window should just show that a PRECT is a pointer to a TRECT (which is probably obvious but, at least it's only 1 or 2 lines) or show the complete definition of TRECT as well (which will definitely take some space but, could sometimes come in quite handy.)  I think either way is fine except for what it's showing right now (which consumes a fair amount of space yet gives very little useful information.)

Ah, yes that looks like a bug. Displaying types really did not have much attention so far. The function names (and declarations) do exist in the dwarf info.

I don't know if removing the deref of the info is really going to help much. You still get the entire bunch if you hover over TRect instead of PRect. And then there is on deref to omit.

But which ever way that is going to be solved, please report a bug. (Hovering over TRect should include function names and declaration).

About the inclusion of function in any structured typed (record, object, class) => that could be optional. But that is a separate matter.
 

440bx

  • Hero Member
  • *****
  • Posts: 4194
questionable function definition display.
« Reply #4 on: April 05, 2024, 02:53:49 pm »
It needs to be addressed in FPC...
I figured that would be the case.

I really don't want to add to much "magic" of that kind. It will end up breaking, and may then not even be fixable....
I fully understand that.  It's a given that sooner or later a lot of that stuff breaks or becomes difficult to keep functional.

Ah, yes that looks like a bug.
<snip>
But which ever way that is going to be solved, please report a bug.
Yes, it looked like a bug to me too.  Usually that window shows a lot of useful information and in that particular case, not so much ;)  Reported as bug: 40882
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Nate897

  • Newbie
  • Posts: 5
Re: questionable function definition display.
« Reply #5 on: April 23, 2024, 12:05:52 am »
That makes sense.

Hello my brother in Christ,
 
that editor colour theme looks good. Did you make it yourself? Would you mind sharing it?

Sorry about this being unrelated to your topic.
 
Thank you.

440bx

  • Hero Member
  • *****
  • Posts: 4194
Re: questionable function definition display.
« Reply #6 on: April 23, 2024, 12:25:05 am »
that editor colour theme looks good. Did you make it yourself? Would you mind sharing it?

Sorry about this being unrelated to your topic.
 
Thank you.
Yes, I made that theme decades ago in my normal editor then I applied it to Delphi (v1) then to Lazarus (v1.8 ).  It's got a lot of miles on it.  My pleasure to share it, it's attached to this post.  I renamed it from "ExportedColors" to a bit of megalomania.

You're welcome.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9987
  • Debugger - SynEdit - and more
    • wiki

440bx

  • Hero Member
  • *****
  • Posts: 4194
Re: questionable function definition display.
« Reply #8 on: April 23, 2024, 12:58:42 am »
Put it on https://wiki.freepascal.org/UserSuppliedSchemeSettings ?
I just added it there.  Called it "Eclipse".

I couldn't find how to make a screenshot like the other ones that show more options. 
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Nate897

  • Newbie
  • Posts: 5
Re: questionable function definition display.
« Reply #9 on: April 23, 2024, 01:23:51 am »
You're welcome.

Thanks my man. What is that font you're using called? 

Thanks my dudes
« Last Edit: April 23, 2024, 01:43:53 am by Nate897 »


440bx

  • Hero Member
  • *****
  • Posts: 4194
Re: questionable function definition display.
« Reply #11 on: April 23, 2024, 01:35:28 am »
The font is BorlandTE, filename: BORTE.FON

It's proprietary to Borland and, I think they stopped distributing it long ago.  There is a very similar but not the same font called "Raize" which is available for free on the net.  BORTE.FON was distributed with Delphi 2 (and possibly some of the later versions.)

This place has some interesting fonts as well as comments and screenshots along with an easy to read article about programming fonts https://darinhiggins.com/2012/05/18/best-programming-font/

HTH.

ETA:

@dseligo provided you a link to a reply I gave recently to the same question from someone else.

« Last Edit: April 23, 2024, 01:37:04 am by 440bx »
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018