debugg a console application lazarus / 12-Debugger ---------------------------------------------------------------------- c-bob · 2009-10-27 09:42 Maybe a too simple question: How can I debug console applications? I know I have to adjust Start->Start-Parameter->Startprogramm (in the german lazarus, I don't know, how it was in the english version). But how can I use breakpoints and the like? Greetz -C- Oh PS: My system: Linux, Debian Sid 64bit (sidux) and lazarus from Sid. ---------------------------------------------------------------------- Marc · 2009-10-27 09:46 debugging console apps is hard with lazarus, since you cannot send input to your app unlees you use some terminal as starting application. However in that case you cannot use a debugger since it will start to debug your terminal instead of your app. ---------------------------------------------------------------------- c-bob · 2009-10-27 11:34 Umhh.. this is really annoying. And there is no way to get this working? The only way I have in mind is to take a container like TMemo or the like to catch all the console outputs. But then there is the problem of inputs  ... Damned! ---------------------------------------------------------------------- Marc · 2009-10-27 23:14 there is some patch for it in our bugtracker, but I want a more generalized solution for it. Thats why it isn't applied ---------------------------------------------------------------------- Criticon · 2010-12-23 09:52 Well! I think that's quite easy. Since console applications are made for the console you should debug them with fpc or with the fpc-IDE (fp.exe) not with Lazarus or Delphi (the DP-command line compiler is of very limited value for this purpose). Running your apllication in a Shell gives you the possibility to catch runtime errors and go back to the source code - most other errors are shown directly by the freepascalcompiler (the 'engine' behind lazarus). You can download the whole package from www.freepascal.org (if You have Lazarus then you will have fpc too but in most cases this won't be the newest release). Pls be careful: fpc2.40 had a feaulty fp-IDE so You should use a newer (or older) version. regards ---------------------------------------------------------------------- ik · 2010-12-23 10:01 I usually debug programs either by write to thee screen or to a log file and see what happens. FPC Have TEventLog that you can use for log information. If you want to debug a console application with writeln, you can do something like this: Code: [Select]writeln(stderr, 'some text to see'); And on terminal: Code: [Select]$ ./myprogram 2> file_or_device_to_redirect_the_output For the above, you should do it only if you do not view it directly on the screen.