From patchwork Mon Mar 7 10:20:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 11229 Received: (qmail 116096 invoked by alias); 7 Mar 2016 10:21:04 -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 116084 invoked by uid 89); 7 Mar 2016 10:21:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=analyzer, NOP, unwinding, Hx-languages-length:1712 X-HELO: e06smtp07.uk.ibm.com Received: from e06smtp07.uk.ibm.com (HELO e06smtp07.uk.ibm.com) (195.75.94.103) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Mon, 07 Mar 2016 10:21:03 +0000 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 Mar 2016 10:20:59 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 Mar 2016 10:20:57 -0000 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: arnez@linux.vnet.ibm.com X-IBM-RcptTo: gdb-patches@sourceware.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 1B35817D8069 for ; Mon, 7 Mar 2016 10:21:24 +0000 (GMT) Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u27AKupv7471596 for ; Mon, 7 Mar 2016 10:20:56 GMT Received: from d06av09.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u27AKui5018169 for ; Mon, 7 Mar 2016 03:20:56 -0700 Received: from oc1027705133.ibm.com (dyn-9-152-212-180.boeblingen.de.ibm.com [9.152.212.180]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u27AKuiF018148 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 7 Mar 2016 03:20:56 -0700 From: Andreas Arnez To: gdb-patches@sourceware.org Cc: Ulrich Weigand Subject: [PATCH] S390: Recognize special jumps in prologue parser Date: Mon, 07 Mar 2016 11:20:56 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16030710-0029-0000-0000-0000062975AE X-IsSubscribed: yes Functions compiled with the gcc option `-mhotpatch' may start with a branch-never BRCL instruction as a 6-byte NOP. And functions compiled with `-mstack-size' contain a BRC instruction in their prologue that is actually a conditional trap. Both of these special jumps cause the prologue parser to stop and yield bad unwinding results. This change makes the prologue analyzer recognize such special jumps and ignore them. gdb/ChangeLog: * s390-linux-tdep.c (s390_analyze_prologue): Ignore BRC and BRCL instructions that do nothing or are conditional traps. --- gdb/s390-linux-tdep.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c index 155bc66..950696e 100644 --- a/gdb/s390-linux-tdep.c +++ b/gdb/s390-linux-tdep.c @@ -1567,13 +1567,25 @@ s390_analyze_prologue (struct gdbarch *gdbarch, break; } + /* BRC/BRCL -- branch relative on condition. Ignore "branch + never", branch to following instruction, and "conditional + trap" (BRC +2). Otherwise terminate search. */ + else if (is_ri (insn, op1_brc, op2_brc, &r1, &i2)) + { + if (r1 != 0 && i2 != 1 && i2 != 2) + break; + } + else if (is_ril (insn, op1_brcl, op2_brcl, &r1, &i2)) + { + if (r1 != 0 && i2 != 3) + break; + } + /* Terminate search when hitting any other branch instruction. */ else if (is_rr (insn, op_basr, &r1, &r2) || is_rx (insn, op_bas, &r1, &d2, &x2, &b2) || is_rr (insn, op_bcr, &r1, &r2) || is_rx (insn, op_bc, &r1, &d2, &x2, &b2) - || is_ri (insn, op1_brc, op2_brc, &r1, &i2) - || is_ril (insn, op1_brcl, op2_brcl, &r1, &i2) || is_ril (insn, op1_brasl, op2_brasl, &r2, &i2)) break;