If you use sigaction , you can define a signal handler that takes 3 arguments:
void (*sa_sigaction)(int signum, siginfo_t *info, void *ucontext)
The third argument passed to the signal handler is a pointer to a data structure specific to the OS and architecture. On linux, its a ucontext_t , which is defined in the header file <sys/ucontext.h> . In this case, uc_mcontext is mcontext_t (machine context), which for x86 contains all the registers during the signal in gregs . This way you can access
ucontext->uc_mcontext.gregs[REG_EIP] (32 bit mode) ucontext->uc_mcontext.gregs[REG_RIP] (64 bit mode)
to get a pointer to a failure instruction instruction.
source share