From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23844 invoked by alias); 28 Jul 2010 19:49:30 -0000 Received: (qmail 23821 invoked by uid 22791); 28 Jul 2010 19:49:29 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 28 Jul 2010 19:49:19 +0000 Received: (qmail 11010 invoked from network); 28 Jul 2010 19:49:17 -0000 Received: from unknown (HELO orlando.localnet) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 28 Jul 2010 19:49:17 -0000 From: Pedro Alves To: gdb-patches@sourceware.org, Oleg Nesterov Subject: Re: [Oleg Nesterov] PATCH? gdb remote.c: readchar() should pop_target() if SERIAL_ERROR? Date: Wed, 28 Jul 2010 19:49:00 -0000 User-Agent: KMail/1.13.2 (Linux/2.6.32-24-generic; KDE/4.4.2; x86_64; ; ) Cc: Tom Tromey References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201007282049.14873.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-07/txt/msg00511.txt.bz2 Oleg Nesterov wrote: > (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. Talking in terms of Linux kernel internals, eh? Do note that you may actually be debugging with something not tcp, say, a bog dumb serial line, and an error may happen at any time, not just when quitting/killing the target (although quitting is more prone to these kinds of issues, since the 'k' packet doesn't actually require a reply). > 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. I guess the idea must have been that the user would just retry whatever failed. But of course, that's prone for messing things up too. I'm thinking this should be rare enough under normal conditions, and that it's not worth the hassle to do anything smarter here. We have no clue in what state the connection or the target was left in. We could claim that it's just better to reconnect and refresh the whole debug state. > --- 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: ... thus, I have no problems with this. Could you tweak the string to say something like: "Remote communication error. Target disconnected." so that user is informed we're no longer talking to the target?. Okay with that change. -- Pedro Alves