When I issue a python based command 'xx' in mi mode I get output similar to the following: &"xx\n" >^done >~"the output" i.e. the ^done message comes before the actual script output. that's somewhat inconvenient if one wants to capture the script output as long as there is no clear 'end of transmission' marker. It would be nicer if the ^done message were sent only after the script output, or possibly even better, if the script output would be made proper part of the ^done message. The behaviour is reproducible with b6fd5e85924d71f28bb7e9d463e97bfd26a25f80 and has been around for a while, probably all the time.
I submitted a patch for what I thought would the solution here: http://sourceware.org/ml/archer/2009-q4/msg00023.html And Tom reviewed it here: http://sourceware.org/ml/archer/2009-q4/msg00033.html Tom quite rightly points out that commands are required to flush the buffer or emit a newline. And that this should be the same for Python scripts. I decided to write a hello world command and test if the output was sequenced correctly if there were multiple writes, and one flush: class HelloWorld (gdb.Command): """Greet the whole world.""" def __init__ (self): super (HelloWorld, self).__init__ ("hello-world", gdb.COMMAND_OBSCURE) def invoke (self, arg, from_tty): gdb.write("Hello, World!") gdb.write("Lovely weather!") gdb.write("What a nice day for a walk") gdb.flush() HelloWorld () output: (gdb) python execfile("/home/build/helloworld2.py") &"python execfile(\"/home/build/helloworld2.py\")\n" ^done (gdb) hello-world &"hello-world\n" ~"Hello, World!Lovely weather!What a nice day for a walk" ^done I also tested the case with just a new line at the end, and no flush: hello-world &"hello-world\n" ~"Hello, World!Lovely weather!What a nice day for a walk\n" ^done (gdb) So in both cases this works, and no patch is needed. So closing, happily with no patches needed!