Skip to main content

drreg_statelessly_restore_app_value

Function drreg_statelessly_restore_app_value 

Source
pub unsafe extern "C" fn drreg_statelessly_restore_app_value(
    drcontext: *mut c_void,
    ilist: *mut instrlist_t,
    reg: reg_id_t,
    where_restore: *mut instr_t,
    where_respill: *mut instr_t,
    restore_needed: *mut bool_,
    respill_needed: *mut bool_,
) -> drreg_status_t
Expand description

This routine is meant for use with instrumentation that uses separate control flow paths, such as a fastpath and a slowpath, where the slowpath needs access to the full application state yet must retain scratch register parity with the fastpath. The application value for \p reg is restored into \p reg at \p where_restore, but internal drreg state is not updated to reflect this. Furthermore, if doing so affects subsequent behavior, such as when \p reg is being used to hold the preserved application value for another register or flags, instructions are inserted at \p where_respill to restore the state, such that \p where_respill will operate correctly whether \p where_restore was executed or not. The optional output parameters \p restore_needed and \p respill_needed are set to indicate whether instructions were inserted at \p where_restore and \p where_respill, respectively.

For correct operation on x86 in the case when aflags are in xax and this routine is invoked to get app value of xax, there shouldn’t be any new reservation between \p where_restore and \p where_respill that may write to a spill slot and clobber the temporary slot used in this routine.

The results from drreg_reservation_info_ex() can be used to predict the behavior of this routine. A restore is needed if !drreg_reserve_info_t.holds_app_value. and drreg_reserve_info_t.app_value_retained. A respill is needed if a restore is needed and drreg_reserve_info_t.opnd is a register.

If \p app_reg is a dead register, #DRREG_ERROR_NO_APP_VALUE may be returned. Set \p conservative in \p drreg_options_t to avoid this error.

If called during drmgr’s insertion phase, \p where must be the current application instruction.

To restore the arithmetic flags, pass #DR_REG_NULL for \p reg.

On ARM, passing \p reg equal to dr_get_stolen_reg() is not supported.

@return whether successful or an error code on failure.