From patchwork Thu May 23 17:27:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 245987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D7E172C029E for ; Fri, 24 May 2013 03:29:51 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=TOP4m3864MSTEddT 9a4mviFFGuxo/2nb4BQVX7kla5OEN5yQFW1mT1V0BKJaLF8NNqRFrkYOxIRLPRp5 lYOlP1iMMMxtMdzVy6pIhPWjdeYllVMjpSnDffHNGkJH9ZR+3smBSpGYxBCRzI6e CuRj8Px/oh9h5ue9y/LehwHr9b0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=LM4aSqYR7EfADwHkK5d9ll Pd5b0=; b=xLwWbcsI20uIaEg7iRWgPlv91AcW6pvePzuTlwpPPjNi/gdfygg2EC 2JDigqm57+mADkEIoQAVxTXGAoJcNTROd+n69sBNYkJH6HpF6N4wxundtd5HAfmp eQ0URXnuD95MJPdlPEeNZy87QcOhpGWn47qmC1pcYYRHgZwae5lsA= Received: (qmail 13172 invoked by alias); 23 May 2013 17:29:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 13163 invoked by uid 89); 23 May 2013 17:29:45 -0000 X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.1 Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 23 May 2013 17:29:44 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 3969A26473EC for ; Thu, 23 May 2013 19:28:21 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FsNAhLJhJPMh for ; Thu, 23 May 2013 19:28:21 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 126522647398 for ; Thu, 23 May 2013 19:28:21 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Solaris] Catch FP exceptions Date: Thu, 23 May 2013 19:27:10 +0200 Message-ID: <1665825.0OqtZUyZYm@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.19-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 X-Virus-Found: No Hi, this isn't really valid Ada semantics, but some people enable traps-on-fp- exceptions in the FPU on Solaris and expect the Ada exception to be caught. There is a glitch with the x87 and the SPARC FPUs: the SIGFPE is delivered after the faulting instruction by Solaris, so the unwinder is fooled and miscomputes the faulting address. Fixed thusly, tested on x86/Solaris and SPARC/Solaris, OK for mainline? 2013-05-23 Eric Botcazou libgcc/ * config/sparc/sol2-unwind.h (MD_FALLBACK_FRAME_STATE_FOR): Do not set fs->signal_frame for SIGFPE raised for IEEE-754 exceptions. * config/i386/sol2-unwind.h (x86_fallback_frame_state): Likewise. 2013-05-23 Eric Botcazou * gnat.dg/fp_exception.adb: New test. Index: config/sparc/sol2-unwind.h =================================================================== --- config/sparc/sol2-unwind.h (revision 199191) +++ config/sparc/sol2-unwind.h (working copy) @@ -403,7 +403,12 @@ MD_FALLBACK_FRAME_STATE_FOR (struct _Unw fs->retaddr_column = 0; fs->regs.reg[0].how = REG_SAVED_OFFSET; fs->regs.reg[0].loc.offset = (long)shifted_ra_location - new_cfa; - fs->signal_frame = 1; + + /* SIGFPE for IEEE-754 exceptions is delivered after the faulting insn + rather than before it, so don't set fs->signal_frame in that case. + We test whether the cexc field of the FSR is zero. */ + if ((mctx->fpregs.fpu_fsr & 0x1f) == 0) + fs->signal_frame = 1; return _URC_NO_REASON; } Index: config/i386/sol2-unwind.h =================================================================== --- config/i386/sol2-unwind.h (revision 199190) +++ config/i386/sol2-unwind.h (working copy) @@ -249,7 +249,12 @@ x86_fallback_frame_state (struct _Unwind fs->regs.reg[8].how = REG_SAVED_OFFSET; fs->regs.reg[8].loc.offset = (long)&mctx->gregs[EIP] - new_cfa; fs->retaddr_column = 8; - fs->signal_frame = 1; + + /* SIGFPE for IEEE-754 exceptions is delivered after the faulting insn + rather than before it, so don't set fs->signal_frame in that case. + We test whether the ES field of the Status Register is zero. */ + if ((mctx->fpregs.fp_reg_set.fpchip_state.status & 0x80) == 0) + fs->signal_frame = 1; return _URC_NO_REASON; }