www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/02/07/04:13:55

To: "Charles W. Kann" <ckann AT seas DOT gwu DOT edu>
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu, mfeldman AT seas DOT gwu DOT edu (Michael Feldman),
banner AT cs DOT nyu DOT edu, drupp AT cs DOT washington DOT edu
Subject: Re: Need help with gdb!
Date: Tue, 07 Feb 95 08:33:02 +0200
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>

> The problem is this.  I want the output from the program to go to the
> terminal, but I want to gdb output (ie, the backtrace) to go to a file.  I do
> this on unix by redirecting the output from the gdb command to a file, but
> sending the output of the "run" command inside of gdb to the terminal, ie:
>
>	unix_prompt > gdb > myfile
>	gdb > run > /dev/tty

How about this:

	gdb > myfile

and in your program call freopen()/dup()/dup2() to explicitly
open the console on handles 2 and 3 (stdout and stderr).

> to be completely ignored.  I can't redirect the output anywhere.  Even if I 
> could, I don't know the name of the tty.

Under DOS, you can reference the tty as either "con" or "/dev/con".

> I then tried to send all output to a filter program which would strip out any
> gdb stuff and send the user's output to the screen, ie:
>
>	go32 -d gdb myprog | myfilter.exe
>
> However, gdb does not appear to write any output to the filter until after it
> has finished running.  Then, any gdb output appears before any program output,
> even though the program output was written first.

This is really different under DOS, as pipes don't run in parallel.
The command processor just calls the first program redirecting its
stdout to a temporary file, then, after it exits, calls the second
one with its stdin redirected to that same temporary file, then
deletes the temporary after the last program in the pipe exits.
Silly, I know, but DOS was supposed to be a silly operating system
(the first version was called QDOS, for Quick and Dirty Operating
System).  Don't blame its authors that it outgrew their every wild
expectation (making some of them rich in the process).  And silly
as this ``pipe'' is, it does work for batch jobs.

> Can anyone help me split the gdb output from the program output, so that I can
> send the program output to the tty?

You could also use direct screen I/O in your program (functions
from <conio.h> header (if you can call C functions from an Ada
program).  Or you could install an additional video card and
(monochrome) monitor and redirect the debugger output there
by using the ``mono'' parameter in the GO32 environment variable.
There are also the 2r1 and 1r2 parameters that you migt want to
experiment with, but I don't know whether they can differentiate
between the output of the debugger and your program (I didn't try).

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019