Posted by Jenny, DelphiLand Team on January 09, 2009
In Reply to Re: Delphi debugger ignores line posted by Phil p16812 on
January 04, 2009
: Now the debugging break works, thanks a lot!
: But I don't understand it: I thought that "optimization" makes things better??? Can someone please clarify this?
Delphi's code optimization results in more efficient code operation and size (faster and smaller .exe), but it can be confusing during debugging. For example:
- Delphi will create no code for what it sees as "redundant" lines, such as a variable assignment when that variable is not used.
- Occasionally the compiler's optimization may cause the code to execute in an unexpected order.
- Optimization will sometimes prevent you from examining the value of a variable, such as not showing a variable's value via the Run/Evaluate/Modify dialog or while hovering over the variable with the cursor.
Conclusion: for using Delphi's built-in debugger efficiently, turn optimization "off" as long as you're debugging. Only switch it "on" again for your last compilation (and after that, test your application thoroughly).