Skip to main content

dr_register_restore_state_ex_event

Function dr_register_restore_state_ex_event 

Source
pub unsafe extern "C" fn dr_register_restore_state_ex_event(
    func: Option<unsafe extern "C" fn(drcontext: *mut c_void, restore_memory: bool_, info: *mut dr_restore_state_info_t) -> bool_>,
)
Expand description

Registers a callback function for the machine state restoration event with extended information.

This event is identical to that for dr_register_restore_state_event() with the following exceptions:

  • Additional information is provided in the dr_restore_state_info_t structure, including the pre-translation context (containing the address inside the code cache of the translation point) and the starting address of the containing fragment in the code cache. Certain registers may not contain proper application values in \p info->raw_mcontext. 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 info->raw_mcontext.

  • The callback function returns a boolean indicating the success of the translation. When DR is translating not for a fault but for thread relocation, the \p restore_memory parameter will be false. Such translation can target a meta-instruction that can fault (i.e., it has a non-NULL translation field). For that scenario, a client can choose not to translate. Such instructions do not always require full translation for faults, and allowing translation failure removes the requirement that a client must translate at all such instructions. Note, however, that returning false can cause performance degradation as DR must then resume the thread and attempt to re-suspend it at a safer spot. Clients must return true for translation points in application code in order to avoid catastropic failure to suspend, and should thus identify whether translation points are inside their own instrumentation before returning false. Translation for relocation will never occur in meta instructions, so clients only need to look for meta-may-fault instructions. Clients should never return false when \p restore_memory is true.

  • If multiple callbacks are registered, the first one that returns false will short-circuit event delivery to later callbacks.