Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Question about when stdout is flushed in gdb/mi mode
@ 2008-02-19 16:39 Gordon Prieur
  2008-02-19 17:52 ` Dave Korn
  2008-02-19 18:20 ` Daniel Jacobowitz
  0 siblings, 2 replies; 3+ messages in thread
From: Gordon Prieur @ 2008-02-19 16:39 UTC (permalink / raw)
  To: gdb

Hi,

    If I do several printf command before a breakpoint in normal
command line gdb, the stdout gets flushed prior to showing the stop
message in gdb. If I do the same thing in mi mode from a tty, I get
the same results. But if I do this from NetBeans (where gdb isn't
running in a tty), the output doesn't get flushed and hence doesn't
get shown before the stop.

    Looking at the gdb options, I don't see anyway of forcing a
flush of stdout. Since stdout isn't a variable and libc is typically
optimized without debug information, neither "fflush(stdout)" nor
"fflush(&__iob[1])" work. Is there anyway to force gdb to flush
stdout when it stops?

Thanks,
Gordon


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Question about when stdout is flushed in gdb/mi mode
  2008-02-19 16:39 Question about when stdout is flushed in gdb/mi mode Gordon Prieur
@ 2008-02-19 17:52 ` Dave Korn
  2008-02-19 18:20 ` Daniel Jacobowitz
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Korn @ 2008-02-19 17:52 UTC (permalink / raw)
  To: 'Gordon Prieur', gdb

On 19 February 2008 16:32, Gordon Prieur wrote:

>     Looking at the gdb options, I don't see anyway of forcing a
> flush of stdout. Since stdout isn't a variable and libc is typically
> optimized without debug information, neither "fflush(stdout)" nor
> "fflush(&__iob[1])" work. Is there anyway to force gdb to flush
> stdout when it stops?

  You could always rely on the default behaviour of "fflush (NULL)", if you
don't mind other descriptors getting flushed too.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Question about when stdout is flushed in gdb/mi mode
  2008-02-19 16:39 Question about when stdout is flushed in gdb/mi mode Gordon Prieur
  2008-02-19 17:52 ` Dave Korn
@ 2008-02-19 18:20 ` Daniel Jacobowitz
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-02-19 18:20 UTC (permalink / raw)
  To: Gordon Prieur; +Cc: gdb

On Tue, Feb 19, 2008 at 08:32:16AM -0800, Gordon Prieur wrote:
> Hi,
>
>    If I do several printf command before a breakpoint in normal
> command line gdb, the stdout gets flushed prior to showing the stop
> message in gdb. If I do the same thing in mi mode from a tty, I get
> the same results. But if I do this from NetBeans (where gdb isn't
> running in a tty), the output doesn't get flushed and hence doesn't
> get shown before the stop.

Yes.  By default, stdout is line buffered in TTYs and block buffered
otherwise.  On pipes, or Cygwin terminals with a mingw32 GDB (where
isatty returns false), stdout ends up block buffered.  This applies to
both GDB's stdout and the program being debugged.

GDB never, ever flushes the stdout of the program being debugged.
That would be a real pain if it affected anything you were debugging,
because the buffering is done in the C library, not in the kernel.

You can run the program being debugged in a new TTY, for instance with
"set tty".

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-02-19 18:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-19 16:39 Question about when stdout is flushed in gdb/mi mode Gordon Prieur
2008-02-19 17:52 ` Dave Korn
2008-02-19 18:20 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox