I've attached a patch to what I think is the best fix for the PR. Before the patch, "gdb.write" wrote to gdb_stdout and exited. The completion was noted, and MI appended "^done". While the command had indeed finished, the output was still still lurking in gdb_stdout, and was being flushed out later. This lead to out-of-sequence ^done message and "gdb.write" output. I talked with Andre and Vlad on irc about possible fixes. We talked about the MI code flushing the buffer before appending ^done, but we are just not sure if this is correct. Given that many front ends presumably rely on the current MI expectation that each function flushes its own CLI output before exiting, the next best thing would be have gdb.write do just that. This however does not allow large CLI messages to be constructed (or cached I guess) in gdb_stdout with successive calls to "gdb.write" - each write is flushed at the end of each "gdb.write" call. The workaround for this is to construct your message in some other buffer then feed the entire buffer to gdb.write at the end. Anyway, here is the patch and test. What do you think? Cheers, Phil -- ChangeLog 2009-10-23 Phil Muldoon PR python/10826 * python/python.c (gdbpy_write): Flush output. Testsuite ChangeLog 2009-10-23 Phil Muldoon * gdb.python/py-mi.exp: Regression test for PR python/10826.