Recent

Author Topic: Is it possible to see the value of a variant or property?  (Read 4826 times)

markus_ja

  • New Member
  • *
  • Posts: 43
Is it possible to see the value of a variant or property?
« on: June 16, 2016, 09:45:54 am »
Hello,

so far I found in the internet, the lazarus debugger is not able to show the value of an variant variable or property.
Is there any option, to investigate the content of such a variable or property?

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Is it possible to see the value of a variant or property?
« Reply #1 on: June 16, 2016, 09:54:42 am »
One option is something like this:

Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. {$R *.res}
  4.  
  5. uses LazLogger;
  6.  
  7. var
  8.   v: variant;
  9.  
  10. begin
  11.   v:=True;
  12.   DebugLn('v=',v);
  13.   v:=123.456;
  14.   DebugLn('v=',v);
  15.   v:='this is a variant';
  16.   DebugLn('v=',v);
  17. end.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Is it possible to see the value of a variant or property?
« Reply #2 on: June 16, 2016, 10:21:04 am »
so far I found in the internet, the lazarus debugger is not able to show the value of an variant variable or property.
Any reference ?

Quote
Is there any option, to investigate the content of such a variable or property?
When step debugging, i hover my mouse over the variant variable, use inspector to inspect the contents and/or add a watch on the variant variable.

Seeing the responses from others, i must be interpreting something wrong here ?

Michl

  • Full Member
  • ***
  • Posts: 226
Re: Is it possible to see the value of a variant or property?
« Reply #3 on: June 16, 2016, 10:25:10 am »
the lazarus debugger is not able to show the value of an variant variable or property
A variable can be shown with the GDB, a property not.

If you have something like:
Code: Pascal  [Select][+][-]
  1.   TForm1 = class(TForm)
  2. ...
  3.   private
  4.     FVari: Variant;
  5.   public
  6.     property Vari: Variant read FVari write FVari;
  7.   end;
  8. ...
  9. procedure TForm1.Button1Click(Sender: TObject);
  10. begin
  11.   Vari := 'Test';  // <- Breakpoint
  12.   Vari := 1.234;
  13.   Vari := 789;
  14.   Vari := False;
  15. end;
With <Ctrl> + <F5> you can add "FVari" to your Watch List. If you set a breakpoint in the code above and you step through the code with <F8>, you will see the changes of FVari (Lazarus 1.6 with GBD 7.7.1).

[Edit] molly was even faster.
Code: [Select]
type
  TLiveSelection = (lsMoney, lsChilds, lsTime);
  TLive = Array[0..1] of TLiveSelection;

markus_ja

  • New Member
  • *
  • Posts: 43
Re: Is it possible to see the value of a variant or property?
« Reply #4 on: June 16, 2016, 10:37:08 am »
Hm ... in my test project I see the variant as well. But in my multithreaded REST server project, I was not able to see it in the debugger.
Can it be, that in a multithreaded environment, the debugger has some issues?


Thaddy

  • Hero Member
  • *****
  • Posts: 14382
  • Sensorship about opinions does not belong here.
Re: Is it possible to see the value of a variant or property?
« Reply #5 on: June 16, 2016, 10:44:32 am »
Yes. You will need a more recent GDB than the one that comes with Lazarus.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki

markus_ja

  • New Member
  • *
  • Posts: 43
Re: Is it possible to see the value of a variant or property?
« Reply #7 on: June 16, 2016, 03:10:27 pm »
Yes. You will need a more recent GDB than the one that comes with Lazarus.

How to get / install the latest GDB debugger?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9908
  • Debugger - SynEdit - and more
    • wiki
Re: Is it possible to see the value of a variant or property?
« Reply #8 on: June 16, 2016, 03:24:37 pm »
If you are on Windows, then look at our Sourceforge page.

the 32 bit setup already comes with gdb 7.7. (You can also get that in the alternative gdb folder in win32)

the 64 bit comes with an older and 7.7 can be downloaded (the alternative gdb folder in win64)

7.7 is not the latest gdb, but according to my tests, any later gdb has a higher likelihood of crashing. (I have testcases that crash 7.8 and up, but run on 7.7)

----------
gdb version does NOT affect what properties you can see.

Not sure about variant, but I dont think that gdb version will make a diff.

dwarf vs stabs may make a diff
« Last Edit: June 16, 2016, 03:26:24 pm by Martin_fr »

markus_ja

  • New Member
  • *
  • Posts: 43
Re: Is it possible to see the value of a variant or property?
« Reply #9 on: June 16, 2016, 05:25:00 pm »
Thanks

 

TinyPortal © 2005-2018