1

I have been writing a C++ program that requires the user to enter some input through the console. The problem is that when I try to enter input while debugging, what I type into the console doesn't get put into the variable. Instead, an arcane string like "48-thread-select" (without quotes) gets stored. The number at the beginning is mostly random but the rest is always the same. A quick Google search revealed that this might be due to Eclipse buffering its console input. I followed the solution mentioned in this post here: Eclipse debugging with input from console to try and get Eclipse to open up a native DOS console while debugging. However, this didn't work. Now the program doesn't even launch. It just gets stuck at 91% saying "Launching program.exe (91%)" in the bottom right corner with a loading bar right next to it. Please tell me what I can do to make Eclipse launch the debugger with the native DOS console or preferably a way to turn off console input buffering altogether.

I am almost certain that the strange input is due to Eclipse buffering the console's input while debugging. I don't know what's causing the program to not launch and get stuck at 91% while trying to launch a native DOS console in debug mode though. I have tried storing the input in both std::string and C style strings to see if that would make a difference but the result was still the same. I also tried using getchar and std::getline when std::cin failed to produce the desired result but that didn't help either.

//the following applies to when I DON'T try to start the debugger in a
//native DOS console
std::cout << "Enter string: ";
std::string input;
std::cin >> input;//<-----------------------------------
std::cout << "The input was: " << input << std::endl;//|                                    
//when the instruction pointer is at this line, I type--
//my input into the console, press enter and then step over to the next line

When not trying to launch debugger in a native DOS console:
Expected result:

Enter a string: String
The input was: String

Actual result:

Enter a string: String
The input was: 69-thread-select

Error messages:
Under the variables view in the debugger, where the values of the elements of the member variable _M_local_buf should be, it displays the following errors:

Multiple errors reported.

1) Failed to execute MI command:
-var-create - * &((()._M_local_buf))
Error message from debugger back end:
-var-create: unable to create variable object

2) Failed to execute MI command:
-data-evaluate-expression (()._M_local_buf)
Error message from debugger back end:
A syntax error in expression, near `)._M_local_buf)'.

3) Failed to execute MI command:
-var-create - * &((()._M_local_buf))
Error message from debugger back end:
-var-create: unable to create variable object

4) Unable to create variable object

When trying to launch debugger in native DOS command line:
No errors are reported. It just says "Launching program.exe (91%)" with a loading bar and the program never starts no matter how long I wait for. I sat at my desk for a good 40 minutes today waiting for the program to launch but it never did.

anon12c
  • 11
  • 3

0 Answers0