| T.R | Title | User | Personal Name
 | Date | Lines | 
|---|
| 8841.1 | why do you want to do this? | VAXCPU::michaud | Jeff Michaud - ObjectBroker | Fri Feb 14 1997 21:54 | 7 | 
|  | 	Why don't you explain why you want to do this and we can
	proceed from there.
	The only supported (and relatively portable, at least to
	other UNIX platforms) way I know of to recover from a
	SEGV or BUS error is to use setjmp and then longjmp from
	the signal handler.
 | 
| 8841.2 | sc_pc in sig_context structure | STEVEN::hobbs | Steven Hobbs | Sat Feb 15 1997 17:46 | 14 | 
|  | The -speculate optimization option on the various compiler command
lines uses an additional supported way to continue after a SEGV or BUS
error but that is probably no useful in the current situation.
I often write code that continues from FPE faults.  All I need to do
is increment by 4 the sc_pc field in the sig_context structure before
returning from the signal handler.
Note: I must be careful when continuing from FPE signals since some
signals are faults and others others are traps.  Only the faults need
sc_pc incremented.  On Unix, both SEGV and BUS are faults but if you
are writing code that will run on both Unix and VMS then you should be
careful.  I believe that the BUS exceptions on VMS caused by
misaligned memory references are synchronous traps rather than faults.
 | 
| 8841.3 |  | CADSYS::BOGDANOV |  | Mon Feb 17 1997 13:16 | 15 | 
|  | .1
>	Why don't you explain why you want to do this and we can
>	proceed from there.
	
	I need a memory probe mechanism where request, address  and data is
known to the program. I can analyze a current instruction to see whwt is going
on. Then the program should continue, returning normally from a handler.
.2 
	Thank you for an idea. I did not expect that incrementing pc in the
sig_context is going to work but looks like it does. Is it a reliable mechanism
on Dunix?
>> Serge
 | 
| 8841.4 | sigreturn | CADSYS::BOGDANOV |  | Mon Feb 17 1997 17:32 | 22 | 
|  | I think that I've found an answer in man pages. The sigreturn routine should be
able to help. 
  #include <signal.h>
  int sigreturn(
          struct sigcontext *scp) ;
PARAMETERS
  scp       Points to a sigcontext structure whose members contain the pro-
            cessor state to be restored. The contents of the sigcontext
            structure should have been previously obtained by entry to a sig-
            nal handler or by the setjmp() or sigsetjmp() function.
DESCRIPTION
  The sigreturn() function restores the processor state of the calling pro-
  cess from a sigcontext structure...
Thanks
>> Serge
 |