-kern_return_t
-catch_exception_raise_state(
- __unused mach_port_t exception_port,
- __unused exception_type_t exception,
- __unused const exception_data_t code,
- __unused mach_msg_type_number_t codeCnt,
- __unused int *flavor,
- __unused const thread_state_t old_state,
- __unused mach_msg_type_number_t old_stateCnt,
- __unused thread_state_t new_state,
- __unused mach_msg_type_number_t *new_stateCnt)
-{
- return(KERN_INVALID_ARGUMENT);
-}
-
-kern_return_t
-catch_mach_exception_raise_state(
- __unused mach_port_t exception_port,
- __unused exception_type_t exception,
- __unused const mach_exception_data_t code,
- __unused mach_msg_type_number_t codeCnt,
- __unused int *flavor,
- __unused const thread_state_t old_state,
- __unused mach_msg_type_number_t old_stateCnt,
- __unused thread_state_t new_state,
- __unused mach_msg_type_number_t *new_stateCnt)
-{
- return(KERN_INVALID_ARGUMENT);
-}
-
-kern_return_t
-catch_exception_raise_state_identity(
- __unused mach_port_t exception_port,
- __unused mach_port_t thread,
- __unused mach_port_t task,
- __unused exception_type_t exception,
- __unused exception_data_t code,
- __unused mach_msg_type_number_t codeCnt,
- __unused int *flavor,
- __unused thread_state_t old_state,
- __unused mach_msg_type_number_t old_stateCnt,
- __unused thread_state_t new_state,
- __unused mach_msg_type_number_t *new_stateCnt)
-{
- return(KERN_INVALID_ARGUMENT);
-}
-
-kern_return_t
-catch_mach_exception_raise_state_identity(
- __unused mach_port_t exception_port,
- __unused mach_port_t thread,
- __unused mach_port_t task,
- __unused exception_type_t exception,
- __unused mach_exception_data_t code,
- __unused mach_msg_type_number_t codeCnt,
- __unused int *flavor,
- __unused thread_state_t old_state,
- __unused mach_msg_type_number_t old_stateCnt,
- __unused thread_state_t new_state,
- __unused mach_msg_type_number_t *new_stateCnt)
-{
- return(KERN_INVALID_ARGUMENT);
-}
-
-
-/*
- * ux_exception translates a mach exception, code and subcode to
- * a signal and u.u_code. Calls machine_exception (machine dependent)
- * to attempt translation first.
- */
-
-static
-void ux_exception(
- int exception,
- mach_exception_code_t code,
- mach_exception_subcode_t subcode,
- int *ux_signal,
- mach_exception_code_t *ux_code)
-{
- /*
- * Try machine-dependent translation first.
- */
- if (machine_exception(exception, code, subcode, ux_signal, ux_code))
- return;
-
- switch(exception) {
-
- case EXC_BAD_ACCESS:
- if (code == KERN_INVALID_ADDRESS)
- *ux_signal = SIGSEGV;
- else
- *ux_signal = SIGBUS;
- break;
-
- case EXC_BAD_INSTRUCTION:
- *ux_signal = SIGILL;
- break;
-
- case EXC_ARITHMETIC:
- *ux_signal = SIGFPE;
- break;
-
- case EXC_EMULATION:
- *ux_signal = SIGEMT;
- break;
-
- case EXC_SOFTWARE:
- switch (code) {
-
- case EXC_UNIX_BAD_SYSCALL:
- *ux_signal = SIGSYS;
- break;
- case EXC_UNIX_BAD_PIPE:
- *ux_signal = SIGPIPE;
- break;
- case EXC_UNIX_ABORT:
- *ux_signal = SIGABRT;
- break;
- case EXC_SOFT_SIGNAL:
- *ux_signal = SIGKILL;
- break;
- }
- break;
-
- case EXC_BREAKPOINT:
- *ux_signal = SIGTRAP;
- break;
- }
-}