Subject: Re: faulting address in SIGSEGV handler (i386)
To: None <tech-kern@netbsd.org>
From: Valeriy E. Ushakov <uwe@ptc.spbu.ru>
List: tech-kern
Date: 08/31/2001 04:42:49
On Fri, Aug 31, 2001 at 10:23:44 +1000, Simon Burge wrote:
> > > > get at the faulting address in its SIGSEGV handler.
> > >
> > > sc_eip should give you what you want.
> >
> > My understanding is that it needs the address of the access that
> > caused the fault (e.g SFVA on sun4m), not the address of the
> > instruction that tried to perform the access.
>
> A quick glance at a few <machine/signal.h>'s show that sc_pc *seems*
> to be present on all architectures.
sc_pc is %pc to restore. What's needed is the address that causes the
fault. E.g. for
int *bad = (int *)0xdeadbee0;
*bad = 0; /* handler is interested in 'bad' not the %pc */
On sparc the handler will be called with code=0xdeadbee0 (the fault
address). And because of a clever trick in sigcode all the cpu
regiters at the time of the signal are also available with a little
stack scavenge (what would be in mcontext_t on sysv).
SY, Uwe
--
uwe@ptc.spbu.ru | Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen