Recent

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

440bx

  • Hero Member
  • *****
  • Posts: 3944
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.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

sash

  • Sr. Member
  • ****
  • Posts: 366
Not related to debugging, but Menu -> Run -> Run Parameters -> Command line (without appname) "> out.txt" works for me.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

440bx

  • Hero Member
  • *****
  • Posts: 3944
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 ?
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9792
  • Debugger - SynEdit - and more
    • 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

  • Hero Member
  • *****
  • Posts: 3944
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.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

sash

  • Sr. Member
  • ****
  • Posts: 366
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 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

440bx

  • Hero Member
  • *****
  • Posts: 3944
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.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018