help-gnu-utils
[Top][All Lists]
Advanced

[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
program
that invokes gdb, piping it some initial commands and then turning
control
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
from
within this program.

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

     (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
command,
I have to hit <ENTER> an extra time before I'm returned to a command
prompt.
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
line.

my query:  Can anyone verify my theory/suggest another means of doing
this?
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),
that
would be very helpful.

Thanks very much for any tips,
-Brad Chamberlain


reply via email to

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