Neale Ferguson wrote:

>When a signal like SIGSEGV or SIGFPE is intercepted by a signal handler
>that receives signal no., siginfo_t, and ucontext the PSW is that of the
>program old PSW. However, the instruction length code (ILC) is not
>passed anywhere nor can is it accessible (nor could it be relied upon)
>from low-core. This makes writing signal handlers that inspect the
>problem difficult. For example, I want to distinguish between a zero
>divide exception and other fixed point exceptions (both PROG 009). I'd
>like to inspect the opcode to see if it was a divide operations and then
>check the operands to see if the divisor was 0. The divide instruction
>could be 2, 4, or 6 bytes long (RR, RX, RXY format) but because the PSW
>address is pointing to the instruction following and there's no ILC I
>cannot write a foolproof method of finding the opcode (having 1d20 could
>be the opcode for DR but it might be part of the displacement field of
>the D, DL instructions). I'd like to suggest that the ucontext structure
>be enhanced to include the ILC information. (Changing the current
>behavior of the PSW address would probably cause massive breakage.)

Changing ucontext would cause significant ABI issues, so we like to
avoid that if at all possible ;-)

In any case, for those signals where the PSW address points after the
faulting instruction, the siginfo_t always contains a field si_addr
which holds the address of the faulting insn itself.  This can be used
for purposes like the one you describe.

There has been a little bit of confusion about just when the PSW points
to or after the current instruction in the past, but the rule (that
current 2.6 kernels enforce) is: SIGILL/SIGFPE/SIGTRAP point after the
instruction, every other signal points to the instruction.

For an example of how to handle your very problem (analysing SIGFPEs
resulting from divide), you may have a look at
  libjava/include/s390-signal.h (HANDLE_DIVIDE_OVERFLOW)
residing in current GCC sources.


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: [EMAIL PROTECTED]

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [EMAIL PROTECTED] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to