Recent

Author Topic: Evaluate/modify and 'hover', not working 'as expected'  (Read 842 times)

mvandere

  • Newbie
  • Posts: 5
Evaluate/modify and 'hover', not working 'as expected'
« on: July 30, 2024, 02:26:50 am »
What am I missing?
evaluate/modify and hover seem to not understand things,

Eg
ComboBox1.itemindex says <Error: Member not found: itemindex>
Ditto for RadioGroup1.itemindex and BitBtn2.enabled

ComboBox1.items does not seem to list the items anywhere
and
ComboBox1.items[0] says <Error: Index error at pos 10 for '.'[]: The value has no index>

Also, for things that can be modified, something modified in the line the breakpoint is located on seems to be evaluated as it was before the modification


440bx

  • Hero Member
  • *****
  • Posts: 5137
Re: Evaluate/modify and 'hover', not working 'as expected'
« Reply #1 on: July 30, 2024, 02:41:40 am »
got a compilable, preferably short. program that exhibits the problem ? if so, it would be useful if you posted it.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

jamie

  • Hero Member
  • *****
  • Posts: 6869
Re: Evaluate/modify and 'hover', not working 'as expected'
« Reply #2 on: July 30, 2024, 02:46:54 am »
go to the tools in laz, TOOL: down the button, Clean and build ..

That will rebuild the IDE and its files.  what you described sounds like mismatched files.
The only true wisdom is knowing you know nothing

mvandere

  • Newbie
  • Posts: 5
Re: Evaluate/modify and 'hover', not working 'as expected'
« Reply #3 on: July 30, 2024, 03:02:25 am »
go to the tools in laz, TOOL: down the button, Clean and build ..

That will rebuild the IDE and its files.  what you described sounds like mismatched files.

Did you mean "Run", "Clean up and Build"? If so then no change

jamie

  • Hero Member
  • *****
  • Posts: 6869
Re: Evaluate/modify and 'hover', not working 'as expected'
« Reply #4 on: July 30, 2024, 03:04:14 am »
TOOLS:Build Lazarus.

make sure you have no project open.
The only true wisdom is knowing you know nothing

mvandere

  • Newbie
  • Posts: 5
Re: Evaluate/modify and 'hover', not working 'as expected'
« Reply #5 on: July 30, 2024, 03:23:13 am »
got a compilable, preferably short. program that exhibits the problem ? if so, it would be useful if you posted it.
The attached demonstrates everything

440bx

  • Hero Member
  • *****
  • Posts: 5137
Re: Evaluate/modify and 'hover', not working 'as expected'
« Reply #6 on: July 30, 2024, 04:48:39 am »
I see the problem you are referring to.

Take what follows with a grain of salt because I don't do OOP therefore, I could very easily be wrong.  I believe the reason you are getting those messages is because the debugger, at this time, cannot retrieve the value of some properties (it depends how the property is defined) and ItemIndex is a property. 

I don't know if the way ItemIndex is defined is within what the debugger can handle.  Someone better versed than I am in OOP and debugging OOP can hopefully shed additional light.

In the meantime, I believe that the value of ItemIndex is given by FItemIndex and, that value can be "watched" if necessary.  IOW, you can use that as a workaround if need be.

HTH.
(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: 10997
  • Debugger - SynEdit - and more
    • wiki
Re: Evaluate/modify and 'hover', not working 'as expected'
« Reply #7 on: July 30, 2024, 11:58:38 am »
properties currently don't work in the debugger. Well, except in some case, when the have "read FSomeField" (not go through a getter method).
Reasons for that are part historical....

As desirable is it may be, it will likely still take some time. It needs to be coordinated with the compiler development.

At the moment you may (50/50 chance) be able to do
    GetItemIndex()

Or whatever the name of the getter is.
It needs "function calls" enabled, in the global options AND in the watch properties.

It doesn't currently work for all getters. (It likely works if they are virtual, and in very few other cases)




Warning:

Calling function from watches (or eval/modify) can have side effects.

That is true for all debuggers (i.e. that also happens in Delphi, and I have personally been badly burnt by that). And that is true for evaluating any property that has a getter function.

If the called function modifies any variable/field in the app, then the app will behave according to that modification.

Example:
- The property "Handle" (or is it a function?) does create a handle if it hasn't yet been created (and if possible).
- I had code, that crashed, because it accessed handle without that function (and handle was not created).
- During debugging I wanted to know the value of handle, and forgot the property would create it, so I added "Handle" as watch (that was Delphi)
- The app did not fail during debugging, I was for some time not able to find the bug.

So once that properties have been added as feature, use with caution.


 

TinyPortal © 2005-2018