Re: get faulting address in segfault?

Systemkennung Linux (linux@mailhost.uni-koblenz.de)
Wed, 26 Feb 1997 10:58:46 +0100 (MET)


Hi,

> is it possible under linux to catch a
> segfault and get the faulting address?
>
> That is can a signalhandler that catches
> SIGSEGV find out the faulting address?

All Unices pass a pointer to the saved old context to the sighandler
as the second or third parameter. This is a struct sigcontext *.
Certain Linux versions for some reason call that parameter
struct sigcontext_struct *. You can get the definition from
<sigcontext.h>; the kernel source defines struct sigcontext in
linux/include/asm-<cpu>/sigcontext.h.

Downside of the mechanism: it highly machine dependand.

Ralf