From patchwork Wed Nov 19 09:07:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 3802 Received: (qmail 31146 invoked by alias); 19 Nov 2014 09:07:36 -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 31135 invoked by uid 89); 19 Nov 2014 09:07:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp17.uk.ibm.com Received: from e06smtp17.uk.ibm.com (HELO e06smtp17.uk.ibm.com) (195.75.94.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 19 Nov 2014 09:07:35 +0000 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Nov 2014 09:07:32 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 19 Nov 2014 09:07:30 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 2513517D8059 for ; Wed, 19 Nov 2014 09:07:42 +0000 (GMT) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sAJ97Tqs17170824 for ; Wed, 19 Nov 2014 09:07:29 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sAJ97TQD027662 for ; Wed, 19 Nov 2014 02:07:29 -0700 Received: from br87z6lw.de.ibm.com ([9.84.41.136]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sAJ97SNl027649; Wed, 19 Nov 2014 02:07:28 -0700 From: Andreas Arnez To: Pedro Alves Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] Use 2-byte instead of 4-byte NOP on S390 in 'bp-permanent' test case References: <874mtxssee.fsf@br87z6lw.de.ibm.com> <546A2DDA.3090700@redhat.com> Date: Wed, 19 Nov 2014 10:07:27 +0100 In-Reply-To: <546A2DDA.3090700@redhat.com> (Pedro Alves's message of "Mon, 17 Nov 2014 17:18:18 +0000") Message-ID: <87zjbnr228.fsf@br87z6lw.de.ibm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14111909-0029-0000-0000-000001BCE809 X-IsSubscribed: yes On Mon, Nov 17 2014, Pedro Alves wrote: > On 11/17/2014 04:28 PM, Andreas Arnez wrote: >> The bp-permanent test case assumes that a NOP is exactly as long as a >> software breakpoint. > > Ah. It'd be good to add a comment mentioning this assumption, > where the NOPs are defined. Could you do that? Sure. >> This is not the case for the S390 "nop" >> instruction, which is 4 bytes long, while a software breakpoint is >> just 2 bytes long. The "nopr" instruction has the right size and can >> be used instead. >> >> Without this patch the test case fails on S390 when trying to continue >> after SIGTRAP on the permanent breakpoint: >> >> ... >> Continuing. >> >> Program received signal SIGILL, Illegal instruction. >> test () at /home/arnez/src/binutils-gdb/gdb/testsuite/gdb.base/bp-permanent.c:40 >> 40 NOP; /* after permanent bp */ >> (gdb) > > Yeah, if the instruction was originally 4 bytes, and then we poke a 2-byte > breakpoint, when GDB skips the breakpoint manually, advancing 2 bytes, > then the PC ends up pointing at the middle of the original instruction... Right -- which contains a two-byte invalid opcode in this case. > The patch is OK. Thanks. For reference, here's the updated patch: -- >8 -- Subject: [PATCH] Use 2-byte instead of 4-byte NOP on S390 in 'bp-permanent' test case The bp-permanent test case assumes that a NOP is exactly as long as a software breakpoint. This is not the case for the S390 "nop" instruction, which is 4 bytes long, while a software breakpoint is just 2 bytes long. The "nopr" instruction has the right size and can be used instead. Without this patch the test case fails on S390 when trying to continue after SIGTRAP on the permanent breakpoint: ... Continuing. Program received signal SIGILL, Illegal instruction. test () at /home/arnez/src/binutils-gdb/gdb/testsuite/gdb.base/bp-permanent.c:40 40 NOP; /* after permanent bp */ (gdb) FAIL: gdb.base/bp-permanent.exp: always_inserted=off, sw_watchpoint=0: basics: stop at permanent breakpoint With this patch the test case succeeds without any FAILs. gdb/testsuite/ChangeLog: * gdb.base/bp-permanent.c (NOP): Define as 2-byte instead of 4-byte instruction on S390. --- gdb/testsuite/gdb.base/bp-permanent.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdb/testsuite/gdb.base/bp-permanent.c b/gdb/testsuite/gdb.base/bp-permanent.c index a45a922..64cfb4d 100644 --- a/gdb/testsuite/gdb.base/bp-permanent.c +++ b/gdb/testsuite/gdb.base/bp-permanent.c @@ -21,7 +21,14 @@ #include #endif +/* NOP instruction: must have the same size as the breakpoint + instruction. */ + +#if defined(__s390__) || defined(__s390x__) +#define NOP asm("nopr 0") +#else #define NOP asm("nop") +#endif /* Buffer holding the breakpoint instruction. */ unsigned char buffer[16];