简体   繁体   English

管道命令时,gdb不会停止

[英]gdb does not stop when piping the command

When running the usual way, gdb stops as expected: 当以常规方式运行时, gdb按预期停止:

(gdb) break main
(gdb) run
Starting program ...
Breakpoint 1, main ...

when running while piping, gdb never stops: 在管道运行时, gdb永不停止:

(gdb) run | cat
Starting program: /home/sds/z | cat
...
During startup program exited normally.
(gdb)

How do I debug program behavior when piping? 配管时如何调试程序行为?

my setup: 我的设置:

$ gdb --version
GNU gdb (GDB) Amazon Linux (7.6.1-64.33.amzn1)
$ uname -a
Linux datasci-1 4.4.19-29.55.amzn1.x86_64 #1 SMP Mon Aug 29 23:29:40 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version
gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9)

same problem on the most recent fully updated ubuntu (16.10). 最近完全更新的ubuntu(16.10)上存在相同的问题。

While input and output redirection work, you cannot use pipes to pass the output of the program you are debugging to another program; 在输入和输出重定向工作时,不能使用管道将要调试的程序的输出传递给另一个程序。 if you attempt this, GDB is likely to wind up debugging the wrong program. 如果您尝试这样做,GDB可能会结束调试错误的程序。

https://www.sourceware.org/gdb/onlinedocs/gdb.html https://www.sourceware.org/gdb/onlinedocs/gdb.html

Based on another answer : 根据另一个答案

(gdb) run > >(cat)

See Process Substitution . 参见过程替代

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM