1 /* $NetBSD: sigsegv.c,v 1.4 2003/11/13 06:48:31 simonb Exp $ */
3 #include <sys/ucontext.h>
11 sigsegv(int signo
, siginfo_t
*info
, void *ptr
)
14 printf("%d %p %p\n", signo
, info
, ptr
);
16 printf("si_signo=%d\n", info
->si_signo
);
17 printf("si_errno=%d\n", info
->si_errno
);
18 printf("si_code=%d\n", info
->si_code
);
19 printf("si_trap=%d\n", info
->si_trap
);
20 printf("si_addr=%p\n", info
->si_addr
);
23 ucontext_t
*ctx
= ptr
;
25 mcontext_t
*mc
= &ctx
->uc_mcontext
;
26 printf("uc_flags 0x%x\n", ctx
->uc_flags
);
27 printf("uc_link %p\n", ctx
->uc_link
);
28 for (i
= 0; i
< sizeof(ctx
->uc_sigmask
.__bits
) /
29 sizeof(ctx
->uc_sigmask
.__bits
[0]); i
++)
30 printf("uc_sigmask[%d] 0x%x\n", i
,
31 ctx
->uc_sigmask
.__bits
[i
]);
32 printf("uc_stack %p %lu 0x%x\n", ctx
->uc_stack
.ss_sp
,
33 (unsigned long)ctx
->uc_stack
.ss_size
,
34 ctx
->uc_stack
.ss_flags
);
35 for (i
= 0; i
< sizeof(mc
->__gregs
)/sizeof(mc
->__gregs
[0]); i
++)
36 printf("uc_mcontext.greg[%d] 0x%x\n", i
,
40 assert(info
->si_signo
== SIGSEGV
);
41 assert(info
->si_errno
== 0);
42 assert(info
->si_code
== SEGV_MAPERR
);
43 assert(info
->si_addr
== (void *)0);
51 sa
.sa_flags
= SA_SIGINFO
;
52 sa
.sa_sigaction
= sigsegv
;
53 sigemptyset(&sa
.sa_mask
);
54 sigaction(SIGSEGV
, &sa
, NULL
);