Re: SIGSEGV signal handler
It appears that you need information that is no longer readily
available. While siginfo.si_addr is provided as "the address of the
fault" (see sigaction(2)), there does not appear to be a value that
provides the directionality of the fault (read or write).
FWIW, the sigaction(2) manpage states:
Before the introduction of SA_SIGINFO it was also possible
to get some additional information, namely by using a
sa_handler with second argument of type struct sigcontext.
See the relevant kernel sources for details. This use is
Not exactly. Please note that it should not be a SA_SIGINFO issue, as
with x86/32 bits I can get this information even with SIGINFO, but with
x86_64 the structure is different.
In fact, by making
static void segv_handler(sig, sip, uap)
struct siginfo *sip;
struct ucontext *uap;
I was already able to find the address of the fault faulting memory
reference (siginfo.si_addr) and whether it was a read or write fault
(write_fault = uap->uc_mcontext.gregs[REG_ERR] & 2)
But I still need the address of the faulting instruction with x86_64.
This information should be readily available as several softwares need
it, including performance monitors (e.g Intel Vtune), debuggers (e.g.
gdb) and tracers.
Perhaps you can trace (ptrace(2)) your process from another process,
and capture the address and directionality of the SIGSEGV through the
It won't be a good solution because of the overhead. I want to get it
from the same source as ptrace does. Otherwise, it would be like making
a debugger to call another debugger to get the information it needs.
- Prev by Date: Re: "Hello, World!" Operating System
- Next by Date: Getting "absolute time" in Linux
- Previous by thread: Re: SIGSEGV signal handler
- Next by thread: Re: SIGSEGV signal handler