linux-mips
[Top] [All Lists]

Re: [Patch] / 0 should send SIGFPE not SIGTRAP...

To: linux-mips@linux-mips.org
Subject: Re: [Patch] / 0 should send SIGFPE not SIGTRAP...
From: David Daney <ddaney@avtrex.com>
Date: Fri, 11 Jun 2004 11:12:14 -0700
In-reply-to: <40C9F5A4.2050606@avtrex.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <40C9F5A4.2050606@avtrex.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031030
It might help if I attached the patch.  Here it is...

David Daney wrote:

I am getting a SIGTRAP whenever an integer divide by 0 happens. It should be sending SIGFPE.

It looks like kernel/traps.c is a little messed up.

The attached patch fixes it for me.

The decoding of the break instruction was selecting the wrong bits. It looks like the trap instruction decoding was messed up also. The patch fixes trap also, but I could not figure out how to get gcc to generate the trap form of division, so that part is untested.

David Daney.


--- ../linux-avtrex/linux/arch/mips/kernel/traps.c      2004-02-26 
11:14:09.000000000 -0800
+++ arch/mips/kernel/traps.c    2004-06-11 10:13:59.000000000 -0700
@@ -598,7 +598,7 @@
         * code starts left to bit 16 instead to bit 6 in the opcode.
         * Gas is bug-compatible ...
         */
-       bcode = ((opcode >> 16) & ((1 << 20) - 1));
+       bcode = ((opcode >> 6) & ((1 << 20) - 1));
 
        /*
         * (A short test says that IRIX 5.3 sends SIGTRAP for all break
@@ -633,7 +633,7 @@
 
        /* Immediate versions don't provide a code.  */
        if (!(opcode & OPCODE))
-               tcode = ((opcode >> 6) & ((1 << 20) - 1));
+               tcode = ((opcode >> 6) & ((1 << 10) - 1));
 
        /*
         * (A short test says that IRIX 5.3 sends SIGTRAP for all trap
<Prev in Thread] Current Thread [Next in Thread>