Print variable value during execution? lazarus / 12-Debugger ---------------------------------------------------------------------- panoss · 2011-03-10 14:03 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 (). 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. ---------------------------------------------------------------------- Marc · 2011-03-10 16:17 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 ---------------------------------------------------------------------- panoss · 2011-03-10 16:22 And what should I do? ---------------------------------------------------------------------- Marc · 2011-03-10 16:24 what do you want ? ---------------------------------------------------------------------- panoss · 2011-03-10 16:27 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'. ---------------------------------------------------------------------- panoss · 2011-03-21 08:07 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? ---------------------------------------------------------------------- Leledumbo · 2011-03-21 15:54 Do you have GDB installed in your Linux?Have you set GDB as the debugger in environment options? ---------------------------------------------------------------------- panoss · 2011-03-21 18:47 Quote from: Leledumbo on March 21, 2011, 04:54:13 pmDo 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. ---------------------------------------------------------------------- bobo · 2011-03-22 06:52 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 · 2011-03-22 07:59 But, in windows version of Lazarus, everything was displayed as expected. ---------------------------------------------------------------------- Leledumbo · 2011-03-22 11:02 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 · 2011-03-22 13:06 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 '. ---------------------------------------------------------------------- bobo · 2011-03-30 01:31 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 · 2011-03-30 14:19 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. ---------------------------------------------------------------------- bobo · 2011-03-30 23:28 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. ---------------------------------------------------------------------- Leledumbo · 2011-03-31 03:56 QuoteReally 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.No I can't see contents of properties, BUT I can see the contents of private variables (though this breaks the encapsulation, but it's required). ---------------------------------------------------------------------- Marc · 2011-04-01 08:46 Usually I need the contents of Edit1.Text to do some processing. For efficiency reasons I put it in a variable first and then do my processing. So I seldom need to know the contents of Edit1.Text ---------------------------------------------------------------------- Guillermo · 2011-04-06 03:46 I have had same problems with debugger, so I use the "brute force" method (as I used in Turbo3): drop a memo in the form, and print the desired values... I really don't know how to use the debugger, is there any tutorial? Gracias (Thanks). Guillermo.