From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32199 invoked by alias); 19 Feb 2008 18:03:00 -0000 Received: (qmail 32190 invoked by uid 22791); 19 Feb 2008 18:02:59 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 19 Feb 2008 18:02:37 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 00715983A9; Tue, 19 Feb 2008 18:02:35 +0000 (GMT) Received: from caradoc.them.org (22.svnf5.xdsl.nauticom.net [209.195.183.55]) by nan.false.org (Postfix) with ESMTP id BA7AC9802B; Tue, 19 Feb 2008 18:02:34 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1JRWnZ-0001GM-UZ; Tue, 19 Feb 2008 13:02:33 -0500 Date: Tue, 19 Feb 2008 18:20:00 -0000 From: Daniel Jacobowitz To: Gordon Prieur Cc: gdb@sourceware.org Subject: Re: Question about when stdout is flushed in gdb/mi mode Message-ID: <20080219180233.GA4631@caradoc.them.org> Mail-Followup-To: Gordon Prieur , gdb@sourceware.org References: <47BB0490.6070703@sun.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47BB0490.6070703@sun.com> User-Agent: Mutt/1.5.17 (2007-12-11) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-02/txt/msg00132.txt.bz2 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