无法调试Eclipse上的小程序helios cdt在windows下使用mingw / gdb,控制台死机 [英] can't debug small program on eclipse helios cdt using mingw/gdb under windows, console freezes

查看:179
本文介绍了无法调试Eclipse上的小程序helios cdt在windows下使用mingw / gdb,控制台死机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用Eclipse CDT来做一些c ++示例,我可以使用run命令很好地运行它们,但是每当我尝试调试时,控制台窗口都会冻结,我可以输入,但是该程序不会继续。



当我调试时,我在控制台窗口上得到以下输出(没有断点,但由于默认设置而断开):

 您好,世界
将您的名字:15 ^运行

继续按钮被禁用,当我输入内容并点击输入时,该按钮不会执行任何操作。 15是一个随机数,有时候是16,20等。

如果我在eclipse下运行该程序,那么输入提示符会很好:

 你好,世界
放你的名字:test
你好测试

这是我尝试调试的代码:

  #include <&的iostream GT; 
#include< string>

int main(){
std :: cout<< 你好,世界<<的std :: ENDL;
std :: string name;
std :: cout<< 把你的名字:;
std :: cin>>名称;
std :: cout<< 你好+名字<<的std :: ENDL;
返回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 Service Release 2

CDT版本:7.0.2

操作系统:windows xp

GDB版本:GNU gdb(GDB)7.2



如何在CDT下调试这个小例子,问题?

解决方案

以下是来自Eclipse网站的常见问题:

http://wiki.eclipse.org/CDT/User/FAQ#Eclipse_console_does_not_show_output_on_Windows
$ b


Eclipse控制台不显示Windows上的输出在
上的Eclipse CDT中,正在运行或调试的程序的标准输出完全是
缓冲,因此e它没有连接到Windwos控制台,而是连接到
管道。有关更多详细信息,请参阅错误173732。在
每个printf之后添加fflush调用,或者在主
函数的开头添加以下行:



  setvbuf(stdout,NULL,_IONBF,0); 
setvbuf(stderr,NULL,_IONBF,0);

看起来像是Windows上的预期错误。

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?

解决方案

the following is from the Eclipse website's FAQ:

http://wiki.eclipse.org/CDT/User/FAQ#Eclipse_console_does_not_show_output_on_Windows

Eclipse console does not show output on Windows In Eclipse CDT on Windows, standard output of the program being run or debugged is fully buffered, because it is not connected to a Windwos console, but to a pipe. See bug 173732 for more details. Either add fflush calls after every printf or add the following lines in the start of the main function:

setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);

Seems like an expected bug on windows.

这篇关于无法调试Eclipse上的小程序helios cdt在windows下使用mingw / gdb,控制台死机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆