Program input (cin or getline) is read in correct when running but not when debugging

时间:2017-04-10 00:08:02

标签: debugging console mingw eclipse-cdt

I'm having trouble trying to debug C++ with input from cin and/or getline. It works perfectly when I run instead of debug. I'm using Eclipse neon CDT in Windows 8.1 with MinGW compiler/debugger (64bit). Running a sample program to isolate the issue that uses getline for input and extracts the first character for comparison:

while (true) {
  cout << "Enter x to exit: ";
  getline(cin, input);
  myChar = input[0];
  if (myChar=='x') {
    break;
  }

  cout << "You entered: " <<myChar<<endl;
}
cout <<"Exiting..."<<endl;

When I run it - it works perfectly. However when I try to debug, it either a) doesn't wait for input and makes up it's own, or b) ignores my input and makes up it's own. I've seen both of these happen when experimenting in different projects.

I thought maybe I needed to make sure it was reading chars as UTF-8. But the settings I found seem to be for the text editor or text files (Window->Preferences->General->Workspace)...not the console.

I read that there are sometimes issues with console input and tried using native Windows console instead of the IDE integrated one as described here: http://nicolas.riousset.com/eclipse-how-to-debug-a-c-console-application-using-a-native-dos-console-instead-of-the-ide-integrated-one/

Unfortunately then I just get an error when trying to launch the debugger:

Error in final launch sequence Failed to execute MI command: record Error message from debugger back end: Process record: the current architecture doesn't support record function. Process record: the current architecture doesn't support record function.

1 个答案:

答案 0 :(得分:0)

  

不幸的是,我在尝试启动调试器时遇到错误:

     

最终启动顺序错误执行MI命令失败:记录来自调试器后端的错误消息:进程记录:当前体系结构不支持记录功能。流程记录:当前架构不支持记录功能。

听起来你正在遇到bug in Eclipse Neon

该错误已在Neon.1更新中修复。如果你download the latest version of Eclipse(写这篇文章的时候是Neon.3),它将包括修复。

相关问题