Forum > Debugger

Debugger error


   The debugger has an error as shown in the figure(lazarus2.2.2 and lazarus2.2.4).

I understand. If you choose the third option, problems will occur. It's OK to choose the first two

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.


[0] Message Index

Go to full version