From patchwork Fri Jan 25 10:48:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Hayward X-Patchwork-Id: 31209 Received: (qmail 52596 invoked by alias); 25 Jan 2019 10:48:58 -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 37988 invoked by uid 89); 25 Jan 2019 10:48:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR03-VE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr50051.outbound.protection.outlook.com (HELO EUR03-VE1-obe.outbound.protection.outlook.com) (40.107.5.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 Jan 2019 10:48:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WE2O+KqXn3Q/XeYHAABSgbwmG9lIuv7upkP/jflZ4bc=; b=ASFor3UUQaGiCJ8NKC5/1kAxj/dx/rncFh93AFQ1hHpXXhFa6rdN0vKf+hrGDCQMJ6gR7lbfr/m87/R+LYfOggO2t5OavFED/1P4PMOPn6qXA+f19aS8lXlh4DbMxqp8BJcdO033mnBdPcdGvCsAjAlAF0B2ZqbSVJmJRjUc6s0= Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com (10.172.227.22) by DB6PR0802MB2408.eurprd08.prod.outlook.com (10.172.250.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1558.18; Fri, 25 Jan 2019 10:48:39 +0000 Received: from DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::acd7:a958:2aaa:562e]) by DB6PR0802MB2133.eurprd08.prod.outlook.com ([fe80::acd7:a958:2aaa:562e%5]) with mapi id 15.20.1558.021; Fri, 25 Jan 2019 10:48:38 +0000 From: Alan Hayward To: "gdb-patches@sourceware.org" CC: nd , Alan Hayward Subject: [PATCH] gdbserver: When attaching, add process before lwps Date: Fri, 25 Jan 2019 10:48:38 +0000 Message-ID: <20190125104834.2595-1-alan.hayward@arm.com> authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alan.Hayward@arm.com; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 MIME-Version: 1.0 X-IsSubscribed: yes The recent BP/WP changes for AArch64 swapping the order in add_lwp() so that the process was added before the lwp. This was due to the lwp creation requiring the process data. This also needs changing in linux_attach(). Fixes gdb.server/ext-attach.exp on Aarch64. (This regression was hidden due to the racy nature of the gdb.server tests - now they are no longer racy it'll be easier to spot. Also checked X86). gdb/gdbserver/ChangeLog: 2019-01-25 Alan Hayward * linux-low.c (linux_attach): Add process before lwp. --- gdb/gdbserver/linux-low.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index 17cce24d76..1ab2cfb1eb 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -1188,6 +1188,8 @@ linux_attach (unsigned long pid) ptid_t ptid = ptid_t (pid, pid, 0); int err; + proc = linux_add_process (pid, 1); + /* Attach to PID. We will check for other threads soon. */ err = linux_attach_lwp (ptid); @@ -1198,8 +1200,6 @@ linux_attach (unsigned long pid) error ("Cannot attach to process %ld: %s", pid, reason.c_str ()); } - proc = linux_add_process (pid, 1); - /* Don't ignore the initial SIGSTOP if we just attached to this process. It will be collected by wait shortly. */ initial_thread = find_thread_ptid (ptid_t (pid, pid, 0));