From patchwork Tue Jul 10 19:06:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 28298 Received: (qmail 49540 invoked by alias); 10 Jul 2018 19:06:43 -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 49443 invoked by uid 89); 10 Jul 2018 19:06:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx3-rdu2.redhat.com (HELO mx1.redhat.com) (66.187.233.73) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Jul 2018 19:06:41 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00D7D401DECC for ; Tue, 10 Jul 2018 19:06:39 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id A61B82026D6B for ; Tue, 10 Jul 2018 19:06:35 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/2] GDB: Workaround D; PID handling bug in older GDBservers (PR gdb/23377) Date: Tue, 10 Jul 2018 20:06:23 +0100 Message-Id: <20180710190623.13540-3-palves@redhat.com> In-Reply-To: <20180710190623.13540-1-palves@redhat.com> References: <20180710190623.13540-1-palves@redhat.com> This commit adds a GDB workaround for the GDBserver bug exposed by commit f2ffa92bbce9 ("gdb: Eliminate the 'stop_pc' global"), so that newer GDBs can continue working with older GDBservers. gdb/ChangeLog: yyyy-mm-dd Pedro Alves PR gdb/23377 * remote.c (remote_target::remote_detach_pid): Call set_current_process. --- gdb/remote.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gdb/remote.c b/gdb/remote.c index 297c198ed6..a81d67e5ed 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5661,6 +5661,14 @@ remote_target::remote_detach_pid (int pid) { struct remote_state *rs = get_remote_state (); + /* This should not be necessary, but the handling for D;PID in + GDBserver versions prior to 8.2 incorrectly assumes that the + selected process points to the same process we're detaching, + leading to misbehavior (and possibly GDBserver crashing) when it + does not. Since it's easy and cheap, work around it by forcing + GDBserver to select GDB's current process. */ + set_general_process (); + if (remote_multi_process_p (rs)) xsnprintf (rs->buf, get_remote_packet_size (), "D;%x", pid); else