Recent

Author Topic: FPDebug: Evaluate/Modify variable of type Currency  (Read 563 times)

bpranoto

  • Full Member
  • ***
  • Posts: 155
FPDebug: Evaluate/Modify variable of type Currency
« on: April 22, 2024, 11:34:27 am »
When debugging with fpDebug, Evalue/Modify and watch, variables of type currency is displayed multiplied by 10000, for example Val1 value is actually 10, but displayed in Evaluate/Watched windows as 10000. See the screenshot attached.

I think, it will be better if it represented the value as it is?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10001
  • Debugger - SynEdit - and more
    • wiki
Re: FPDebug: Evaluate/Modify variable of type Currency
« Reply #1 on: April 22, 2024, 12:05:10 pm »
This does work (kinda) in 3.99.
It only affects the display in the watches Window (and locals, inspect, ...).

The problem is that FPC encodes "currency" as plain integer in the debug info. So the debugger (fpdebug, gdb, lldb) itself does not know.

However, in 3.99 "debug visualizers" (aka "value formatters") exist: https://forum.lazarus.freepascal.org/index.php/topic,66186.0.html
And they amend at least how it is displayed.

Downside, if you add a watch like:
Code: Text  [Select][+][-]
  1. MyCurrencyVar + 1
  2. MyCurrencyVar + MyIntVar
Then the result is calculate in the debugger, and the Integer value will add 0.0001 to the currency var.

But to fix this, fpc needs to provide the correct info to the debugger...

Well, maybe FpDebug can get an option to override that info. But that is problematic too, because all it has to detect currency is the typename (though that is the same for the "dbg visualizer"), and you can have code like
Code: Pascal  [Select][+][-]
  1. type currency = byte;
And then translating this into fixed point, would be wrong (and will be incorrectly displayed if the dbg-visualizer is active).


bpranoto

  • Full Member
  • ***
  • Posts: 155
Re: FPDebug: Evaluate/Modify variable of type Currency
« Reply #2 on: April 22, 2024, 03:14:12 pm »
Thank you for the Insight Martin, actually it's not really a problem, it just gives me an itch whenever I inspect the variable in the debugger :)

 

TinyPortal © 2005-2018