|
|
|
|
| Re: console problem with printf [message #491263 is a reply to message #489392] |
Tue, 13 October 2009 20:47   |
No real name Messages: 6 Registered: October 2009 |
Junior Member |
|
|
the app, this is the code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("!!!Hello World!!!");
fflush(stdout);
return EXIT_SUCCESS;
}
and this is the error message while debugging step-to-step (after the printf, at the fflush):
!!!Hello World!!!540*stopped,reason="end-stepping-range",thread-id= "1",frame={addr="0x00401336",func="main",args=[],file="../src/test.c ",line="7"}
|
|
|
| Re: console problem with printf [message #491312 is a reply to message #491263] |
Wed, 14 October 2009 06:32   |
Axel Mueller Messages: 1973 Registered: July 2009 |
Senior Member |
|
|
| S.raffaele.mad.scientist. wrote on Tue, 13 October 2009 16:47 | the app, this is the code:
#include <stdio.h>
#include <stdlib.h>
int main(void) {
printf("!!!Hello World!!!");
fflush(stdout);
return EXIT_SUCCESS;
}
and this is the error message while debugging step-to-step (after the printf, at the fflush):
!!!Hello World!!!540*stopped,reason="end-stepping-range",thread-id= "1",frame={addr="0x00401336",func="main",args=[],file="../src/test.c ",line="7"}
|
What platform, compiler and debugger are you using? I built and debugged your example on Linux and did not encounter any problems.
Axel
Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
|
|
|
| Re: console problem with printf [message #491452 is a reply to message #491312] |
Wed, 14 October 2009 15:58   |
No real name Messages: 6 Registered: October 2009 |
Junior Member |
|
|
i'm running windows vista x32, MinGW (gcc) as compiler with GDB (from MinGW package)
Edit, check this out:
| Quote: | C:\Users\x>gcc -v
Reading specs from C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/specs
Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc --with-gnu-ld --wi
th-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --dis
able-nls --enable-languages=c,c++,f77,ada,objc,java --disable-win32-registry --d
isable-shared --enable-sjlj-exceptions --enable-libgcj --disable-java-awt --with
out-x --enable-java-gc=boehm --disable-libgcj-debug --enable-interpreter --enabl
e-hash-synchronization --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.5 (mingw-vista special r3)
C:\Users\x>gdb -v
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
|
[Updated on: Wed, 14 October 2009 19:18] Report message to a moderator
|
|
|
|
| Re: console problem with printf [message #491746 is a reply to message #491574] |
Thu, 15 October 2009 16:08   |
No real name Messages: 6 Registered: October 2009 |
Junior Member |
|
|
Ok, i will try what you suggested, btw MInGW stable version runs those versions of gcc, gdb. Thank you for the link you posted
EDIT: didn't work... 
| Quote: | C:\>gcc -v
Using built-in specs.
Target: mingw32
Configured with: ../../gcc-4.4.1/configure --prefix=/mingw --build=mingw32 --ena
ble-languages=c,ada,c++,fortran,objc,obj-c++ --disable-nls --disable-win32-regis
try --enable-libgomp --enable-cxx-flags='-fno-function-sections -fno-data-sectio
ns' --disable-werror --enable-threads --disable-symvers --enable-version-specifi
c-runtime-libs --enable-fully-dynamic-string --with-pkgversion='TDM-2 mingw32' -
-enable-sjlj-exceptions --with-bugurl=http://www.tdragon.net/recentgcc/bugs.php
Thread model: win32
gcc version 4.4.1 (TDM-2 mingw32)
C:\>gdb -v
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-pc-mingw32".
|
[Updated on: Thu, 15 October 2009 16:28] Report message to a moderator
|
|
|
| Re: console problem with printf [message #491833 is a reply to message #491746] |
Fri, 16 October 2009 06:23   |
Axel Mueller Messages: 1973 Registered: July 2009 |
Senior Member |
|
|
| Quote: | and this is the error message while debugging step-to-step (after the printf, at the fflush):
!!!Hello World!!!540*stopped,reason="end-stepping-range",thread-id= "1",frame={addr="0x00401336",func="main",args=[],file="../src/test.c ",line="7"}
|
OK, I could reproduce it. The message part after "Hello World" comes from the debugger. You get it if you set "Verbose console mode" in the debug launch configuration (this is not the default). However, the message does not indicate an error! It just means that the debugger stopped (or better suspended) the application because stepping is used (just google the term "stopped,reason=end-stepping-range" and you will find some info about it). You will get this message for every single step.
The only weird behavior (or bug?) I see, is that you get the gdb message in the console window of you application. The gdb messages should all go to a separate console window.
Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
|
|
|
|
|
| Re: console problem with printf [message #525029 is a reply to message #497012] |
Mon, 05 April 2010 13:22   |
JAN LIND Messages: 1 Registered: April 2010 |
Junior Member |
|
|
I have the same problem and it must come from the Eclipse environment. When running gdb from a command line, everything works fine, but when I run exactly the same version of gdb from Eclipse it hangs in fflush for stdout or fgets for stdin. I think it is obvious that Eclipse has problems with stdio in a Windows environment. My environment is
Windows XP SP3
minGW 5.1.6
gdb 6.6 (also tried 6.8 and 7.0, but the same problem)
[Updated on: Mon, 05 April 2010 19:29] Report message to a moderator
|
|
|
| Re: console problem with printf [message #528047 is a reply to message #525029] |
Mon, 19 April 2010 06:26  |
Axel Mueller Messages: 1973 Registered: July 2009 |
Senior Member |
|
|
The Eclipse console has buffering problems on Windows. Basically, it doesn't flush the streams when a newline is received. (Unlike a normal windows console window)
Either, you have to add fflush calls when needed or add the following lines in the start of the main function:
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stderr, NULL, _IONBF, 0);
Before you ask
- search this forum
- see the FAQ http://wiki.eclipse.org/CDT/User/FAQ
- google
|
|
|
Powered by
FUDForum. Page generated in 0.01913 seconds