windows下无法使用mingw/gdb在eclipse helios cdt上调试小程序,控制台冻结
我一直在尝试使用 Eclipse CDT 来做一些 C++ 示例,我可以使用 run 命令很好地运行它们,但是每当我尝试调试时,控制台窗口就会冻结,我可以输入,但程序不运行不继续了
当我调试时,我在控制台窗口上得到以下输出(没有断点,但由于默认设置而在 main 上中断):
Hello, world
put your name: 15^running
继续按钮被禁用,当我输入内容并按 enterenter。 15 是一个随机数,有时是 16、20 等。
如果我在 Eclipse 下运行该程序,我会得到输入提示:
Hello, world
put your name: test
Hello test
这是我尝试调试的代码:
#include <iostream>
#include <string>
int main() {
std::cout << "Hello, world" << std::endl;
std::string name;
std::cout << "put your name: ";
std::cin >> name;
std::cout << "Hello " + name << std::endl;
return 0;
}
我的路径 var:C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\Java\jdk1.6.0_14\bin;C:\MinGW\bin
Eclipse版本:Helios 服务版本 2
CDT版本:7.0.2
操作系统:windows xp
GDB 版本:GNU gdb (GDB) 7.2
如何在 CDT 下调试这个小示例而不出现问题?
I've been trying to use Eclipse CDT to do some c++ examples, i can run them just fine with the run command, but whenever i try to Debug, the console window freezes up, I'm able to input, but the program doesn't continue.
When I debug, i get the following output on the console window (no breakpoints, but breaks on main because of default settings):
Hello, world
put your name: 15^running
The continue button is disabled and doesn't do anything when I input something and hit enter. The 15 is a random number, sometimes its 16, 20 etc.
If I run the program under eclipse I get the input prompt just fine:
Hello, world
put your name: test
Hello test
this is the code I try to debug:
#include <iostream>
#include <string>
int main() {
std::cout << "Hello, world" << std::endl;
std::string name;
std::cout << "put your name: ";
std::cin >> name;
std::cout << "Hello " + name << std::endl;
return 0;
}
My path var:C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program Files\Java\jdk1.6.0_14\bin;C:\MinGW\bin
Eclipse version: Helios Service Release 2
CDT version: 7.0.2
OS: windows xp
GDB version: GNU gdb (GDB) 7.2
How can I debug this small example under CDT, without issues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
15^running
看起来像是 gdb 的 的结果记录机器接口。通常它不应该出现在 Eclipse 控制台中。我建议尝试不同的创建进程启动器。可以通过以下方式更改:
在主菜单中选择“运行”-> “调试配置...”。
在打开的“调试配置”窗口中,如下所示,单击“使用 GDB (DSF) 创建进程启动器”对面的“选择其他...”。
在打开的“选择首选启动器”窗口中,如下所示,选中“使用配置特定设置”,在下面的列表中选择“标准创建流程启动器”,然后单击“确定”。
现在转到“调试配置”窗口中的“调试器”选项卡,选择调试器,例如“ MinGW gdb”并单击“应用”。
使用标准创建进程启动器,我可以调试您的程序,尽管打印了“输入您的名字:”仅在我输入内容并按 Enter 键后,因为输出流未刷新。
15^running
looks as a result record from gdb's Machine Interface. Normally it shouldn't appear in the Eclipse console.I recommend trying a different Create Process Launcher. It can be changed in the following way:
In Main menu choose "Run" -> "Debug Configurations...".
In the opened "Debug Configurations" window shown below click "Select other..." opposite "Using GDB (DSF) Create Process Launcher".
In the opened "Select Preferred Launcher" window shown below check "Use configuration specific settings", select "Standard Create Process Launcher" in the list below and click OK.
Now go to the Debugger tab in the "Debug Configurations" window, select debugger, e.g. "MinGW gdb" and click Apply.
With the Standard Create Process Launcher I am able to debug your program although "put your name:" is printed only after I type something and hit Enter, because the output stream is not flushed.
尝试看看这个 http://www.cprogramming.com/gdbtutorial.html 和看看是否有帮助。就像你可以按 CTRL-C 来打破吗?
另外 无法使用 gdb 输入。 Help! 可能是一个指针,尽管与 apple 相关。
Try having a look at this http://www.cprogramming.com/gdbtutorial.html and see if that helps. Like can you press CTRL-C to break?
Also Cannot enter input with gdb. Help! might be a pointer although related to apple.
以下内容来自 Eclipse 网站的常见问题解答:
http://wiki.eclipse.org/CDT/用户/常见问题解答#Eclipse_console_does_not_show_output_on_Windows
似乎是 Windows 上的预期错误。
the following is from the Eclipse website's FAQ:
http://wiki.eclipse.org/CDT/User/FAQ#Eclipse_console_does_not_show_output_on_Windows
Seems like an expected bug on windows.