* * *

Author Topic: how to tell the debugger to redirect the debuggee's output to a file ?  (Read 1337 times)

440bx

  • Sr. Member
  • ****
  • Posts: 292
Hello,

basically what I'm trying to do is to debug a console program that would be started on the command line with its output redirected, i.e:

TheProgram.exe > PutOutputHere

how do I tell the debugger to redirect the debuggee's output (stdout) to the file "PutOutputHere" ?

Thank you for your help.



sash

  • Full Member
  • ***
  • Posts: 104
Not related to debugging, but Menu -> Run -> Run Parameters -> Command line (without appname) "> out.txt" works for me.
Lazarus 1.8.4 Unversioned directory FPC 3.0.4 x86_64-linux-gtk2

440bx

  • Sr. Member
  • ****
  • Posts: 292
Not related to debugging, but Menu -> Run -> Run Parameters -> Command line (without appname) "> out.txt" works for me.

Thank you.  I tried that but, it didn't work for me.   My program sees the ">" and "out.txt" as command line parameters.  It was worth a try.

Are you using a flavor of unix or Windows ?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4810
    • wiki
Not tested: (unix /Mac only)

Tools > Opiton > Debugger: Look through the property grid, there should be an option about "...Pty...". Try to put your filename there.

This option is global. Not per project

440bx

  • Sr. Member
  • ****
  • Posts: 292
Not tested: (unix /Mac only)

Tools > Opiton > Debugger: Look through the property grid, there should be an option about "...Pty...". Try to put your filename there.

This option is global. Not per project

Thank you Martin.  Maybe I didn't set the right field but, I didn't get any of those I tried to work.  I just added a little bit of code that is conditionally compiled to do the redirection "manually".  Not exactly elegant but, it serves the purpose.  It will do and it's easily re-useable :)

Again, thank you.

sash

  • Full Member
  • ***
  • Posts: 104
I tried that but, it didn't work for me.   My program sees the ">" and "out.txt" as command line parameters.

In Ubuntu Linux 18.04, simple console program
Code: Pascal  [Select]
  1. program console;
  2. begin
  3.   WriteLn('Params: ', ParamCount, ParamStr(1));
  4.   WriteLn('Press any key');
  5.   ReadLn;
  6. end.
  7.  
with given option creates a file "out.txt", and waits for <Enter> to resume (I use View->Debug Windows-> Terminal Output for input)
out.txt has following contents:
Quote
Params: 0
Press any key
Lazarus 1.8.4 Unversioned directory FPC 3.0.4 x86_64-linux-gtk2

440bx

  • Sr. Member
  • ****
  • Posts: 292
I tried that but, it didn't work for me.   My program sees the ">" and "out.txt" as command line parameters.

In Ubuntu Linux 18.04, simple console program
Code: Pascal  [Select]
  1. program console;
  2. begin
  3.   WriteLn('Params: ', ParamCount, ParamStr(1));
  4.   WriteLn('Press any key');
  5.   ReadLn;
  6. end.
  7.  
with given option creates a file "out.txt", and waits for <Enter> to resume (I use View->Debug Windows-> Terminal Output for input)
out.txt has following contents:
Quote
Params: 0
Press any key
I cannot make it work under Windows.  No matter what I do, it sees the redirection character and file to redirect to as command line parameters for the program.

 

Recent

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