帮助,我该如何解决这个问题?我无法将命令从stdin重定向到gdb。
我收到此错误:
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
答案 0 :(得分:2)
另一种很好用的技术是使用here-document将输入重定向到gdb:
gdb -quiet -nx << EndOfInput
thread apply all bt
quit
EndOfInput
这使得编写控制gdb的脚本成为可能,而不必使用临时文件。它似乎完全避免了“挂断检测”消息。
答案 1 :(得分:0)
如果你的目标是在gdb启动时执行命令“list”,最简单的方法是使用.gdbinit启动文件。例如:
$ echo list > .gdbinig $ gdb a.out
如果要在运行.gdbinit中列出的命令后退出gdb,请执行:
$ echo quit >> .gdbinit