Recent

Author Topic: Testers needed: FpDebug and ModeSwitch AutoDeref  (Read 3134 times)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9210
  • Debugger - SynEdit - and more
    • wiki
Testers needed: FpDebug and ModeSwitch AutoDeref
« on: June 08, 2023, 03:27:07 pm »
Under Tools > Debugger > Debugger Backend: When FpDebug is selected, there is now an option "AutoDeref" (in the properties grid).
The option is OFF by default.

If checked, FpDebug will evaluate expressions like
Code: Pascal  [Select][+][-]
  1.   PointerToMyObject.Foo // without the ^
  2.   PointerToMyArray[i] // without the ^

That is, if a (typed) pointer is followed by either "." or "[" then the debugger performs exactly one ^ deref.

The debugger has no knowledge if a unit was compiled with or without that ModeSwitch. The debugger applies the setting globally.

As I don't use that ModeSwitch in any of my code, I have no experience when or where it will affect operations (all the nitty gritty details).
And also, I will not use the feature in may daily work, reducing the amount of testing it gets from me.

So, I relay on those who use the modeswitch (and want the debugger to behave accordingly) to test it.
And to find out any place were the debugger behaves different from what the compiler does. (except for applying the flag globally).

If you find differences, then please create an issue report on the bugtracker. Please include a small example prog that show what the compiler does.

nanobit

  • Full Member
  • ***
  • Posts: 137
Re: Testers needed: FpDebug and ModeSwitch AutoDeref
« Reply #1 on: June 09, 2023, 01:26:41 pm »
Thank you, this is very useful.
I suggest that {$mode delphi} users enable this debug-mode option,
because the compile mode already includes AutoDeref ON by default.

My test for AutoDeref was successful:
Expression type was pointer-type PRecord, PStaticObject, PStaticArray.
I also tested some exotic expressions (above pointer-types are result-types):
PPPStaticArray^^[0] resolves to PPPStaticArray^^^[0] under AutoDeref ON.
All this was successful.

I know one combination where the AutoDeref debug-option should be disabled:
1) {$PointerMath on} type PStaticArray = ^TStaticArray;
2) compiler mode is AutoDeref OFF  (or even ON in case of ideal compiler (see note)).
By pointermath, the compiler views PStaticArray[0] as one TStaticArray in a line of arrays.
With debugger-AutoDeref, the debugger would see only first element in TStaticArray: PStaticArray^[0].

(Note about the compiler: PStaticArray[0] is a pointermath index expression,
but due to a known compiler bug (also in Delphi) the pointermath meaning is overridden (lost) under AutoDeref ON.
This compiler bug violates the rule that AutoDeref should be applied to expressions
only if the same expressions under AutoDeref OFF are non-compilable (caret missing).)

 

TinyPortal © 2005-2018