[ale] OT: Sending Commands to GDB
Tim Watts
tim at cliftonfarm.org
Wed Jan 19 09:25:28 EST 2011
More progress. Try this:
#!/bin/bash
sleep 0.5
cat
echo quit
sleep 0.5
and this:
$ echo pwd |./gdbin|gdb /bin/true
[BTW, how is this OT?]
On Wed, 2011-01-19 at 09:15 -0500, Tim Watts wrote:
> Update:
>
> wrote this script (gdbin):
>
> #!/bin/bash
> echo pwd
> sleep 3
> echo quit
>
> then tried this:
>
> $ ./gdbin|gdb /bin/true
>
> Output:
>
> Reading symbols from /bin/true...(no debugging symbols found)...done.
> (gdb) Working directory /home/timtw.
> (gdb) Hangup detected on fd 0
> error detected on stdin
>
> So keeping the pipe open seems to be the key (even though it complained
> at the end). This probably won't be a solution to your final goal but
> hopefully a step in the right direction.
>
>
> On Wed, 2011-01-19 at 08:55 -0500, Tim Watts wrote:
> > 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.
> > >
> >
> >
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://mail.ale.org/mailman/listinfo/ale
> > See JOBS, ANNOUNCE and SCHOOLS lists at
> > http://mail.ale.org/mailman/listinfo
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
More information about the Ale
mailing list