[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

cat-ing commands into gdb (or other program) and terminating cleanly

From: Mad Brad
Subject: cat-ing commands into gdb (or other program) and terminating cleanly
Date: Tue, 15 Jan 2008 17:45:13 -0800 (PST)
User-agent: G2/1.0

my context: I'm trying to create a system() command within my C
that invokes gdb, piping it some initial commands and then turning
over to the user to interact with as usual.  I don't want to use gdb's
command files support because I would prefer to avoid creating files
within this program.

my command: The closest I've come to succeeding is using the following

     (echo "break main" && cat - ) | gdb a.out

For example, this sets a breakpoint at main and then turns control
over to
the console input.

the result: What I'm finding is that when I type "quit" at the gdb
I have to hit <ENTER> an extra time before I'm returned to a command
I'm guessing that this is because the gdb process has ended but that
the cat
command doesn't realize that it's gone until I've typed in my next

my query:  Can anyone verify my theory/suggest another means of doing
My question seems to be more about "cat" than gdb per se (which is to
say, I
believe that piping cat into other programs in this way would generate
similar behavior).  That said, I ultimately want to apply this to gdb,
so if
there are any gdb-specific tricks (again, not using command files),
would be very helpful.

Thanks very much for any tips,
-Brad Chamberlain

reply via email to

[Prev in Thread] Current Thread [Next in Thread]