List Info

Thread: Question about when stdout is flushed in gdb/mi mode




Question about when stdout is flushed in gdb/mi mode
country flaguser name
United States
2008-02-19 10:32:16
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


Re: Question about when stdout is flushed in gdb/mi mode
country flaguser name
United States
2008-02-19 12:02:33
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

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )