From patchwork Thu Jul 12 16:41:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 28340 Received: (qmail 78289 invoked by alias); 12 Jul 2018 16:41:18 -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 78267 invoked by uid 89); 12 Jul 2018 16:41:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jul 2018 16:41:16 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6CGeTIk050957 for ; Thu, 12 Jul 2018 12:41:15 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k69psjmg4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 12 Jul 2018 12:41:14 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Jul 2018 17:41:13 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 12 Jul 2018 17:41:11 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6CGfA9K42729626 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Jul 2018 16:41:10 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 827E452050; Thu, 12 Jul 2018 19:41:31 +0100 (BST) Received: from oc1027705133.ibm.com (unknown [9.152.222.21]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 623F352052; Thu, 12 Jul 2018 19:41:31 +0100 (BST) From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH] S390: Fix displaced stepping of "basr r,0" Date: Thu, 12 Jul 2018 18:41:03 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 x-cbid: 18071216-0016-0000-0000-000001E628DF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071216-0017-0000-0000-0000323ABE68 Message-Id: The BASR instruction behaves differently depending on whether the second operand is a number from 1 to 15, or zero. In the former case BASR jumps to the address contained in the general register of that number, but in the latter case no jump is performed. GDB's displaced-stepping logic does not distinguish these cases, although it should. This is fixed. In the case where no jump is performed the PC is adjusted to point back after the original instruction. Otherwise the PC is left alone. gdb/ChangeLog: * s390-tdep.c (s390_displaced_step_fixup): Adjust PC for a non-branching basr. --- gdb/s390-tdep.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 77e64af..e962824 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -492,6 +492,9 @@ s390_displaced_step_fixup (struct gdbarch *gdbarch, /* Recompute saved return address in R1. */ regcache_cooked_write_unsigned (regs, S390_R0_REGNUM + r1, amode | (from + insnlen)); + /* Update PC iff the instruction doesn't actually branch. */ + if (insn[0] == op_basr && r2 == 0) + regcache_write_pc (regs, from + insnlen); } /* Handle absolute branch instructions. */