public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug breakpoints/18275] New: dprintf (call style) could automatically flush the standard output
@ 2015-04-17 18:29 malaperle at gmail dot com
  2015-04-17 18:30 ` [Bug breakpoints/18275] " malaperle at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: malaperle at gmail dot com @ 2015-04-17 18:29 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=18275

            Bug ID: 18275
           Summary: dprintf (call style) could automatically flush the
                    standard output
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: malaperle at gmail dot com

Created attachment 8251
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8251&action=edit
Sample source file

I am attaching to a program that appears to have output buffering on (setvbuf).
If I use dprintf (call style) to add some debug print-outs, I do not see them
until I call fflush. To improve the out-of-the-box experience, I think dprintf
should flush the stdout. I am not sure whether or not there should be an option
to control this but by default I think it should flush.

Here's an example to illustrate the problem

testDprintf.c:
#include <unistd.h>
#include <stdio.h>

int main() {
    setvbuf(stdout, NULL, _IOFBF, BUFSIZ);
    while (1) {
        sleep(5);
    }
    return 0;
}


gdb ./testDprintf
set dprintf-style call
dprintf testDprintf.c:7, "hello printf\n"
r

Wait a few seconds. You won't see output (unless you wait for a really long
time!). If you interrupt (Ctrl-C) then do a: call fflush(0)
Then you see the printfs appear.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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

end of thread, other threads:[~2015-05-01 21:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-17 18:29 [Bug breakpoints/18275] New: dprintf (call style) could automatically flush the standard output malaperle at gmail dot com
2015-04-17 18:30 ` [Bug breakpoints/18275] " malaperle at gmail dot com
2015-04-17 18:31 ` malaperle at gmail dot com
2015-04-17 18:31 ` malaperle at gmail dot com
2015-04-29  2:17 ` simon.marchi at polymtl dot ca
2015-04-29  2:24 ` simon.marchi at polymtl dot ca
2015-05-01 20:20 ` malaperle at gmail dot com
2015-05-01 21:22 ` malaperle at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).