* * *

Author Topic: Debugging console applications with breakpoints?  (Read 808 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 568
    • http://www.quickhash-gui.org
Debugging console applications with breakpoints?
« on: October 11, 2016, 07:55:46 pm »
Hi guys

I'm trying to port code (that worked) to a console application, but some of the code isn't working. I'm trying to work out where the problem is, but using "Writeln : whatever", recompiling, then running the exe in CMD is proving to be cumbersome and isn't allowing me to watch the individual variables as I'm used to with breakpoints and the debugger with traditional form based programs.

So I read http://wiki.freepascal.org/Debugger_Console_App#Lazarus_0.9.31_.2F_1.0_and_higher and enabled "View --> Debug Windows --> Debug output" and whilst I get some never-before-seen output it's still not what I hoped for. I want to be able to watch the variables as the various loops and while statements run so I can work out where and why a particular function is failing. In other words, with a normal GUI based application I'd set one or two breakpoints and use "Step Into" with debugging enabled in the project and I can see how the vars change with each line. How can I do that with a console app?

Can anyone give me some pointers?
Lazarus 1.6.4 and fpc 3.0.2 - Linux Mint 17 LTS, Windows 7 and Mac Yosemite
Useful Page to remember : http://wiki.freepascal.org/Cross_compiling#From_Linux_x64_to_Linux_i386

howardpc

  • Hero Member
  • *****
  • Posts: 2185
Re: Debugging console applications with breakpoints?
« Reply #1 on: October 11, 2016, 08:27:00 pm »
One way is to add
Code: Pascal  [Select]
  1. uses lazlogger;
to your unit(s) and add DebugLn(....) statements as needed.
The LCL sources have examples of this almost everywhere.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4280
    • wiki
Re: Debugging console applications with breakpoints?
« Reply #2 on: October 11, 2016, 08:30:39 pm »
breakpoints, and watches (watches window), single step....

All that should work the same.  Provided you compiled with debug info. http://wiki.lazarus.freepascal.org/Debugger_Setup#Project_Options

The "Debug Output" is internal info.

The problem with debugging console app, is that you need a console, so you can see your programs output, or make input

Under Windows, you get that automatically
Under linux, open "debug windows" > "Terminal Output"
Under Mac, well that is a problem.

 

Recent

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