Recent

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

Gizmo

  • Hero Member
  • *****
  • Posts: 831
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?

howardpc

  • Hero Member
  • *****
  • Posts: 4144
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: 9905
  • Debugger - SynEdit - and more
    • 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.

 

TinyPortal © 2005-2018