/* * The GC needs to be hooked into whatever signal is raised for * page fault on this OS. */ static void sigsegv_handler(int signal, siginfo_t *info, os_context_t *context) { os_vm_address_t addr = arch_get_bad_addr(signal, info, context); #ifdef LISP_FEATURE_ALPHA /* Alpha stuff: This is the end of a pseudo-atomic section during which a signal was received. We must deal with the pending interrupt (see also interrupt.c, ../code/interrupt.lisp) (how we got here: when interrupting, we set bit 63 in reg_ALLOC. At the end of the atomic section we tried to write to reg_ALLOC, got a SIGSEGV (there's nothing mapped there) so ended up here. */ if (addr != NULL && *os_context_register_addr(context, reg_ALLOC) & (1L<<63)) { *os_context_register_addr(context, reg_ALLOC) -= (1L<<63); interrupt_handle_pending(context); return; } #endif #ifdef LISP_FEATURE_GENCGC if (!gencgc_handle_wp_violation(addr)) #else if (!cheneygc_handle_wp_violation(context, addr)) #endif if (!handle_guard_page_triggered(context, addr)) lisp_memory_fault_error(context, addr); }
static void call_info_from_context(struct call_info *info, os_context_t *context) { unsigned long pc; info->interrupted = 1; if (lowtag_of(*os_context_register_addr(context, reg_CODE)) == FUN_POINTER_LOWTAG) { /* We tried to call a function, but crapped out before $CODE could * be fixed up. Probably an undefined function. */ info->frame = (struct call_frame *)(unsigned long) (*os_context_register_addr(context, reg_OCFP)); info->lra = (lispobj)(*os_context_register_addr(context, reg_LRA)); info->code = code_pointer(info->lra); pc = (unsigned long)native_pointer(info->lra); } else { info->frame = (struct call_frame *)(unsigned long) (*os_context_register_addr(context, reg_CFP)); info->code = code_pointer(*os_context_register_addr(context, reg_CODE)); info->lra = NIL; pc = *os_context_pc_addr(context); } if (info->code != NULL) info->pc = pc - (unsigned long) info->code - #ifndef LISP_FEATURE_ALPHA (HEADER_LENGTH(info->code->header) * sizeof(lispobj)); #else (HEADER_LENGTH(((struct code *)info->code)->header) * sizeof(lispobj)); #endif else
static lispobj find_code(os_context_t *context) { #ifdef reg_CODE lispobj code = *os_context_register_addr(context, reg_CODE); lispobj header; if (lowtag_of(code) != OTHER_POINTER_LOWTAG) return NIL; header = *(lispobj *)(code-OTHER_POINTER_LOWTAG); if (widetag_of(header) == CODE_HEADER_WIDETAG) return code; else return code - HeaderValue(header)*sizeof(lispobj); #else lispobj codeptr = (lispobj)component_ptr_from_pc((lispobj *)(*os_context_pc_addr(context))); if (codeptr == 0) return NIL; else return codeptr + OTHER_POINTER_LOWTAG; #endif }
void *handle_fun_end_breakpoint(os_context_t *context) { lispobj code, lra; struct code *codeptr; DX_ALLOC_SAP(context_sap, context); fake_foreign_function_call(context); #ifndef LISP_FEATURE_SB_SAFEPOINT unblock_gc_signals(0, 0); #endif code = find_code(context); codeptr = (struct code *)native_pointer(code); #ifndef LISP_FEATURE_WIN32 /* Don't disallow recursive breakpoint traps. Otherwise, we can't * use debugger breakpoints anywhere in here. */ thread_sigmask(SIG_SETMASK, os_context_sigmask_addr(context), 0); #endif funcall3(StaticSymbolFunction(HANDLE_BREAKPOINT), compute_offset(context, code), code, context_sap); lra = codeptr->constants[REAL_LRA_SLOT]; #ifdef LISP_FEATURE_PPC /* PPC now passes LRA objects in reg_LRA during return. Other * platforms should as well, but haven't been fixed yet. */ *os_context_register_addr(context, reg_LRA) = lra; #else #ifdef reg_CODE *os_context_register_addr(context, reg_CODE) = lra; #endif #endif undo_fake_foreign_function_call(context); #ifdef reg_LRA return (void *)(lra-OTHER_POINTER_LOWTAG+sizeof(lispobj)); #else return compute_pc(lra, fixnum_value(codeptr->constants[REAL_LRA_SLOT+1])); #endif }
static void print_context(os_context_t *context) { int i; for (i = 0; i < NREGS; i++) { printf("%s:\t", lisp_register_names[i]); #ifdef LISP_FEATURE_X86 brief_print((lispobj)(*os_context_register_addr(context, i*2))); #else brief_print((lispobj)(*os_context_register_addr(context,i))); #endif } #ifdef LISP_FEATURE_DARWIN printf("DAR:\t\t 0x%08lx\n", (unsigned long)(*os_context_register_addr(context, 41))); printf("DSISR:\t\t 0x%08lx\n", (unsigned long)(*os_context_register_addr(context, 42))); #endif printf("PC:\t\t 0x%08lx\n", (unsigned long)(*os_context_pc_addr(context))); }
os_context_register_t * os_context_lr_addr(os_context_t *context) { return os_context_register_addr(context, reg_LR); }
os_context_register_t * os_context_pc_addr(os_context_t *context) { return os_context_register_addr(context, reg_PC); }