mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-13 08:29:43 +00:00
MacOS X exception handling updates:
- Call user handler for KERN_INVALID_ADDRESS too (SIGBUS) - Check for VALID_THREAD_STATE_FLAVOR in forward_exception() - Return KERN_FAILURE if forward_exception() got an unknown behavior code
This commit is contained in:
parent
0af4721cb6
commit
4c225b2705
@ -614,7 +614,7 @@ if (ret != KERN_SUCCESS) { \
|
|||||||
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
|
#define SIGSEGV_SKIP_INSTRUCTION ix86_skip_instruction
|
||||||
#endif
|
#endif
|
||||||
#define SIGSEGV_FAULT_ADDRESS code[1]
|
#define SIGSEGV_FAULT_ADDRESS code[1]
|
||||||
#define SIGSEGV_FAULT_HANDLER_INVOKE(ADDR, IP) ((code[0] == KERN_PROTECTION_FAILURE) ? sigsegv_fault_handler(ADDR, IP) : SIGSEGV_RETURN_FAILURE)
|
#define SIGSEGV_FAULT_HANDLER_INVOKE(ADDR, IP) ((code[0] == KERN_PROTECTION_FAILURE || code[0] == KERN_INVALID_ADDRESS) ? sigsegv_fault_handler(ADDR, IP) : SIGSEGV_RETURN_FAILURE)
|
||||||
#define SIGSEGV_FAULT_HANDLER_ARGLIST mach_port_t thread, exception_data_t code, SIGSEGV_THREAD_STATE_TYPE *state
|
#define SIGSEGV_FAULT_HANDLER_ARGLIST mach_port_t thread, exception_data_t code, SIGSEGV_THREAD_STATE_TYPE *state
|
||||||
#define SIGSEGV_FAULT_HANDLER_ARGS thread, code, &state
|
#define SIGSEGV_FAULT_HANDLER_ARGS thread, code, &state
|
||||||
|
|
||||||
@ -1719,6 +1719,11 @@ forward_exception(mach_port_t thread_port,
|
|||||||
behavior = oldExceptionPorts->behaviors[portIndex];
|
behavior = oldExceptionPorts->behaviors[portIndex];
|
||||||
flavor = oldExceptionPorts->flavors[portIndex];
|
flavor = oldExceptionPorts->flavors[portIndex];
|
||||||
|
|
||||||
|
if (!VALID_THREAD_STATE_FLAVOR(flavor)) {
|
||||||
|
fprintf(stderr, "Invalid thread_state flavor = %d. Not forwarding\n", flavor);
|
||||||
|
return KERN_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
fprintf(stderr, "forwarding exception, port = 0x%x, behaviour = %d, flavor = %d\n", port, behavior, flavor);
|
fprintf(stderr, "forwarding exception, port = 0x%x, behaviour = %d, flavor = %d\n", port, behavior, flavor);
|
||||||
*/
|
*/
|
||||||
@ -1756,6 +1761,7 @@ forward_exception(mach_port_t thread_port,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "forward_exception got unknown behavior\n");
|
fprintf(stderr, "forward_exception got unknown behavior\n");
|
||||||
|
kret = KERN_FAILURE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1765,7 +1771,7 @@ forward_exception(mach_port_t thread_port,
|
|||||||
MACH_CHECK_ERROR (thread_set_state, kret);
|
MACH_CHECK_ERROR (thread_set_state, kret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return KERN_SUCCESS;
|
return kret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user