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

* [Bug breakpoints/18275] dprintf (call style) could automatically flush the standard output
  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 ` malaperle at gmail dot com
  2015-04-17 18:31 ` malaperle at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: malaperle at gmail dot com @ 2015-04-17 18:30 UTC (permalink / raw)
  To: gdb-prs

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

Marc-Andre Laperle <malaperle at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |antoine.tremblay at ericsson dot c
                   |                            |om

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


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

* [Bug breakpoints/18275] dprintf (call style) could automatically flush the standard output
  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
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: malaperle at gmail dot com @ 2015-04-17 18:31 UTC (permalink / raw)
  To: gdb-prs

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

Marc-Andre Laperle <malaperle at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simon.marchi at ericsson dot com

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


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

* [Bug breakpoints/18275] dprintf (call style) could automatically flush the standard output
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: malaperle at gmail dot com @ 2015-04-17 18:31 UTC (permalink / raw)
  To: gdb-prs

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

Marc-Andre Laperle <malaperle at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marc.khouzam at ericsson dot com

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


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

* [Bug breakpoints/18275] dprintf (call style) could automatically flush the standard output
  2015-04-17 18:29 [Bug breakpoints/18275] New: dprintf (call style) could automatically flush the standard output malaperle at gmail dot com
                   ` (2 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2015-04-29  2:17 UTC (permalink / raw)
  To: gdb-prs

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

Simon Marchi <simon.marchi at polymtl dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simon.marchi at polymtl dot ca

--- Comment #1 from Simon Marchi <simon.marchi at polymtl dot ca> ---
Created attachment 8286
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8286&action=edit
Quick fix

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


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

* [Bug breakpoints/18275] dprintf (call style) could automatically flush the standard output
  2015-04-17 18:29 [Bug breakpoints/18275] New: dprintf (call style) could automatically flush the standard output malaperle at gmail dot com
                   ` (3 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: simon.marchi at polymtl dot ca @ 2015-04-29  2:24 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Simon Marchi <simon.marchi at polymtl dot ca> ---
Hi Marc-André,

Can you check if this small fix does the job for you? If it works, it would
need still need more work to make it parameterizable (if you want to flush or
not). Also, since you can customize what function dprintf calls, you might want
to flush another file than stdout, so maybe it should be configurable.

It could be similar to how "set dprintf-channel" works. It would be "set
dprintf-flush". If unset (the default), it wouldn't do anything. If it is set,
it would be evaluated as an expression and that value would be passed to
fflush. In your case, you would do "set dprintf-flush stdout".

What do you think?

Simon

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-17980-listarch-gdb-prs=sources.redhat.com@sourceware.org Wed Apr 29 02:25:18 2015
Return-Path: <gdb-prs-return-17980-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 117114 invoked by alias); 29 Apr 2015 02:25:18 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 117089 invoked by uid 48); 29 Apr 2015 02:25:18 -0000
From: "simon.marchi at polymtl dot ca" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug breakpoints/18275] dprintf (call style) could automatically
 flush the standard output
Date: Wed, 29 Apr 2015 02:25:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: breakpoints
X-Bugzilla-Version: HEAD
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: simon.marchi at polymtl dot ca
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-18275-4717-Lc3jVr4z6Y@http.sourceware.org/bugzilla/>
In-Reply-To: <bug-18275-4717@http.sourceware.org/bugzilla/>
References: <bug-18275-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00174.txt.bz2
Content-length: 327

https://sourceware.org/bugzilla/show_bug.cgi?id\x18275

--- Comment #3 from Simon Marchi <simon.marchi at polymtl dot ca> ---
Actually, since the default values print to stdout, we might as well flush
stdout by default, it would be more convenient.

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


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

* [Bug breakpoints/18275] dprintf (call style) could automatically flush the standard output
  2015-04-17 18:29 [Bug breakpoints/18275] New: dprintf (call style) could automatically flush the standard output malaperle at gmail dot com
                   ` (4 preceding siblings ...)
  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
  6 siblings, 0 replies; 8+ messages in thread
From: malaperle at gmail dot com @ 2015-05-01 20:20 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Marc-Andre Laperle <malaperle at gmail dot com> ---
(In reply to Simon Marchi from comment #2)
> Hi Marc-André,
> 
> Can you check if this small fix does the job for you?

I tried it and I got a crash, strangely:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fd722fc2fdd, pid=15355, tid=140561991497472
#
# JRE version: OpenJDK Runtime Environment (7.0_79-b14) (build 1.7.0_79-b14)
# Java VM: OpenJDK 64-Bit Server VM (24.79-b02 mixed mode linux-amd64
compressed oops)
# Derivative: IcedTea 2.5.5
# Distribution: Ubuntu 14.10, package 7u79-2.5.5-0ubuntu0.14.10.2
# Problematic frame:
# C  [libc.so.6+0x6dfdd]  fflush+0xd
#
# Core dump written. Default location: /home/emalape/Documents/dev/eclipse/core
or core.15355
#
# An error report file with more information is saved as:
# /home/emalape/Documents/dev/eclipse/hs_err_pid15355.log

(gdb) bt
#0  0x00007f2033ab6e37 in __GI_raise (sig=sig@entry=6) at
../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007f2033ab8528 in __GI_abort () at abort.c:89
#2  0x00007f203137d8b9 in os::abort (dump_core=<optimized out>)
    at
/build/buildd/openjdk-7-7u79-2.5.5/build/openjdk/hotspot/src/os/linux/vm/os_linux.cpp:1626
#3  0x00007f203150e0ef in VMError::report_and_die
(this=this@entry=0x7f203444fd90)
    at
/build/buildd/openjdk-7-7u79-2.5.5/build/openjdk/hotspot/src/share/vm/utilities/vmError.cpp:1054
#4  0x00007f2031386a66 in JVM_handle_linux_signal (sig=11, info=0x7f203444fff0,
ucVoid=0x7f203444fec0, 
    abort_if_unrecognized=<optimized out>)
    at
/build/buildd/openjdk-7-7u79-2.5.5/build/openjdk/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp:531
#5  <signal handler called>
#6  __GI__IO_fflush (fp=0x33e3e400) at iofflush.c:40
#7  0x00007f203445048f in ?? ()
#8  0x0000000000000000 in ?? ()



> It could be similar to how "set dprintf-channel" works. It would be "set
> dprintf-flush". If unset (the default), it wouldn't do anything. If it is
> set, it would be evaluated as an expression and that value would be passed
> to fflush. In your case, you would do "set dprintf-flush stdout".
> 
> What do you think?

I like this proposal.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
>From gdb-prs-return-18000-listarch-gdb-prs=sources.redhat.com@sourceware.org Fri May 01 20:25:12 2015
Return-Path: <gdb-prs-return-18000-listarch-gdb-prs=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb-prs@sources.redhat.com
Received: (qmail 94417 invoked by alias); 1 May 2015 20:25:12 -0000
Mailing-List: contact gdb-prs-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb-prs.sourceware.org>
List-Subscribe: <mailto:gdb-prs-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb-prs/>
List-Post: <mailto:gdb-prs@sourceware.org>
List-Help: <mailto:gdb-prs-help@sourceware.org>, <http://sourceware.org/lists.html#faqs>
Sender: gdb-prs-owner@sourceware.org
Delivered-To: mailing list gdb-prs@sourceware.org
Received: (qmail 93708 invoked by uid 48); 1 May 2015 20:25:11 -0000
From: "MatthewS.Grochowalski at ge dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug server/18367] New: gdbserver doesn't work if parent blocks
 SIGCHLD
Date: Fri, 01 May 2015 20:25:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gdb
X-Bugzilla-Component: server
X-Bugzilla-Version: 7.9
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: MatthewS.Grochowalski at ge dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at sourceware dot org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status
 bug_severity priority component assigned_to reporter target_milestone
Message-ID: <bug-18367-4717@http.sourceware.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://sourceware.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-q2/txt/msg00194.txt.bz2
Content-length: 1455

https://sourceware.org/bugzilla/show_bug.cgi?id\x18367

            Bug ID: 18367
           Summary: gdbserver doesn't work if parent blocks SIGCHLD
           Product: gdb
           Version: 7.9
            Status: NEW
          Severity: normal
          Priority: P2
         Component: server
          Assignee: unassigned at sourceware dot org
          Reporter: MatthewS.Grochowalski at ge dot com
  Target Milestone: ---

Steps to reproduce (on Linux x86):
1. Launch gdbserver from a parent that has SIGCHLD blocked. For example,
replace SIGINT with SIGCHLD in the code in
http://stackoverflow.com/questions/4515274
2. Try to connect through a gdb client
3. GDB prints the following and remote debugging doesn't work:
Ignoring packet error, continuing...
warning: unrecognized item "timeout" in "qSupported" response
Ignoring packet error, continuing...
Ignoring packet error, continuing...
Bogus trace status reply from target: timeout

Running gdbserver with the "--debug" option produces the following output:
>>>> entering linux_wait_1
linux_wait_1: [Process 3252]
my_waitpid (-1, 0x40000001)
my_waitpid (-1, 0x80000001): status(bffff58c), -1
LWFE: waitpid(-1, ...) returned -1, No child processes
leader_pid252, leader_lp!=NULL=1, num_lwps=1, zombie=0
sigsuspend'ing

This was introduced some time after 7.3. Looks like it may be due to the fix
for PR 12702.

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


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

* [Bug breakpoints/18275] dprintf (call style) could automatically flush the standard output
  2015-04-17 18:29 [Bug breakpoints/18275] New: dprintf (call style) could automatically flush the standard output malaperle at gmail dot com
                   ` (5 preceding siblings ...)
  2015-05-01 20:20 ` malaperle at gmail dot com
@ 2015-05-01 21:22 ` malaperle at gmail dot com
  6 siblings, 0 replies; 8+ messages in thread
From: malaperle at gmail dot com @ 2015-05-01 21:22 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #5 from Marc-Andre Laperle <malaperle at gmail dot com> ---
it seems to be a problem when stdout is not found as a debug symbol by GDB.
This works:
call (void) fflush (*((void**)&stdout))

BTW, Simon figured this out, not me ;)

-- 
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).