我正在尝试在 emacs 中使用 gdb 模式调试程序。它是用 g++ 编译的,我使用的是 cygwin。我的程序接受一个命令行参数,并且还接受来自标准输入的输入,我从文件重定向该输入,如下所示:
program.exe inputFile.dat <otherInput.dat
问题是,gdb 正在发送字符串
"<otherInput.dat"
作为命令行参数而不是重定向标准输入。如何强制 gdb 重定向 stdin?
编辑:
在 gdb 中,我使用以下命令:
run inputFile.dat <otherInput.dat
当我在 emacs 之外使用 gdb 时,它也不起作用。
编辑#2:
dfa指出了类似的问题:How to load program reading stdin and taking parameters in gdb?
不幸的是,该问题的公认答案对我不起作用......这可能是与 cygwin 相关的错误吗?
最佳答案
看来你必须使用run
命令:
You can redirect your program's input and/or output using shell redirection with the run > command. For example,
run > outfile
http://sourceware.org/gdb/current/onlinedocs/gdb_5.html#SEC24
关于c++ - gdb 在 Emacs 中不接受 stdin 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/769250/