From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cagney To: Jonathan Larmour Cc: insight@sourceware.cygnus.com, gdb@sourceware.cygnus.com Subject: Re: Insight remote output doesn't output to console window immediately Date: Thu, 13 Apr 2000 16:53:00 -0000 Message-id: <38F65D4D.8B390EFA@cygnus.com> References: <38F6404E.5959A4E0@redhat.co.uk> X-SW-Source: 2000-q2/msg00067.html Jonathan Larmour wrote: > > [ Sent to gdb and insight lists since ] > > I've found a problem in insight that is surprisingly old - I can't imagine > how it's lived so long actually: output from a remote target doesn't get > sent to the console window as it arrives. Instead it is buffered up. > > I believe the problem is because of Cagney's change to remote.c on July 2nd > 1999 which changed remote_console_output to operate on the gdb_stdtarg > stream rather than gdb_stdout. But, in main.c, gdb_stdtarg is #defined to > gdb_stderr. Which means that it matches the following code in > gdbtk/generic/gdbtk-hooks.c in gdbtk_fputs(): Yes, most likely :-( > if (result_ptr != NULL) > { > if (result_ptr->flags & GDBTK_TO_RESULT) > ... > else if (stream == gdb_stderr || result_ptr->flags & > GDBTK_ERROR_ONLY) > { > if (result_ptr->flags & GDBTK_ERROR_STARTED) > Tcl_AppendToObj (result_ptr->obj_ptr, (char *) ptr, -1); > else > { > Tcl_SetStringObj (result_ptr->obj_ptr, (char *) ptr, -1); > result_ptr->flags |= GDBTK_ERROR_STARTED; > } > > i.e. it is appended to result_ptr, rather than calling gdbtk_tcl_fputs to > display it in the console window. > > The only thing I'm wondering about is the fix. We could #define gdb_stdtarg > to gdb_stdout instead. Or we could add a hook with set_ui_file_flush() so > that the "gdb_flush (gdb_stdtarg);" at the end of remote_console_output() > would do the right thing. I simply don't know which is the more correct fix > before I implement it, although I suspect the latter. There is no need for another hook. Even the existing hooks (gdbtk_fputs() and gdbtk_flush()) can, in theory, deleted. To see how it should work, check the MI (mi/mi-main.c) - it maintains a separate stream. (BTW, sending the output gdb_stdout is wrong in CLI mode. gdb_stdout is paged. Having ``more ....'' appear part way through target output in CLI mode is only a little less frustrating than delayed output in GUI mode :-) As for a quick hack? My first guess is to, when the GUI is enabled (ie not CLI mode), re-route gdb_stdtarg to gdb_stdout. That might be suitable for the branch. However, the trunk, needs to start taking advantage of ``struct ui_out''. Andrew