在Linux上,使用Eclipse CDT中的gdb调试C ++应用程序,如何向stdin输入内容? [英] On Linux, Debugging a C++ application with gdb in Eclipse CDT, how to input something to stdin?
问题描述
在Linux上,我正在尝试使用Eclipse CDT中的gdb调试C ++应用程序。
On Linux, I am trying to debug a C++ application with gdb in Eclipse CDT.
例如,应用程序 applic.exe
需要一些命令行参数 arg1
和 arg2
,并且期望 stdin
(例如,取自文件 input.txt
)。
For example the application applic.exe
takes some command line arguments arg1
and arg2
and it expects some data on stdin
(say, taken from a file input.txt
).
通常,要在控制台中运行该应用程序,我将执行以下操作:
Normally, to run the application in the console I would do this:
cat input.txt | applic.exe arg1 arg2
在控制台中使用gdb可以做到:
Using gdb in the console I can do:
gdb applic.exe
(gdb) run applic.exe arg1 arg2 < input.txt
是否可以在Eclipse中使用gdb做到这一点?我知道如何在Eclipse Debug Configurations 中指定参数(和环境),但是 stdin
呢?
Is it possible to do that with gdb in Eclipse? I know how to specify the arguments (and the environment) in the Eclipse Debug Configurations, but what about stdin
?
推荐答案
Eclipse中有控制台选项卡(位于IDE的底部),您可以将数据放在此处。
There is Console tab in Eclipse (at the bottom of IDE) you can put your data here.
这篇关于在Linux上,使用Eclipse CDT中的gdb调试C ++应用程序,如何向stdin输入内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!