Recent

Author Topic: more debuggery.  (Read 2506 times)

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #30 on: October 25, 2022, 02:30:21 pm »
OK, some sanity has returned and I have a USEFUL debugger at last.

There does still seem to be some glitches on nested types.

Code: Pascal  [Select][+][-]
  1.  
  2.  for i:=0 to boxcount-1 do with pack do
  3.   begin
  4.  
  5.       if cardstate=cd_phr then
  6.  
  7.        cardstr:= cards[cardnum].phrase
  8.       else
  9.         cardstr:= cards[cardnum].cardwords[i];
  10.  

If I hover variables to look at values, cards shows me a full array with expected content. cardnum shows me 1 but when I hover cardwords, it complains that it can't find cardnum ( which it just found ).

type

Code: Pascal  [Select][+][-]
  1. TwordArray = array[0..2] of string[phraselen];
  2.  
  3. Tcard=record
  4.   cardwords:TWordArray;
  5.   phrase:string[phraselen] ;
  6. end;
  7.  
  8. TcardPack = array[1..maxpacksize] of Tcard;
  9.                                              

Code: Pascal  [Select][+][-]
  1.       property cards:TcardPack Read Fcards;
  2.  
« Last Edit: October 25, 2022, 02:38:50 pm by lazer »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9872
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #31 on: October 25, 2022, 02:33:24 pm »
OK, some sanity has returned and I have a USEFUL debugger at last.

There does still seem to be some glitches on nested types.

Code: Pascal  [Select][+][-]
  1.         cardstr:= cards[cardnum].cardwords[i];
  2.  

If I hover variables to look at values, cards shows me a full array with expected content. cardnum shows me 1 but when I hover cardwords, it complains that it can't find cardnum ( which it just found ).

I would need some example of it. (just putting it into a new project, and it works)

Does it also happen, if you enter it in the watch window (or inspect or evaluate window)?
« Last Edit: October 25, 2022, 02:39:19 pm by Martin_fr »

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #32 on: October 25, 2022, 02:41:35 pm »
Interesting. It is basically the same except that it cannot watch and evaluate cardnum, which was found in the hover.

If I put pack.cardnum in watch and eval , they work.   It seems like they are able to apply the with syntax to cards but not twice in the same line.
Code: Pascal  [Select][+][-]
  1.       property cards:TcardPack Read Fcards;
  2.       property cardnum:word Read wordcounter;
  3.      

Making it explict , it does evaluate fully.
Code: Pascal  [Select][+][-]
  1.         cardstr:= cards[pack.cardnum].cardwords[i];  
« Last Edit: October 25, 2022, 02:52:09 pm by lazer »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9872
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #33 on: October 25, 2022, 02:56:04 pm »
Interesting. It is basically the same except that it cannot watch and evaluate cardnum, which was found in the hover.

If I put pack.cardnum in watch and eval , they work.   It seems like they are able to apply the with syntax to cards but not twice in the same line.
Code: Pascal  [Select][+][-]
  1.       property cards:TcardPack Read Fcards;
  2.       property cardnum:word Read wordcounter;
  3.      

Still works here.

That is assuming FCards and wordcounter are fields (variables).

If the are getter functions "function wordcounter: word;" then => yes then it does not work.
That is a known issue. Work is in progress. But it will still be a long time.


Also those properties, are they on a class? or a record? or an "object"?
Apparently properties on an "object" don't work either (just tested).
But on class/record they should (if the "read" directly reads a field)



Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9872
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #34 on: October 25, 2022, 02:58:40 pm »
Is your code in a
Code: Pascal  [Select][+][-]
  1. with foo do begin
  2. end;
block?

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #35 on: October 25, 2022, 03:12:26 pm »
To confirm, yes, that was posted above.

Code: Pascal  [Select][+][-]
  1. for i:=0 to boxcount-1 do with pack do
  2.   begin
  3.  

even if not in a block, it should still apply to a single line: hypothetically:

Code: Pascal  [Select][+][-]
  1. with pack do
  2.      cardstr:= cards[cardnum].cardwords[i];
  3.  

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9872
  • Debugger - SynEdit - and more
    • wiki
Re: more debuggery.
« Reply #36 on: October 25, 2022, 03:26:40 pm »
Sorry, I overlooked the "with"
That may explain it. And then it may be a while till it gets fixed.

The debugger doesn't know where there is a "with" block.

The IDE ("codetools" to be exact) prepares the expression.
In the hint you will see that it says

pack.cards =
pack.cardnum =

and
pack.cards[cardnum] =

So it misses cardnum in that last case.

That needs to be reported as a "codetools" bug.




As for "the debugger does not know 'with'"

1) it is not added by fpc to the debug info (so fixing it there will likely take time)

2) It would change the behaviour
The debugger always uses the "current line" (the line on which you are paused / or which you selected in the stack window) as context.

So if the debugger knew about "with" but you are paused before/after then the debugger would not be able to apply the with. Yet codetool can. So codetool (if it works) gives you a better result.

And this is the same for any debugger backend we have.


In any case this is by all likelihood going to take time to be fixed.






Martin_fr

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

lazer

  • Full Member
  • ***
  • Posts: 215
Re: more debuggery.
« Reply #38 on: October 25, 2022, 03:59:40 pm »
Quote
The debugger always uses the "current line"

Excepting the case of a with block, it seems strange that it can evaluate cards ( which implies it is using a with ) but then in the same line can't evaluate cardum.

Both are properties of the same object , declared next to each other.

There is perhaps a more accessible bug in making it apply with to the whole line.
« Last Edit: October 25, 2022, 05:41:20 pm by lazer »

 

TinyPortal © 2005-2018