* PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR?
@ 2010-07-02 1:14 Oleg Nesterov
2010-07-02 1:29 ` Roland McGrath
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Oleg Nesterov @ 2010-07-02 1:14 UTC (permalink / raw)
To: Tom Tromey, Roland McGrath, Frank Ch. Eigler; +Cc: archer
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:
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR?
2010-07-02 1:14 PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR? Oleg Nesterov
@ 2010-07-02 1:29 ` Roland McGrath
2010-07-02 20:10 ` Tom Tromey
2010-07-30 21:37 ` Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Roland McGrath @ 2010-07-02 1:29 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Tom Tromey, Frank Ch. Eigler, archer
I don't know that part of the code at all well either. But your fix looks
clearly correct. Both code paths leave in the same way (perror_with_name
is a wrapper around error), so their cleanup calls should match.
Thanks,
Roland
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR?
2010-07-02 1:14 PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR? Oleg Nesterov
2010-07-02 1:29 ` Roland McGrath
@ 2010-07-02 20:10 ` Tom Tromey
2010-07-30 21:37 ` Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2010-07-02 20:10 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Roland McGrath, Frank Ch. Eigler, archer
>>>>> "Oleg" == Oleg Nesterov <oleg@redhat.com> writes:
Oleg> I was trying to learn how gdb works with gdbserver and hit the bug.
Oleg> The patch below seems to fix the problem for me but I am not sure
Oleg> it is correct, I never looked into the (complex!) gdb sources before.
It seems reasonable to me, too. However, I don't know this part of gdb
very well.
I suggest re-sending your email to gdb-patches@sourceware.org. Some of
the maintainers there are very familiar with remote.c and friends.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR?
2010-07-02 1:14 PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR? Oleg Nesterov
2010-07-02 1:29 ` Roland McGrath
2010-07-02 20:10 ` Tom Tromey
@ 2010-07-30 21:37 ` Tom Tromey
2 siblings, 0 replies; 4+ messages in thread
From: Tom Tromey @ 2010-07-30 21:37 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Roland McGrath, Frank Ch. Eigler, archer
>>>>> "Oleg" == Oleg Nesterov <oleg@redhat.com> writes:
Oleg> The patch merely adds pop_target(). The more sophisticates fix
Oleg> should probably continue the reading, sock->sk_err was cleared and
Oleg> the socket may have the packets which we could read.
Just for closure on this, I put your patch in upstream.
It will be in gdb 7.2.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-07-30 21:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-02 1:14 PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR? Oleg Nesterov
2010-07-02 1:29 ` Roland McGrath
2010-07-02 20:10 ` Tom Tromey
2010-07-30 21:37 ` Tom Tromey
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).