First you can run the program and debug it using pid. This decision, of course, does not apply to all cases.
Another approach is to use the power of Linux for interprocess communication. In short, you redirect the output of ret to a special FIFO file ("named pipe"), and then read from this FIFO through the debugger. Here's how to do it. From bash, run:
mkfifo foo
This creates a special file in your directory that will serve as a named pipe. When you write text to this file (using the same echo "Hello" >foo syntax echo "Hello" >foo ), the writer will block until someone reads the data from the file (for example, cat <foo ). In our case, a process controlled by gdb will be read from this file.
Once you have created fifo, start with bash:
ret > foo &
Then at gdb command prompt run
run <foo
And get the desired effect. Please note that you cannot read data from fifo (as well as from a regular channel) twice: when you read all the data, the blah process dies and you must repeat the command written in foo (you can do this from another shell window).
When you're done, delete fifo with rm foo (or put it in a directory where it will be automatically deleted when the system reboots, for example /tmp ).
Pavel Shved Sep 21 '09 at 19:25 2009-09-21 19:25
source share