public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "pedro at palves dot net" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug server/29796] New: gdbserver should imply --once if connected via stdio
Date: Wed, 16 Nov 2022 19:40:02 +0000	[thread overview]
Message-ID: <bug-29796-4717@http.sourceware.org/bugzilla/> (raw)

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

            Bug ID: 29796
           Summary: gdbserver should imply --once if connected via stdio
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: server
          Assignee: unassigned at sourceware dot org
          Reporter: pedro at palves dot net
  Target Milestone: ---

(gdb) target extended-remote | gdbserver --multi -
Remote debugging using | gdbserver --multi -
Remote debugging using stdio
(gdb) quit
* hang for 5 seconds *

You get the hang plus the PIPE_CLOSE_TIMEOUT timeout, because gdbserver hangs
while writing:

  "Remote side has terminated connection.  GDBserver will reopen the
connection.\n"

to stderr.  Like so:

(gdb) bt
#0  0x00007fa124ff9077 in __GI___libc_write (fd=2, buf=0x560d25e89158,
nbytes=78) at ../sysdeps/unix/sysv/linux/write.c:26
#1  0x00007fa124f79e8d in _IO_new_file_write (f=0x7fa1250d85c0
<_IO_2_1_stderr_>, data=0x560d25e89158, n=78) at fileops.c:1176
#2  0x00007fa124f7a7a8 in new_do_write (to_do=<optimized out>,
data=0x560d25e89158 "Remote side has terminated connection.  GDBserver will
reopen the connection.\n", fp=0x7fa1250d85c0 <_IO_2_1_stderr_>) at libioP.h:948
#3  _IO_new_file_xsputn (n=78, data=<optimized out>, f=<optimized out>) at
fileops.c:1255
#4  _IO_new_file_xsputn (f=0x7fa1250d85c0 <_IO_2_1_stderr_>, data=<optimized
out>, n=78) at fileops.c:1197
#5  0x00007fa124f6e3c1 in __GI__IO_fwrite (buf=0x560d25e89158, size=1,
count=78, fp=0x7fa1250d85c0 <_IO_2_1_stderr_>) at libioP.h:948
#6  0x0000560d25e081c4 in captured_main (argc=3, argv=0x7ffcfd97ceb8) at
../../src/gdbserver/server.cc:4145
#7  0x0000560d25e0840f in main (argc=3, argv=0x7ffcfd97ceb8) at
../../src/gdbserver/server.cc:4211


If you pass --once to gdbserver, then the hang disappears, since gdbserver
exits as soon as the connection closes:

(gdb) target extended-remote | gdbserver --once --multi -
Remote debugging using | ../gdbserver/gdbserver --once --multi -
Remote debugging using stdio
(gdb) q
$ # got back the shell prompt immediately.


I'm thinking that gdbserver should auto-imply --once when connected via stdio.

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

             reply	other threads:[~2022-11-16 19:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 19:40 pedro at palves dot net [this message]
2022-11-16 19:41 ` [Bug server/29796] " simon.marchi at polymtl dot ca
2023-12-29  0:29 ` tromey at sourceware dot org
2024-06-12 13:54 ` tromey at sourceware dot org
2024-06-12 14:37 ` mark at klomp dot org
2024-06-12 14:43 ` mark at klomp dot org
2024-08-26 14:45 ` cvs-commit at gcc dot gnu.org
2024-08-27 18:18 ` tromey at sourceware dot org
2024-11-16  7:24 ` brobecker at gnat dot com
2024-11-16 14:08 ` mark at klomp dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29796-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).