228 |
|
#define SIGSEGV_FAULT_INSTRUCTION SIGSEGV_CONTEXT_REGS[REG_PC] |
229 |
|
#endif |
230 |
|
#endif |
231 |
< |
#if defined(__NetBSD__) || defined(__FreeBSD__) |
231 |
> |
#if defined(__FreeBSD__) |
232 |
|
#if (defined(i386) || defined(__i386__)) |
233 |
|
#define SIGSEGV_FAULT_INSTRUCTION (((struct sigcontext *)scp)->sc_eip) |
234 |
|
#define SIGSEGV_REGISTER_FILE ((unsigned int *)&(((struct sigcontext *)scp)->sc_edi)) /* EDI is the first GPR (even below EIP) in sigcontext */ |
297 |
|
#define SIGSEGV_FAULT_HANDLER_ARGS sig, code, scp |
298 |
|
#define SIGSEGV_FAULT_ADDRESS get_fault_address(scp) |
299 |
|
#define SIGSEGV_FAULT_INSTRUCTION scp->sc_pc |
300 |
– |
|
301 |
– |
// From Boehm's GC 6.0alpha8 |
302 |
– |
static sigsegv_address_t get_fault_address(struct sigcontext *scp) |
303 |
– |
{ |
304 |
– |
unsigned int instruction = *((unsigned int *)(scp->sc_pc)); |
305 |
– |
unsigned long fault_address = scp->sc_regs[(instruction >> 16) & 0x1f]; |
306 |
– |
fault_address += (signed long)(signed short)(instruction & 0xffff); |
307 |
– |
return (sigsegv_address_t)fault_address; |
308 |
– |
} |
300 |
|
#endif |
301 |
|
#endif |
302 |
|
|
334 |
|
#define SIGSEGV_ALL_SIGNALS FAULT_HANDLER(SIGSEGV) |
335 |
|
#endif |
336 |
|
|
337 |
< |
// NetBSD or FreeBSD |
338 |
< |
#if defined(__NetBSD__) || defined(__FreeBSD__) |
337 |
> |
// NetBSD |
338 |
> |
#if defined(__NetBSD__) |
339 |
|
#if (defined(m68k) || defined(__m68k__)) |
340 |
|
#include <m68k/frame.h> |
341 |
|
#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp |
363 |
|
} |
364 |
|
return (sigsegv_address_t)fault_addr; |
365 |
|
} |
366 |
< |
#else |
367 |
< |
#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, void *scp, char *addr |
366 |
> |
#endif |
367 |
> |
#if (defined(alpha) || defined(__alpha__)) |
368 |
> |
#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp |
369 |
> |
#define SIGSEGV_FAULT_HANDLER_ARGS sig, code, scp |
370 |
> |
#define SIGSEGV_FAULT_ADDRESS get_fault_address(scp) |
371 |
> |
#define SIGSEGV_ALL_SIGNALS FAULT_HANDLER(SIGBUS) |
372 |
> |
#endif |
373 |
> |
#if (defined(i386) || defined(__i386__)) |
374 |
> |
#error "FIXME: need to decode instruction and compute EA" |
375 |
> |
#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp |
376 |
> |
#define SIGSEGV_FAULT_HANDLER_ARGS sig, code, scp |
377 |
> |
#define SIGSEGV_ALL_SIGNALS FAULT_HANDLER(SIGSEGV) |
378 |
> |
#endif |
379 |
> |
#endif |
380 |
> |
#if defined(__FreeBSD__) |
381 |
> |
#define SIGSEGV_ALL_SIGNALS FAULT_HANDLER(SIGBUS) |
382 |
> |
#if (defined(i386) || defined(__i386__)) |
383 |
> |
#define SIGSEGV_FAULT_HANDLER_ARGLIST int sig, int code, struct sigcontext *scp, char *addr |
384 |
|
#define SIGSEGV_FAULT_HANDLER_ARGS sig, code, scp, addr |
385 |
|
#define SIGSEGV_FAULT_ADDRESS addr |
386 |
< |
#define SIGSEGV_ALL_SIGNALS FAULT_HANDLER(SIGBUS) |
386 |
> |
#define SIGSEGV_FAULT_INSTRUCTION scp->sc_eip |
387 |
> |
#define SIGSEGV_REGISTER_FILE ((unsigned int *)&scp->sc_edi) |
388 |
> |
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction |
389 |
|
#endif |
390 |
|
#endif |
391 |
|
|
392 |
+ |
// Extract fault address out of a sigcontext |
393 |
+ |
#if (defined(alpha) || defined(__alpha__)) |
394 |
+ |
// From Boehm's GC 6.0alpha8 |
395 |
+ |
static sigsegv_address_t get_fault_address(struct sigcontext *scp) |
396 |
+ |
{ |
397 |
+ |
unsigned int instruction = *((unsigned int *)(scp->sc_pc)); |
398 |
+ |
unsigned long fault_address = scp->sc_regs[(instruction >> 16) & 0x1f]; |
399 |
+ |
fault_address += (signed long)(signed short)(instruction & 0xffff); |
400 |
+ |
return (sigsegv_address_t)fault_address; |
401 |
+ |
} |
402 |
+ |
#endif |
403 |
+ |
|
404 |
+ |
|
405 |
|
// MacOS X, not sure which version this works in. Under 10.1 |
406 |
|
// vm_protect does not appear to work from a signal handler. Under |
407 |
|
// 10.2 signal handlers get siginfo type arguments but the si_addr |