How to dump more info when received a SIGSEGV signal?
- From: "cyril.li@xxxxxxxxx" <cyril.li@xxxxxxxxx>
- Date: 26 Jan 2006 23:48:29 -0800
Hi,
I try to dump more system information when process receives a SIGSEGV
signal by using sigaction() system call, the code is showed below.
However the result is not expected, e.g. the eip is not the the fault
instruction when I use objdump to see the binary.
P.S.
The processor is IA32 and Linux kernel is 2.6
------------------------------------------------------------------------------------------
void segv_handler(int sig, struct sigcontext ctx)
{
printf("eip = %x\n", ctx.eip);
printf("trapno = %x\n", ctx.trapno);
exit(0);
}
main()
{
struct sigaction m;
char *p = (char *)0x0,*q, arr[]="Ma";
q=arr;
m.sa_flags = SA_SIGINFO;
m.sa_handler = (void (*)(int))segv_handler;
sigaction(SIGSEGV, &m, (struct sigaction *)NULL);
*p++ = *q++;
return 0;
}
.
- Follow-Ups:
- Re: How to dump more info when received a SIGSEGV signal?
- From: Paul Pluzhnikov
- Re: How to dump more info when received a SIGSEGV signal?
- From: Andrei Voropaev
- Re: How to dump more info when received a SIGSEGV signal?
- Prev by Date: Re: Dynamic library
- Next by Date: Re: How to dump more info when received a SIGSEGV signal?
- Previous by thread: Dynamic library
- Next by thread: Re: How to dump more info when received a SIGSEGV signal?
- Index(es):