2009-04-20 80 views
3

我試圖調試在Emacs用gdb模式的程序。它是用g ++編譯的,我正在使用cygwin。我的程序需要一個命令行參數,並且還需要輸入從標準輸入,這是我從一個文件重定向,像這樣:GDB不會接受標準輸入重定向在Emacs

program.exe inputFile.dat <otherInput.dat 

的問題是,GDB是發送串

"<otherInput.dat" 

爲命令行參數而不是重定向標準輸入。我如何強制gdb重定向stdin?

編輯:

GDB中,我使用的命令:

run inputFile.dat <otherInput.dat 

,當我用GDB的emacs之外它不工作,要麼。

編輯#2:

DFA指出了一個類似的問題:How to load program reading stdin and taking parameters in gdb?

不幸的是,這個問題是不是爲我工作接受的答案......這可能是一個cygwin相關的bug?

+0

重複的[http://stackoverflow.com/questions/455544/how-to-load-program-reading-stdin-and-taking-parameters-in-gdb](http://stackoverflow.com/questions/455544/how-to-load-program-reading-stdin-and-taking-parameters-in-gdb)? – dfa 2009-04-20 17:23:38

回答

1

如果你正在使用bash,你可以立即做PROGRAM ARGS < FILE & jobs -x gdb PROGRAM %1 GDB附加到進程。根據您使用的shell,你可能會發現自己不得不使用更多的創造性的方法(可能涉及從ps -C輸出重定向到gdb的命令行)。