Recent

Author Topic: Debugger error  (Read 894 times)

zhuyl

  • New member
  • *
  • Posts: 8
Debugger error
« on: December 06, 2022, 05:12:18 am »
hello,
   The debugger has an error as shown in the figure(lazarus2.2.2 and lazarus2.2.4).
« Last Edit: December 06, 2022, 05:14:53 am by zhuyl »

zhuyl

  • New member
  • *
  • Posts: 8
Re: Debugger error
« Reply #1 on: December 06, 2022, 05:58:25 am »
I understand. If you choose the third option, problems will occur. It's OK to choose the first two

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: Debugger error
« Reply #2 on: December 06, 2022, 01:11:41 pm »
Only "no optimization" and "-O1" are meant for debugging.

With "O2" and above, some debugging may work (if you are lucky), but it may not work.

And it could even display wrong values. As you got.
The reason is that the compiler puts values into registers, but it use the same register for different variables depending on which line of code you are (or even changing it several times during a line).
The compiler does not currently encode for the debugger at which time those register assignment change. Or if to use the register or read some memory.
Thus you may see the wrong value, or an outdated value.


However, there are cases when people need to debug with O2 (or higher / like someone who develops a compiler).
In such cases, those people will use the disassembler and CPU registers (which works for all levels) instead of normal debugging.

A warning would be nice....
But that is tricky, because you can compile different units (packages) with different settings. And may even have pre-compiled units (like rtl) for which the IDE does not know, how they were compiled.



As for "function calls not allowed"
This can be enabled in Tools > Options > Debugger >General
And then must also be allowed in the "watch properties"

However, while it is present in 2.2.x - it is early beta in 2.2.x and can easily crash.
You should use 2.3 (git main branch) for that, if you need it.

 

TinyPortal © 2005-2018