gdb 管道重定向错误:(gdb) 在 fd 0 上检测到挂断

发布于 2024-12-15 13:06:59 字数 759 浏览 0 评论 0原文

帮忙,我该如何解决这个问题?我无法将命令从 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一抹淡然 2024-12-22 13:06:59

另一种效果很好的技术是使用此处文档将输入重定向到 gdb:

gdb -quiet -nx << EndOfInput
thread apply all bt
quit
EndOfInput

这使得编写控制 gdb 的脚本而无需使用临时文件成为可能。它似乎完全避免了“检测到挂断”消息。

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.

强辩 2024-12-22 13:06:59

如果您的目标是在 gdb 启动时执行命令“list”,最简单的方法是使用 .gdbinit 启动文件。例如:

$ echo list > .gdbinig
$ gdb a.out

如果您希望 gdb 在运行 .gdbinit 中列出的命令后退出,请执行以下操作:

$ echo quit >> .gdbinit

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文