From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2485 invoked by alias); 21 Jan 2020 13:28:44 -0000 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 Received: (qmail 2469 invoked by uid 89); 21 Jan 2020 13:28:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=Alan X-HELO: mail-qv1-f68.google.com Received: from mail-qv1-f68.google.com (HELO mail-qv1-f68.google.com) (209.85.219.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2020 13:28:42 +0000 Received: by mail-qv1-f68.google.com with SMTP id t6so1410003qvs.5 for ; Tue, 21 Jan 2020 05:28:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=P08g6HUCpbZPibco3qLXvZDnJ1hmjXetDwsoNiWM+Iw=; b=F31VYn4wB5HnVOfAsbf1+vE9w4dczMVGAqaRWWE+LONf5/SxYcz/qcHUn9Zln7F5YS 5Vly/a8l2t2qPGuGuy1ksD8dj0W5WYPv4jDdxHkVuxgm1l+QtOgReDX0rAdRAFIH0sTO BmA1vUhjGIh10DLcdawErdjDzo/C9ggLLCQ4t2TIAcmPgHILfCsBpqVSaANjOISc1urd BHVjd81cJ2WY5RSmSISjdeHmPb7Zn4i3rLLSLaR5/wqBW0CGGzORSgs1RtVp93vhDItj y425Nu8gBsaQEq09Sd8e0wSOEqNiFRFOWT17LgbKamcYYmUEDI0rXENnXAggfvD86Qc3 NMBA== Return-Path: Received: from [192.168.0.185] ([179.177.237.129]) by smtp.gmail.com with ESMTPSA id w29sm19619074qtc.72.2020.01.21.05.28.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Jan 2020 05:28:39 -0800 (PST) Subject: Re: [PATCH,v2][AArch64] Fix step-over-syscall.exp failure To: Alan Hayward Cc: "gdb-patches\\@sourceware.org" , nd References: <20200113174239.7819-1-luis.machado@linaro.org> <20200113174239.7819-3-luis.machado@linaro.org> From: Luis Machado Message-ID: <09863520-b426-620b-3ab3-bbe5f784615c@linaro.org> Date: Tue, 21 Jan 2020 13:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2020-01/txt/msg00636.txt.bz2 Thanks. Pushed now. On 1/21/20 8:23 AM, Alan Hayward wrote: > This is ok too. > > Alan. > >> On 13 Jan 2020, at 17:42, Luis Machado wrote: >> >> New in v2: >> >> - Reverted to using pc_adjust as bool/offset and added more comments to explain >> how it is being used. >> >> -- >> >> In particular, this one: >> >> FAIL: gdb.base/step-over-syscall.exp: fork: displaced=on: check_pc_after_cross_syscall: single step over fork final pc >> >> When ptrace fork event reporting is enabled, GDB gets a PTRACE_EVENT_FORK >> event whenever the inferior executes the fork syscall. >> >> Then the logic is that GDB needs to step the inferior yet again in order to >> receive a predetermined SIGTRAP, but no execution takes place because the >> signal was already queued for delivery. That means the PC should stay the same. >> >> I noticed the aarch64 code is currently adjusting the PC in this situation, >> making the inferior skip an instruction without executing it. >> >> The following change checks if we did not execute the instruction >> (pc - to == 0), making proper adjustments for such case. >> >> Regression tested on aarch64-linux-gnu. >> >> gdb/ChangeLog: >> >> 2020-01-13 Luis Machado >> >> * aarch64-tdep.c (struct aarch64_displaced_step_closure ) >> : Adjust the documentation. >> (aarch64_displaced_step_fixup): Check if PC really moved before >> adjusting it. >> --- >> gdb/aarch64-tdep.c | 17 +++++++++++++---- >> 1 file changed, 13 insertions(+), 4 deletions(-) >> >> diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c >> index da41e22130..6a9d34dc67 100644 >> --- a/gdb/aarch64-tdep.c >> +++ b/gdb/aarch64-tdep.c >> @@ -2737,7 +2737,8 @@ struct aarch64_displaced_step_closure : public displaced_step_closure >> is being displaced stepping. */ >> int cond = 0; >> >> - /* PC adjustment offset after displaced stepping. */ >> + /* PC adjustment offset after displaced stepping. If 0, then we don't >> + write the PC back, assuming the PC is already the right address. */ >> int32_t pc_adjust = 0; >> }; >> >> @@ -3032,11 +3033,12 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch, >> { >> aarch64_displaced_step_closure *dsc = (aarch64_displaced_step_closure *) dsc_; >> >> + ULONGEST pc; >> + >> + regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc); >> + >> if (dsc->cond) >> { >> - ULONGEST pc; >> - >> - regcache_cooked_read_unsigned (regs, AARCH64_PC_REGNUM, &pc); >> if (pc - to == 8) >> { >> /* Condition is true. */ >> @@ -3052,6 +3054,13 @@ aarch64_displaced_step_fixup (struct gdbarch *gdbarch, >> >> if (dsc->pc_adjust != 0) >> { >> + /* Make sure the previous instruction was executed (that is, the PC >> + has changed). If the PC didn't change, then discard the adjustment >> + offset. Otherwise we may skip an instruction before its execution >> + took place. */ >> + if ((pc - to) == 0) >> + dsc->pc_adjust = 0; >> + >> if (debug_displaced) >> { >> debug_printf ("displaced: fixup: set PC to %s:%d\n", >> -- >> 2.17.1 >> >