pub unsafe extern "C" fn dr_register_exception_event(
func: Option<unsafe extern "C" fn(drcontext: *mut c_void, excpt: *mut dr_exception_t) -> bool_>,
)Expand description
Registers a callback function for the exception event. DR calls \p func whenever the application throws an exception. If \p func returns true, the exception is delivered to the application’s handler along with any changes made to \p excpt->mcontext. If \p func returns false, the faulting instruction in the code cache is re-executed using \p excpt->raw_mcontext, including any changes made to that structure. Clients are expected to use \p excpt->raw_mcontext when using faults as a mechanism to push rare cases out of an instrumentation fastpath that need to examine instrumentation instructions rather than the translated application state and should normally not examine it for application instruction faults. Certain registers may not contain proper application values in \p excpt->raw_mcontext for exceptions in application instructions. Clients are cautioned against relying on any details of code cache layout or register usage beyond instrumentation inserted by the client itself when examining \p excpt->raw_mcontext.
If multiple callbacks are registered, the first one that returns false will short-circuit event delivery to later callbacks.
DR raises this event for exceptions outside the code cache that could come from code generated by a client. For such exceptions, mcontext is not translated and is identical to raw_mcontext.
To skip the passing of the exception to the application’s exception handlers and to send control elsewhere instead, a client can call dr_redirect_execution() from \p func.
\note \p excpt->fault_fragment_info data is provided with \p excpt->raw_mcontext. It is valid only if \p excpt->fault_fragment_info.cache_start_pc is not \p NULL. It provides clients information about the code fragment being executed at the exception interruption point. Clients are cautioned against relying on any details of code cache layout or register usage beyond instrumentation inserted by the client itself. \note Only valid on Windows. \note The function is not called for RaiseException.