Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Aug 1998 14:25:41 +0200
From:      Martin Cracauer <cracauer@cons.org>
To:        Stephen Hocking-Senior Programmer PGS Tensor Perth <shocking@prth.pgs.com>, Bruce Evans <bde@zeta.org.au>
Cc:        current@FreeBSD.ORG
Subject:   Re: Floating Point Exceptions, signal handlers & subsequent ops
Message-ID:  <19980826142541.B20511@cons.org>
In-Reply-To: <199808260127.JAA02700@ariadne.tensor.pgs.com>; from Stephen Hocking-Senior Programmer PGS Tensor Perth on Wed, Aug 26, 1998 at 09:27:48AM %2B0800
References:  <199808252351.JAA32306@godzilla.zeta.org.au> <199808260127.JAA02700@ariadne.tensor.pgs.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
In <199808260127.JAA02700@ariadne.tensor.pgs.com>, Stephen Hocking-Senior Programmer PGS Tensor Perth wrote: 
> 
> 	[Much scary stuff regarding traps and the like...]
> 
> OK, I've had a look at machine/trap.h, how do I go about getting info on 
> exactly was exception was caused? A brief perusal of the man pages for math 
> and fpsetmask offers no clues (unless I've missed something totally obvious). 
> All the program wishes to do is note the fact and excveption has occured, get 
> some runtime stats (which is where that next FP operation happens) and exit.

As far as I know, you can't. The kernel does not pass the FP registers
as they were in the mainline program flow to your signal handler.

What we need here is a system call to ask the kernel for the FP
register contents which it should have saved before entering the FP
handler. If the user required so, by a system call, sysctl variable or
kernel config option.

I actually didn't beleive this :-) and wrote some code to get the
registers via the "hidden" third parameter to a signal handler, but in
fact the exception indication bits were cleared.

Example code to copy the register contents to some save place:

static int handler(int sig, int code, struct sigcontext *scp)
{
#define TMP "FPE handler\n"
  write(2,TMP,sizeof(TMP)-1);
#undef TMP
  sig_fpe_was_here++;
  sig_sig = sig;
  sig_code = code;
  memcpy(&sig_context, scp, sizeof(*scp));
  return sig;
}

It's very possible that this code is nonsense. 

I appended some programs tangling with FP on FreeBSD. This fragment is
from "freebsd-signal.c". 

Martin
-- 
%%%%%%%%%%%%%%%%%%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