From mboxrd@z Thu Jan 1 00:00:00 1970 From: will.deacon@arm.com (Will Deacon) Date: Mon, 16 Oct 2017 16:30:56 +0100 Subject: A issue about ptrace/SINGLESTEP on arm64 In-Reply-To: <8ad32f6b-e04d-98f8-d944-7ec3582fbdf4@huawei.com> References: <8ad32f6b-e04d-98f8-d944-7ec3582fbdf4@huawei.com> Message-ID: <20171016153055.GD10500@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, Oct 16, 2017 at 12:27:17PM +0800, chengjian (D) wrote: > Hi > I write demo use ptrace/SINGLESTEP to count the number of instructions > executed by the process > The parent process fork+exec a child process, and trace(SINGLESTEP) it, > > It works fine under the x86_64 architecture but has an exception under > arm64. My guess is that you are getting stuck in an LDXR/STXR loop, which cannot be stepped. Can you jump the PC once the child appears to be "stuck"? IIRC, GDB has special heuristics to step through LDXR/STXR critical sections. Will From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753907AbdJPPay (ORCPT ); Mon, 16 Oct 2017 11:30:54 -0400 Received: from foss.arm.com ([217.140.101.70]:58656 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753659AbdJPPax (ORCPT ); Mon, 16 Oct 2017 11:30:53 -0400 Date: Mon, 16 Oct 2017 16:30:56 +0100 From: Will Deacon To: "chengjian (D)" Cc: catalin.marinas@arm.com, oleg@redhat.com, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "Xiexiuqi (Xie XiuQi)" , Li Bin Subject: Re: A issue about ptrace/SINGLESTEP on arm64 Message-ID: <20171016153055.GD10500@arm.com> References: <8ad32f6b-e04d-98f8-d944-7ec3582fbdf4@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ad32f6b-e04d-98f8-d944-7ec3582fbdf4@huawei.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 16, 2017 at 12:27:17PM +0800, chengjian (D) wrote: > Hi > I write demo use ptrace/SINGLESTEP to count the number of instructions > executed by the process > The parent process fork+exec a child process, and trace(SINGLESTEP) it, > > It works fine under the x86_64 architecture but has an exception under > arm64. My guess is that you are getting stuck in an LDXR/STXR loop, which cannot be stepped. Can you jump the PC once the child appears to be "stuck"? IIRC, GDB has special heuristics to step through LDXR/STXR critical sections. Will