Subject: bug#12180: bug#12163: 24.1; Can not input anything or showing none output when debugging c/c++ application.

From: Eli Zaretskii <[email-masked]>
Date: Sun, 12 Aug 2012 20:56:38 +0300

> From: qq510371827 <[email-masked]>
> Date: Sun, 12 Aug 2012 09:32:14 +0800
> Cc: [email-masked], [email-masked]
> 
> 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.