' set new-console on ' command works for me. I have tried eclipse cdt  and it also has the same problem as emacs 24.1 on windows with mingw. Strangely, why emacs 23.4 just works?
2012/8/13 Eli Zaretskii <eliz@gnu.org>
> From: qq510371827 <qq510371827@gmail.com>
> Date: Sun, 12 Aug 2012 09:32:14 +0800
> Cc: 12180@debbugs.gnu.org, bug-gnu-emacs@gnu.org
>
> Yes,I have tried that.Both GUI session and TTY session work very well.

I guess it's a matter of timing, then: there's a certain race
condition between Emacs that crams commands into GDB and the debuggee
that reads from stdin.  If the latter comes after Emacs already sent
all the commands, then the program will work correctly.  But that's a
guess; I hope someone knowledgeable about GUD, comint, and gdb-mi will
chime in.  Nick? somebody?

Anyway, I found a work-around for this problem.  After entering GDB,
and before running your program, type this command at GDB prompt:

  (gdb) set new-console on

This will cause GDB to create a separate console window for the input
and output of your program, when you run it, and you can then
communicate with your program without mixing its I/O with that of GDB.
Just be sure to put a breakpoint at the 'exit' call or at the last
line of your 'main' function, if you want to look at the program
output.  If you don't do that, the console will be automatically
closed when your program exits.