* * *

Author Topic: Is there a Debugging Window on Lazarus?  (Read 6452 times)

Edson

  • Hero Member
  • *****
  • Posts: 761
Is there a Debugging Window on Lazarus?
« on: October 27, 2013, 11:29:39 pm »
In console mode, we can use a simple WriteLn() for output some value to screen.
But in Windows Apps, it doesn't work.
I am looking for some easy way for show strings on Windows Apps (No need for to use a file or to config an environment variable, or to use command line, like DebugLn need).
Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4315
    • wiki
Re: Is there a Debugging Window on Lazarus?
« Reply #1 on: October 28, 2013, 12:01:07 am »
Compile the app as console app.

There is a checkbox "win32 gui application"
 (in "Project options"  exact place depends on which version you have, in 1.3 it is "Config and Target")

Uncheck it, and you get a console window.

Or write to StdErr, and watch the debug event log.

Edson

  • Hero Member
  • *****
  • Posts: 761
Re: Is there a Debugging Window on Lazarus?
« Reply #2 on: October 28, 2013, 12:50:38 am »
Thanks Martin,

I can see now, the output on the console window, when I use writeln().

But it's annoying, when I get an error on execution time when I check again the "win32 gui application".  I must comment all the writeln() or use and conditional directive, for all the writeln().
Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4315
    • wiki
Re: Is there a Debugging Window on Lazarus?
« Reply #3 on: October 28, 2013, 02:15:36 am »
use debugln instead.

It checks for the availability of STDOUT.

And you can change the uses clause

LazLoggerDummy : all debugln are just empty methods, so your code will not do anything (well fpc may leave a few calls to an empty method)

LazLogger : fully functional. Also adds check for commandline options --debug-log and --debug-enable (can be configured

LazLoggerBase : inactive.

LCLProc : nor sure, same as LazLogger or LazLoggerBase


---
LazLoggerBase  is supposed to be used in most units.

 Then as soon as you add LazLogger to ONE unit all LazLoggerBase become active.

Edson

  • Hero Member
  • *****
  • Posts: 761
Re: Is there a Debugging Window on Lazarus?
« Reply #4 on: October 28, 2013, 04:51:27 am »
It seems that "LazLogger" is very complete.

But, does debugLn() have a window for show the output?

Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

Leledumbo

  • Hero Member
  • *****
  • Posts: 7620
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is there a Debugging Window on Lazarus?
« Reply #5 on: October 28, 2013, 10:07:19 am »
Quote
But, does debugLn() have a window for show the output?
AFAIK, debug server (in tools menu) will show the output of debugln.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4315
    • wiki
Re: Is there a Debugging Window on Lazarus?
« Reply #6 on: October 28, 2013, 12:21:36 pm »
Not sure which package debugserver is, it is not there by default.
There actually is a special write to debugserver command, but I do not remember.



Debugln writes to STDOUT (same as writeln). The difference isn that it does not crash, if there is no console.

And it can be redirected to a logfile if wanted. Together with a "tail" application that can also be used.

Leledumbo

  • Hero Member
  • *****
  • Posts: 7620
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is there a Debugging Window on Lazarus?
« Reply #7 on: October 28, 2013, 04:39:38 pm »
Quote
Not sure which package debugserver is, it is not there by default.
No package required, it's there: $LazarusDir()/tools/debugserver/debugserver$ExeExt()
Strange, I remember never touch anything and it is there from the start.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4315
    • wiki
Re: Is there a Debugging Window on Lazarus?
« Reply #8 on: October 28, 2013, 04:50:13 pm »
See picture. Tools menu of a fresh install. No debugserver entry

Edson

  • Hero Member
  • *****
  • Posts: 761
Re: Is there a Debugging Window on Lazarus?
« Reply #9 on: October 29, 2013, 05:13:57 am »
It's not in tool menú.

It's an executable that must be in:  $LazarusDir()/tools/debugserver/

But in my Lazarus, it doesn´t exist. I had to compile the project that was in that place, for getting the executable.

Once executed, the "debugserver.exe" work fine. It show the message of my app, if I use the unit "dbugintf" and call the function "SendDebug()".

But it need, to have the debugserver.exe, always running. If I stop the process, it give me an Error on execution time. (It's the same of using WriteLn on no "win32 gui application" mode).
Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

Leledumbo

  • Hero Member
  • *****
  • Posts: 7620
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is there a Debugging Window on Lazarus?
« Reply #10 on: October 29, 2013, 07:11:45 am »
OK maybe a long time ago I put it in my tools menu as custom tool, so I can call it conveniently. You can also use event log window, using TEventLog as debugging aid.

Edson

  • Hero Member
  • *****
  • Posts: 761
Re: Is there a Debugging Window on Lazarus?
« Reply #11 on: October 29, 2013, 08:02:44 pm »
I probed the TEventLog object, and it worked, but honestly it's a complicated way for view debugging message. It has a lot of unuseful information.

Until now I can see that "There is not a simple way for viewing message on a debugging window."

I was expecting to have some like:

uses ..., debugWin;
...
debug('hello');
...

And no more.

I think it's necessary to have at least a simple Debug Windows on Lazarus, considering that we don't have a good debugger.
Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4315
    • wiki
Re: Is there a Debugging Window on Lazarus?
« Reply #12 on: October 29, 2013, 08:19:29 pm »
Personally I use debugln.

If you define buildmodes, the changing between with and without console window is just making a selection in a dropdown on the main toolbar (no dialog, immediately reachable)

debugln does not fail if there is no console,

And it can be eliminated (by substituting the unit) for release builds.

---
The biggest shortcoming of the debugger imho is the lack of function calling (and with that the ability to see properties).
It has rarely ever affected me. Normally I know the underlying field, and can watch this.

Also make sure to use DWARF, so
  property FOO: Integer read FFOO;
will work (no function, direct to field)

Edson

  • Hero Member
  • *****
  • Posts: 761
Re: Is there a Debugging Window on Lazarus?
« Reply #13 on: October 30, 2013, 01:11:11 am »
Thanks Martin,

it's a good option, to use debugLn with "Build Modes".  I think I can use that way too. However It's necessary to configure for each project, a little extra job.

Probably later I will try to make my own debug Window. I don't hate black console window, but i think it doesn't fit at the Lazarus standar.

I think Lazarus is a great IDE, but has so many options that anyone can confuse at the first time. Probably could have a some different default configuration.
Moreover, I see a lack of documentation on Lazarus or if we have, it's not correctly organized.
Lazarus 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

GeertVc

  • Newbie
  • Posts: 3
Re: Is there a Debugging Window on Lazarus?
« Reply #14 on: August 13, 2017, 09:53:28 am »
Personally I use debugln.

If you define buildmodes, the changing between with and without console window is just making a selection in a dropdown on the main toolbar (no dialog, immediately reachable)

debugln does not fail if there is no console,

And it can be eliminated (by substituting the unit) for release builds.

I know this is an old thread, but I just stepped in into Lazarus and stumbled upon the same.  Build mode is a nice alternative, as is the debugserver alternative.  However, it's anyhow a pitty that WriteLn() doesn't work with Windows GUI's or that DebugLn() is not rerouted to the default available Messages window...

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus