[ale] OT: Sending Commands to GDB

Tim Watts tim at cliftonfarm.org
Wed Jan 19 08:55:03 EST 2011


I wonder if gdb is purging stdin during init thus discarding what was
piped in. Then when it's ready to read commands from stdin finds it's
been closed.

To test this I tried this command:

$ tee junk.txt | gdb /bin/true

Sure enough, it brought me to the gdb prompt and when I typed 'pwd' and
'quit' it required a ^C to get back to the shell. 'cat junk.txt' showed
the commands I typed.

This isn't a conclusive test. You'd have to pipe something in initially
too while leaving the pipe open and observe that the initial output is
discarded. But it suggests to me that my hypothesis is plausible.


On Tue, 2011-01-18 at 22:53 -0500, Brian Pitts wrote:
> Hi,
> 
> I'm trying to non-interactively use gdb, but I can't get it to work.
> Below is an example of what I'm trying and failing to accomplish. I
> expected the first two commands to print the same thing that the third
> command does. Instead, they print nothing. Can anyone explain why and/or
> show me a workaround that doesn't involve a temporary file?
> 
> $ echo pwd | gdb -batch -x /dev/stdin /bin/true
> 
> $ gdb -batch -x <(/bin/echo pwd) /bin/true
> 
> $ echo pwd > gdb_script && gdb -batch -x gdb_script /bin/true
> Working directory /home/brian.
> 
> Without batch mode, gdb reports for command #1
> 
> /dev/stdin: No such file or directory.
> (gdb) Hangup detected on fd 0
> error detected on stdin
> 
> and for command #2
> 
> /proc/self/fd/63: No such file or directory.
> 




More information about the Ale mailing list