This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: printfs output in wrong order in MI


> From: Vladimir Prus <ghost@cs.msu.su>
> Date: Thu, 13 Apr 2006 12:01:57 +0400
> Cc: gdb@sources.redhat.com
> 
> > > (that is, adding "\n"), fixes the problem. Still looks like a bug to me,
> > > though.
> >
> > I think it's expected behavior: printf uses buffered output, 
> 
> Where in documentation is it stated that 'printf' uses buffered output?

I'll welcome patches to document that, TIA.

> Isn't it possible to auto-flush the buffer at the end of "-interpreter-exec 
> console" execution it's possible to flush the buffers?

It is usually a performance tradeoff: GDB has no idea whether a single
printf command is all you will want to print, or a part of a block of
commands that your front end feeds one after the other.  In the latter
case, flushing the buffers will be a performance hit.

The current code assumes that \n marks the end of the values you want
to see output, so line buffering generally does The Right Thing
(because, at least in interactive CLI usage, no one in their right
mind will want to print strings unterminated by a newline: it would
cause the next GDB prompt to not be the first thing on the line).

> I think it's reasonable to expect that *all* output of command
> wrapped in "-interpreter-exec console" would appears before the
> "^done" marker.

Is it?  I wouldn't know; I'll let other front-end gurus to comment on
that.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]