From: Oleg Nesterov <oleg@redhat.com>
To: Tom Tromey <tromey@redhat.com>,
Roland McGrath <roland@redhat.com>,
"Frank Ch. Eigler" <fche@redhat.com>
Cc: archer@sourceware.org
Subject: PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR?
Date: Fri, 02 Jul 2010 01:14:00 -0000 [thread overview]
Message-ID: <20100702011302.GA24599@redhat.com> (raw)
Hello.
I was trying to learn how gdb works with gdbserver and hit the bug.
The patch below seems to fix the problem for me but I am not sure
it is correct, I never looked into the (complex!) gdb sources before.
In short, sometimes gdb doing "target remote :tcp_port" refuses to
exit, putpkt_binary() complains that putpkt failed and longjmp()s
to the main loop. This happens sometimes if gdbserver dies.
(gdb) q
A debugging session is active.
Inferior 1 [Remote target] will be killed.
Quit anyway? (y or n) y
putpkt: write failed: Broken pipe.
(gdb)
Not sure my analysis is correct, but I think that readchar() needs
a fix. A read/recv from a socket doesn't necessarily returns EOF if
the peer has closed the socket. It can return sock->sk_err set by
the previous send if the peer dies and sets sk->sk_shutdown.
The patch merely adds pop_target(). The more sophisticates fix
should probably continue the reading, sock->sk_err was cleared and
the socket may have the packets which we could read.
Oleg.
--- gdb-7.1/gdb/remote.c~ 2010-03-07 15:39:53.000000000 +0100
+++ gdb-7.1/gdb/remote.c 2010-07-02 02:38:09.000000000 +0200
@@ -6364,6 +6364,7 @@ readchar (int timeout)
error (_("Remote connection closed"));
/* no return */
case SERIAL_ERROR:
+ pop_target ();
perror_with_name (_("Remote communication error"));
/* no return */
case SERIAL_TIMEOUT:
next reply other threads:[~2010-07-02 1:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-02 1:14 Oleg Nesterov [this message]
2010-07-02 1:29 ` Roland McGrath
2010-07-02 20:10 ` Tom Tromey
2010-07-30 21:37 ` Tom Tromey
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=20100702011302.GA24599@redhat.com \
--to=oleg@redhat.com \
--cc=archer@sourceware.org \
--cc=fche@redhat.com \
--cc=roland@redhat.com \
--cc=tromey@redhat.com \
/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).