2012/8/13 Eli Zaretskii <address@hidden>
> From: qq510371827 <address@hidden>
> Date: Sun, 12 Aug 2012 09:32:14 +0800
> Cc: address@hidden, address@hidden
>I guess it's a matter of timing, then: there's a certain race
> Yes,I have tried that.Both GUI session and TTY session work very well.
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.