public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Output redirection
@ 2000-07-21 16:05 Sashan Govender
  2000-07-21 16:36 ` Chris Faylor
  0 siblings, 1 reply; 5+ messages in thread
From: Sashan Govender @ 2000-07-21 16:05 UTC (permalink / raw)
  To: gdb

Hi.

Why can't I get output redirection work with gdb 4.18 (configured as
'i386-mingw32') using Win95?
This is what i do after starting gdb:

	file testprog.exe

	run > out.txt

as the help files say, but gdb seems to think that the > and out.txt
are arguments to be passed to main.

If I do this instead:

	shell testprog.exe > out.txt

the Win95 console runs testprog and redirects the output to the file 
out.txt, but this is useless because it's not running testprog within gdb.

Also does gdb separate its output from the output from the program
that is being debugged internally? Does it send the debugee's output
to another stream? As far as I can tell both outputs go to the same
stream (stdout), even with a new console set. I'm interested in being
able to separate the output from gdb from the output of program being
debugged because I have to write a GUI for Windows for gdb.

Thank you
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Output redirection
  2000-07-21 16:05 Output redirection Sashan Govender
@ 2000-07-21 16:36 ` Chris Faylor
  2000-07-22  2:22   ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Faylor @ 2000-07-21 16:36 UTC (permalink / raw)
  To: gdb; +Cc: sashang

On Fri, Jul 21, 2000 at 04:05:17PM -0700, Sashan Govender wrote:
>Why can't I get output redirection work with gdb 4.18 (configured as
>'i386-mingw32') using Win95?
>This is what i do after starting gdb:
>
>	file testprog.exe
>
>	run > out.txt

This kind of redirection doesn't work on Windows gdb.  Sorry.

>Also does gdb separate its output from the output from the program
>that is being debugged internally? Does it send the debugee's output
>to another stream? As far as I can tell both outputs go to the same
>stream (stdout), even with a new console set. I'm interested in being
>able to separate the output from gdb from the output of program being
>debugged because I have to write a GUI for Windows for gdb.

If you are debugging a console application with the console version of
gdb, the output goes to the same place as the gdb output.

This may be different for the GUI version of gdb, though.  However, if
you've built your own version of gdb you may not have this.  It requires
linking in tcl/tk to run.

cgf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Output redirection
  2000-07-21 16:36 ` Chris Faylor
@ 2000-07-22  2:22   ` Eli Zaretskii
  0 siblings, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2000-07-22  2:22 UTC (permalink / raw)
  To: Chris Faylor; +Cc: gdb, sashang

> From: Chris Faylor <cgf@cygnus.com>
> Date: Fri, 21 Jul 2000 19:36:27 -0400
> 
> On Fri, Jul 21, 2000 at 04:05:17PM -0700, Sashan Govender wrote:
> >Why can't I get output redirection work with gdb 4.18 (configured as
> >'i386-mingw32') using Win95?
> >This is what i do after starting gdb:
> >
> >	file testprog.exe
> >
> >	run > out.txt
> 
> This kind of redirection doesn't work on Windows gdb.  Sorry.
> 
> >Also does gdb separate its output from the output from the program
> >that is being debugged internally? Does it send the debugee's output
> >to another stream? As far as I can tell both outputs go to the same
> >stream (stdout), even with a new console set. I'm interested in being
> >able to separate the output from gdb from the output of program being
> >debugged because I have to write a GUI for Windows for gdb.
> 
> If you are debugging a console application with the console version of
> gdb, the output goes to the same place as the gdb output.

I was annoyed by similar misbehavior in the DJGPP (a.k.a. MS-DOS) port
of GDB for many years, until I finally fixed this a year or so ago.

The solution involves a bunch of functions that redirect standard
handles (using dup and dup2) between the debugger's own and debuggee's
streams.  That is, the target-specific module in GDB (go32-nat.c, in
my case) switches the standard handles to the debugger's streams when
the debuggee stops, and switches them back again when the debuggee is
about to be resumed.

This creates an illusion of two separate sets of standard handles that
works well enough.  It even supports the case when the debuggee closes
one of its standard handles (previously, if that happened, GDB would
lose the corresponding handle too; if that handle was stdin, you will
not be able to talk to GDB anymore!)

Perhaps someone would like to reuse the code I wrote for this in the
Mingw port.  Look in go32-nat.c for the calls to functions whose names
begin with "redir_"; the two functions `redir_to_debugger' and
`redir_to_child', called from `go32_terminal_ours' and
`go32_terminal_inferior', are the workhorse of this machinery.  The
functions themselves are part of the DJGPP's debug support library;
see the file src/debug/common/dbgredir.c in the DJGPP source
distribution (djlsr203.zip from the usual DJGPP sites).

The code in dbgrdir.c includes proper handling of quotes in command
lines, to emulate the behavior of stock DOS/Windows shell COMMAND.COM;
thus, the argument to the "run" command may be a full-fledged
command-line tail as you'd typically type it at the command prompt.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Output redirection
  2000-07-21 17:36 Sashan Govender
@ 2000-07-21 19:05 ` Chris Faylor
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Faylor @ 2000-07-21 19:05 UTC (permalink / raw)
  To: gdb; +Cc: sashang

On Fri, Jul 21, 2000 at 05:35:44PM -0700, Sashan Govender wrote:
>>This may be different for the GUI version of gdb, though.  However, if
>>you've built your own version of gdb you may not have this.  It requires
>>linking in tcl/tk to run.
>
>Thanks for your help. This is something I've been bashing my head against 
>for a long time (months). It's a relief to know what the problem is. 
>However, I don't understand what you mean in your last paragraph. I know 
>tcl/tk is a development environment but what requires linking in it console 
>gdb or a GUI version of gdb?

Hmm.  Well I'm confused by your confusion.

gdb has a GUI component.  It's known as either gdbtk or insight.

For gdb to be built as a GUI requires linking in various tcl/tk
modules.  If they are not available, gdb will only be built as a
console app.

Check out http://sourceware.cygnus.com/insight/ for more information.

You can also download a version of gdb/insight from the cygwin project:
http://sourceware.cygnus.com/cygwin/ .

If you install the cygwin environment then the gdb that you get also
includes insight.

cgf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Output redirection
@ 2000-07-21 17:36 Sashan Govender
  2000-07-21 19:05 ` Chris Faylor
  0 siblings, 1 reply; 5+ messages in thread
From: Sashan Govender @ 2000-07-21 17:36 UTC (permalink / raw)
  To: gdb

>From: Chris Faylor <cgf@cygnus.com>
>Reply-To: gdb@sources.redhat.com
>To: gdb@sourceware.cygnus.com
>CC: sashang@hotmail.com
>Subject: Re: Output redirection
>Date: Fri, 21 Jul 2000 19:36:27 -0400
>
>On Fri, Jul 21, 2000 at 04:05:17PM -0700, Sashan Govender wrote:
> >Why can't I get output redirection work with gdb 4.18 (configured as
> >'i386-mingw32') using Win95?
> >This is what i do after starting gdb:
> >
> >	file testprog.exe
> >
> >	run > out.txt
>
>This kind of redirection doesn't work on Windows gdb.  Sorry.
>
> >Also does gdb separate its output from the output from the program
> >that is being debugged internally? Does it send the debugee's output
> >to another stream? As far as I can tell both outputs go to the same
> >stream (stdout), even with a new console set. I'm interested in being
> >able to separate the output from gdb from the output of program being
> >debugged because I have to write a GUI for Windows for gdb.
>
>If you are debugging a console application with the console version of
>gdb, the output goes to the same place as the gdb output.
>
>This may be different for the GUI version of gdb, though.  However, if
>you've built your own version of gdb you may not have this.  It requires
>linking in tcl/tk to run.
>
>cgf

Thanks for your help. This is something I've been bashing my head against 
for a long time (months). It's a relief to know what the problem is. 
However, I don't understand what you mean in your last paragraph. I know 
tcl/tk is a development environment but what requires linking in it console 
gdb or a GUI version of gdb?


Thanks again.
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-07-22  2:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-21 16:05 Output redirection Sashan Govender
2000-07-21 16:36 ` Chris Faylor
2000-07-22  2:22   ` Eli Zaretskii
2000-07-21 17:36 Sashan Govender
2000-07-21 19:05 ` Chris Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).