4 /* TODO(bernhard): use {u,}int* types */
7 // Note by hs: my signal.h includes sys/uconctext which conflicts with
8 // asm/ucontext - this hack kinda solves the problem for me ;-)
9 // so feel free to blame me for that s**t
10 #if defined __USE_XOPEN2K8
13 #warning hs-hack: undefining __USE_XOPEN2K8 for signal.h
17 #define __USE_XOPEN2K8
20 #include <sys/ucontext.h>
22 #include "prototypes.h"
24 void trap(int nSignal, siginfo_t *info, void *ctx)
26 printf("sig: %d\n", nSignal);
28 mcontext_t *mctx = &((ucontext_t *) ctx)->uc_mcontext;
29 unsigned int from = (unsigned int) mctx->gregs[REG_EIP];
31 mateTrapHandler(nSignal, info, ctx, from);
33 printf("from: 0x%08x\n", from);
37 void registerSignalHandlers(void)
39 printf("registering\n");
40 struct sigaction illaction;
41 illaction.sa_sigaction = trap;
42 sigemptyset(&illaction.sa_mask);
43 illaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER;
44 sigaction(SIGILL, &illaction, NULL);
48 struct sigaction segvaction;
49 segvaction.sa_sigaction = trap;
50 sigemptyset(&segvaction.sa_mask);
51 segvaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER;
52 sigaction(SIGSEGV, &segvaction, NULL);
57 void registerSignalHandlers2(void (*f)(int, siginfo_t*,void*))
59 printf("registering2\n");
60 struct sigaction illaction;
61 illaction.sa_sigaction = f;
62 sigemptyset(&illaction.sa_mask);
63 illaction.sa_flags = SA_SIGINFO | SA_RESTART | SA_NODEFER;
64 sigaction(SIGILL, &illaction, NULL);