7 #include <sys/ucontext.h>
9 static char* rip_at_sig = NULL;
11 static void int_handler(int signum, siginfo_t *si, void *uc_arg)
13 ucontext_t *uc = (ucontext_t *)uc_arg;
14 /* Note that uc->uc_mcontext is an embedded struct, not a pointer */
15 mcontext_t *mc = &(uc->uc_mcontext);
16 void *pc = (void*)mc->gregs[REG_RIP];
17 printf("in int_handler, RIP is ...\n");
21 static void register_handler(int sig, void *handler)
24 sa.sa_flags = SA_RESTART | SA_SIGINFO;
25 sigfillset(&sa.sa_mask);
26 sa.sa_sigaction = handler;
27 sigaction(sig, &sa, NULL);
33 register_handler(SIGTRAP, int_handler);
35 "movabsq $zz_int, %%rdx\n"
40 : "m" (intaddr) /* input: address of var to store target addr to */
41 : /* clobbers */ "rdx"
43 /* intaddr is the address of the int 3 insn. rip_at_sig is the PC
44 after the exception, which should be the next insn along.
46 if (intaddr != NULL && rip_at_sig != NULL
47 && rip_at_sig == intaddr+1)