In How do I recover from EXC_BAD_ACCESS?, I figured out how to recover from an EXC_BAD_ACCESS
, but I had the badly accessed pointer stored in a global. Obviously, this won't scale. When I run the code in the iOS Simulator (i386), I can see faultvaddr
register in the Exception State Registers
section of the debugger when inside my catch_exception_raise
function. However, its value isn't the same or close to pointer returned from vm_allocate
. Is there a way to get this value dynamically?
Given the catch_exception_raise
function below, how would I discover the address that caused the EXC_BAD_ACCESS
?
kern_return_t
catch_exception_raise(mach_port_t exception_port,
mach_port_t thread,
mach_port_t task,
exception_type_t exception,
exception_data_t code_vector,
mach_msg_type_number_t code_count)
{
fprintf(stderr, "catch_exception_raise %d\n", exception);
return KERN_SUCCESS;
}