On Mon, Mar 03, 2008 at 01:38:01AM +0100, Andi Kleen wrote:
> [EMAIL PROTECTED] (Ross Ridge) writes:
> 
> > Robert Dewar writes:
> > >Yes, and that is what we would want for Ada, so I am puzzled by your
> > >sigh. All Ada needs to do is to issue a constraint_error exception,
> > >it does not need to know where the exception came from or why except
> > >in very broad detail.
> > 
> > Unless printing "This application has requested the Runtime to terminate
> > it in an unusual way." counts an issuing a contraint_error in Ada,
> > it seems to me that -ftrapv and Ada have differing requirements.
> > How can you portabilty and correctly generate a constraint_error if
> > the code generated by -ftrapv calls the C runtime function abort()?
> > On Unix-like systems you can catch SIGABRT, but even there how do you
> > tell that it didn't come from CTRL-\, a signal sent from a different
> > process, or abort() called fom some other context?  With INTO I don't
> > see any way distignuish the SIGSEGV it generates on Linux from any of
> > the myriad other ways a SIGSEGV can be generated.
> 
> Easy: The signal frame that is passed as an argument to the signal handler 
> has a trapno member than will contain 4 for INTO. The only other case where 
> it would contain 4 would be a explicit int 4

Yes, but it seems that INTO has been removed for 64 bit mode. In this
case the best solution is probably to insert conditional jumps (jo)
both in 32 and 64 bit mode for uniformity. PPC can only use conditional
jumps too, although the easily testable overflow bit is sticky so you 
don't need a test after every instuction. 

The code with conditional jumps is bigger but less dependant on the 
OS environment or of any user code trying to install its own signal 
handlers (especially for SIGSEGV which multiplexes so many exception
causes). The performance impact is probably small since the jumps
will normally be correctly predicted as not taken.

        Gabriel

Reply via email to