- switch (trap) {
-
- case trap_PendingInterrupt:
- FSHOW((stderr, "<trap pending interrupt>\n"));
- arch_skip_instruction(context);
- interrupt_handle_pending(context);
- break;
-
- case trap_Halt:
- /* Note: the old CMU CL code tried to save FPU state
- * here, and restore it after we do our thing, but there
- * seems to be no point in doing that, since we're just
- * going to lose(..) anyway. */
- fake_foreign_function_call(context);
- lose("%%PRIMITIVE HALT called; the party is over.");
-
- case trap_Error:
- case trap_Cerror:
- FSHOW((stderr, "<trap error/cerror %d>\n", code));
- interrupt_internal_error(signal, info, context, code==trap_Cerror);
- break;
-
- case trap_Breakpoint:
- (char*)(*os_context_pc_addr(context)) -= 1;
- handle_breakpoint(signal, info, context);
- break;
-
- case trap_FunctionEndBreakpoint:
- (char*)(*os_context_pc_addr(context)) -= 1;
- *os_context_pc_addr(context) =
- (int)handle_function_end_breakpoint(signal, info, context);
- break;
-
- default:
- FSHOW((stderr,"[C--trap default %d %d %x]\n",
- signal, code, context));
- interrupt_handle_now(signal, info, context);
- break;
+ handle_trap(context, trap);
+}
+
+void
+sigill_handler(int signal, siginfo_t *siginfo, os_context_t *context) {
+ /* Triggering SIGTRAP using int3 is unreliable on OS X/x86, so
+ * we need to use illegal instructions for traps.
+ */
+#if defined(LISP_FEATURE_DARWIN) && !defined(LISP_FEATURE_MACH_EXCEPTION_HANDLER)
+ if (*((unsigned short *)*os_context_pc_addr(context)) == 0x0b0f) {
+ *os_context_pc_addr(context) += 2;
+ return sigtrap_handler(signal, siginfo, context);