Recent

Author Topic: Print variable value during execution?  (Read 22211 times)

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Print variable value during execution?
« on: March 10, 2011, 03:03:42 pm »
In the mousedown event, I have a line like that: debugLn(myvariable).
It's supposed to print the value of myvariable in the Debug output, DURING RUNTIME.
But, it's not being printed in the runtime, but AFTER I stop the program from running!! Shows me the values of the variable it HAD taken when I was clicking with the mouse!
How can I make it work properly?

Also, when I add the myvariable in Watch List, it doesn't show it's value (<unknown>).
Local variables also doesn't work, doesn't show any variable.
In Project-->Compiler options-->Linking checked are:
1.Display line numbers...(-gl)
2.Generate dwarf ...(-gw)
3.Win32...(-WG)

Ubuntu 9.10  Lazarus 0.9.28.2-0 beta.
« Last Edit: March 10, 2011, 04:35:44 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: Print variable value during execution?
« Reply #1 on: March 10, 2011, 05:17:15 pm »
debugln writes text to a console. of no console is openend (like a gui app on windows), debugln does nothing. Thats all. And it writes the output the same moment you use debugln.

however, when debugging on linux using gdb, this console output might be buffered by gdb. This means it can appear any moment in the debugger output window. The debugger output window is meant for debugging the debugger.

If you run your app on a console you will notice that the output is there the moment you click
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Print variable value during execution?
« Reply #2 on: March 10, 2011, 05:22:14 pm »
And what should I do?
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: Print variable value during execution?
« Reply #3 on: March 10, 2011, 05:24:31 pm »
what do you want ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Print variable value during execution?
« Reply #4 on: March 10, 2011, 05:27:09 pm »
I want to see the variables' value at runtime.
Since I checked the option 'Generate dwarf debug information (-gw)', strange things happen:
I start Lazarus, run my application for first time, and runs ok.
When I try to run it for a second time: 'mycomponentspackage.lpr(18,1) Error: Error while linking'.
« Last Edit: March 10, 2011, 07:05:18 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Print variable value during execution?
« Reply #5 on: March 21, 2011, 09:07:27 am »
I installed lazarus in a windows xp pc.
Watches, local variables, debug output worked fine! Without any changes! Why can't I do the same in Linux?
I think it must be something extremely simple, I just can't find. Any ideas?
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8799
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Print variable value during execution?
« Reply #6 on: March 21, 2011, 04:54:13 pm »
  • Do you have GDB installed in your Linux?
  • Have you set GDB as the debugger in environment options?

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Print variable value during execution?
« Reply #7 on: March 21, 2011, 07:47:45 pm »
  • Do you have GDB installed in your Linux?
  • Have you set GDB as the debugger in environment options?
Yes I have done all that but nothing.
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Print variable value during execution?
« Reply #8 on: March 22, 2011, 07:52:31 am »
I think Lazarus still can not display most variables that are object properties while debugging, like Delphi does.

See http://www.lazarus.freepascal.org/index.php/topic,8172.0.html
or
http://www.mail-archive.com/lazarus@lazarus.freepascal.org/msg05350.html
or
http://bugs.freepascal.org/view.php?id=12111

I don't think much has changed in this area in the past years.
There are some tricks to display SOME subset of object properties (the ones that are not returned with a Get Set function/procedure), there were discussions on this many times on the mailing lists.

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Print variable value during execution?
« Reply #9 on: March 22, 2011, 08:59:25 am »
But, in windows version of Lazarus, everything was displayed as expected.
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8799
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Print variable value during execution?
« Reply #10 on: March 22, 2011, 12:02:40 pm »
Hmm... that's weird. MinGW's recent packages are built from vanilla, which means there should be no difference between platforms. Could you check installed GDB version in both Windows and Linux? (call from command line, use the standard --version option)

panoss

  • Full Member
  • ***
  • Posts: 162
  • You only live twice
Re: Print variable value during execution?
« Reply #11 on: March 22, 2011, 02:06:17 pm »
I gave 'gdb --version' and got:
'GNU gdb (GDB) 7.0-ubuntu' .

For the windows version, I will have access to that pc on Friday or Saturday.
But, I downloaded lazarus from here, the ' Lazarus Windows 32 bits       2009-10-25 '.
« Last Edit: March 22, 2011, 02:08:03 pm by panoss »
Windows 10 64bit, Lazarus Version 2.2.0    FPC 3.2.2.

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Print variable value during execution?
« Reply #12 on: March 30, 2011, 03:31:08 am »
Really you guys can debug within Lazarus and see more than simple local variable values?

When I debug a program, I can not see even simple things like Edit1.Text or Memo1.Lines[1] , it just gives error messages like "Syntax error near .Text" and things like that.

I am using the latest SVN version for both Lazarus and FPC.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: Print variable value during execution?
« Reply #13 on: March 30, 2011, 04:19:11 pm »
I won't call Edit1.Text or Memo1.Lines[1] the most simple things. There is a whole bunch of code behind those before you get their value.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

bobo

  • Full Member
  • ***
  • Posts: 171
Re: Print variable value during execution?
« Reply #14 on: March 31, 2011, 01:28:50 am »
Oh, I think you misunderstood, I did not think that it is simple to implement to see those values while debugging, otherwise it would have been included in Lazarus many years ago.

I meant that they are the very first things people use even in the most basic GUI applications.
TButton, TEdit, TMemo, TStringlist, and so on. These components (except TStringlist)  are all on the "Standard" component panel in Lazarus (or in any RAD GUI development system), representing some of the very basic GUI components.

Not being able to see the properties of these objects during debugging is a very serious missing feature in my opinion.

 

TinyPortal © 2005-2018