Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Debugger problem with cout / cin
Debugger problem with cout / cin [message #652775] Sun, 06 February 2011 16:37 Go to next message
Carsten is currently offline Carsten
Messages: 2
Registered: February 2011
Junior Member
Hi everybody,

I am having problems debugging this code:
#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;

int main(int argc, char * argv[]) {
	setvbuf(stdout, NULL, _IONBF, 0);
	setvbuf(stderr, NULL, _IONBF, 0);

    cout << "======================\n";
    cout << "Press 'Return' to quit: ";
    cin.get();

    return 0;
}


I get this output in the console:
Press 'Return' to quit: *stopped,reason="end-stepping-range",frame={addr="0x0040144e",func="main",args=[{name="argc",value="1"},{name="argv",value="0x524438"}],file="..\getchTest.cpp",fullname="C:/Dokumente und Einstellungen/Normal/workspace/getchTest/.settings/..\getchTest.cpp",line="13"},thread-id="1",stopped-threads="all"

When I run the program normaly all is working as expected.

As you can see I already stumbled over the CDT FAQ (I put that setvbuff stuff in the code).

But that does not seem to help for debugging.

I am running Windows XP.
Eclipse:
Eclipse C/C++ Development Tools
Version: Helios Service Release 1
Build id: 20100917-0705
I installed MinGW via Wascana MinGW Tools and Base SDK 0.9.9.0a
which gives me:
GCC: 4.4.1
GDB: 7.1

I found a thread in this forum about some similar problem but no solution there either.

Can anybody help?

Thanks a lot,

Carsten
Re: Debugger problem with cout / cin [message #653285 is a reply to message #652775] Wed, 09 February 2011 08:39 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1949
Registered: July 2009
Senior Member
You should read this post http://www.eclipse.org/forums/index.php?t=msg&goto=23484 0&
and the bug report that is mentioned at the end https://bugs.eclipse.org/bugs/show_bug.cgi?id=231883

There are some workarounds for your problem.


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Debugger problem with cout / cin [message #653459 is a reply to message #652775] Wed, 09 February 2011 20:29 Go to previous messageGo to next message
Carsten is currently offline Carsten
Messages: 2
Registered: February 2011
Junior Member
Thank you for pointing me to this information.
I have read the posts but to be honest I did not understand it all.
I think it says I have to make the debugger work in a different way or different kind of mode.
But I can't find where to change the settings.
Re: Debugger problem with cout / cin [message #653617 is a reply to message #653459] Thu, 10 February 2011 12:43 Go to previous messageGo to next message
Axel Mueller is currently offline Axel Mueller
Messages: 1949
Registered: July 2009
Senior Member
Quote:
I have read the posts but to be honest I did not understand it all.
I think it says I have to make the debugger work in a different way or different kind of mode.

AFAIK, try to put the line
set new-console on
into your gdbinit file (see Debug Launch Configuration).


Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
Re: Debugger problem with cout / cin [message #1064440 is a reply to message #652775] Wed, 19 June 2013 09:30 Go to previous message
Nenad Bulatovic is currently offline Nenad Bulatovic
Messages: 3
Registered: June 2013
Junior Member
I had same problem every time I was using cin right after cout, and finally I resolved it with adding << endl; after cout

	bool isDone()
	{
		char c;
		cout << "Enter 'Y' if food is done:";
		cin >> c;
		return ((c == 'Y') || (c == 'y'));
	}


This was generating error such as:

*stopped,reason="end-stepping-range",frame=...



But this is working just fine:

	bool isDone()
	{
		char c;
		cout << "Enter 'Y' if food is done:" << endl;
		cin >> c;
		return ((c == 'Y') || (c == 'y'));
	}

[Updated on: Wed, 19 June 2013 09:37]

Report message to a moderator

Previous Topic:eclipse IDE complie Failed , ACE_MT_SYNCH could not be resolved
Next Topic:android/java/src/pcf: No such file or directory
Goto Forum:
  


Current Time: Tue Sep 02 21:36:48 GMT 2014

Powered by FUDForum. Page generated in 0.02064 seconds