From patchwork Thu Mar 24 22:09:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 11506 Received: (qmail 81163 invoked by alias); 24 Mar 2016 22:09:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 81149 invoked by uid 89); 24 Mar 2016 22:09:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=sk:handle_ X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 24 Mar 2016 22:09:46 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 330322655 for ; Thu, 24 Mar 2016 22:09:45 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-22.ams2.redhat.com [10.36.116.22]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2OM9aFO027575 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 24 Mar 2016 18:09:39 -0400 Date: Thu, 24 Mar 2016 23:09:33 +0100 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org, Gary Benson Subject: [patch] Workaround gdbserver<7.7 for setfs [Re: [patch] Suggest newer gdbserver if it has no qXfer:exec-file:read] Message-ID: <20160324220933.GA27445@host1.jankratochvil.net> References: <20160319201842.GA16540@host1.jankratochvil.net> <56F13963.9040204@redhat.com> <20160322131604.GA24312@host1.jankratochvil.net> <56F14F1E.5010606@redhat.com> <20160323211547.GA17400@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160323211547.GA17400@host1.jankratochvil.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes On Wed, 23 Mar 2016 22:15:47 +0100, Jan Kratochvil wrote: > With current FSF GDB HEAD and old FSF gdbserver I expected I could do: > gdb -ex 'file target:/root/redhat/threadit' -ex 'target remote :1234' > (supplying that unsupported qXfer:exec-file:read by "file") > But that does not work because: > Sending packet: $vFile:setfs:0#bf...Packet received: OK > Packet vFile:setfs (hostio-setfs) is supported > ... > Sending packet: $vFile:setfs:104#24...Packet received: OK > "target:/root/redhat/threadit": could not open as an executable file: Invalid argument > > GDB documentation says: > The valid responses to Host I/O packets are: > An empty response indicates that this operation is not recognized. > > OT: I do not see why "empty response" is response "OK" but apparently it is. This "empty response" vs. "OK" was a bug in gdbserver < 7.7. It was fixed by: commit e7f0d979dd5cc4f8b658df892e93db69d6d660b7 Author: Yao Qi Date: Tue Dec 10 21:59:20 2013 +0800 Fix a bug in matching notifications. Message-ID: <1386684626-11415-1-git-send-email-yao@codesourcery.com> https://sourceware.org/ml/gdb-patches/2013-12/msg00373.html 2013-12-10 Yao Qi * notif.c (handle_notif_ack): Return 0 if no notification matches. But I would prefer to make gdb compatible with gdbserver-7.6.1. OK for check-in? Thanks, Jan gdb/ChangeLog 2016-03-24 Jan Kratochvil * remote.c (packet_ok): Add workaround for vFile:setfs. diff --git a/gdb/remote.c b/gdb/remote.c index af0a08a..be5cc09 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1311,7 +1311,14 @@ packet_ok (const char *buf, struct packet_config *config) internal_error (__FILE__, __LINE__, _("packet_ok: attempt to use a disabled packet")); - result = packet_check_result (buf); + if (strcmp (config->name, "vFile:setfs") == 0 && strcmp (buf, "OK") == 0) + { + /* Workaround gdbserver < 7.7 before its fix from 2013-12-11. */ + result = PACKET_UNKNOWN; + } + else + result = packet_check_result (buf); + switch (result) { case PACKET_OK: