Reputation: 1080
Help, how do i fix this? I am unable to redirect command from stdin to gdb.
I get this error:
charmae@charmae-pc:~/workspace/AVT$ echo "list" | gdb a.out
GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/charmae/workspace/AVT/a.out...done.
(gdb) Hangup detected on fd 0
error detected on stdin
Upvotes: 2
Views: 2601
Reputation: 21
Another technique that works nicely is to redirect input to gdb using a here-document:
gdb -quiet -nx << EndOfInput
thread apply all bt
quit
EndOfInput
This makes it possible to write a script which controls gdb without having to use temporary files. It seems to avoid the "Hangup detected" message completely.
Upvotes: 2
Reputation: 212268
If your goal is to execute the command "list" when gdb starts up, the easiest way to do that is to use a .gdbinit startup file. For example:
$ echo list > .gdbinig $ gdb a.out
If you want gdb to exit after running the commands listed in .gdbinit, do:
$ echo quit >> .gdbinit
Upvotes: 0