delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/05/15:00:39

Xref: news2.mv.net comp.os.msdos.djgpp:3465
From: ckann AT seas DOT gwu DOT edu (Charles W. Kann)
Newsgroups: comp.os.msdos.djgpp
Subject: gdb and stdout
Date: 5 May 1996 15:12:52 GMT
Organization: George Washington University
Lines: 44
Message-ID: <4mighk$7h1@cronkite.seas.gwu.edu>
NNTP-Posting-Host: 128.164.9.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I am having a problem with gdb and version 2 of djgpp, redirecting stdout.
The basic problem is I want stdout from gdb to go to a file, and the 
user's output to go to the Console (CON).  The rest of this tells what I
have done, and what I have found does not work.

I am running a user's program under gdb without them knowing it.  I have
a gdb.ini file I generate which looks like:

  break __gnat_unhandled_exception 
  commands 
  shell echo "\"#***BACKTRACE***\"" 
  bt 
  shell echo "\"#***DONE EXCEPTION***\"" 
  continue 
  end 
  run
  quit

when gdb starts, there program runs normally unless __gnat_unhandled_exception
gets called, in which case I produce a backtrace so I can show them where
the problem occured.

The problem is that I want to reformat the backtrace, so I send it to 
a file.  However, I want the user to see their output as the program 
runs.  In djgpp version 1, I would run:

	gdb program.cof > tmpfile

Then to get the users output to come to the screen rather than the tmpfile,
in the users program I would reopen stdout to the console.  It was a trick,
but it worked fine.

In v2, if I reopen the user's console in the program, stdout for djgpp is put
back on the console, not the tmpfile  I have tried:

	run > CON

but then the users output still gets put in the tmpfile.

How can I split the stdout io streams between the two programs?

--
chuck kann
ckann AT seas DOT gwu DOT edu

- Raw text -


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