pub unsafe extern "C" fn dr_register_persist_rx(
func_size: Option<unsafe extern "C" fn(drcontext: *mut c_void, perscxt: *mut c_void, file_offs: usize, user_data: *mut *mut c_void) -> usize>,
func_persist: Option<unsafe extern "C" fn(drcontext: *mut c_void, perscxt: *mut c_void, fd: file_t, user_data: *mut c_void) -> bool_>,
func_resurrect: Option<unsafe extern "C" fn(drcontext: *mut c_void, perscxt: *mut c_void, map: *mut *mut byte) -> bool_>,
) -> bool_Expand description
Registers callback functions for storing executable code (outside of normal code blocks) in each persisted cache file. When generating a new persisted cache file, DR first calls \p func_size to obtain the size required for executable code in each persisted cache file. DR subsequently calls \p func_persist to write the actual code. DR ensures that no other thread will execute in between the calls to \p func_size and \p func_persist.
Upon loading a previously-written persisted cache file, DR calls \p func_resurrect to validate and read back in code from the persisted file.
For each callback, the \p perscxt parameter can be passed to the routines dr_persist_start(), dr_persist_size(), and dr_fragment_persistable() to identify the region of code being persisted.
@param[in] func_size The function to call to determine the size needed for persisted code. The \p file_offs parameter indicates the offset from the start of the persisted file where this code will reside (which is needed to calculate patch displacements). The callback can store a void* value into the address specified by \p user_data. This value will be passed to \p func_persist and if a patch callback is registered (see dr_register_persist_patch()) to \p func_patch. The same value will be shared with read-only data callbacks (see dr_register_persist_ro()) and writable data callbacks (see dr_register_persist_rw()). @param[in] func_persist The function to call to write the actual code. Code to be persisted should be written to the file \p fd via dr_write_file(). The code will be read-only when the persisted file is loaded back in for use. The return value of the function indicates success of the write. If the function returns false, the persisted cache file being generated will be abandoned under the assumption of a non-recoverable error. @param[in] func_resurrect The function to call to validate previously written code. The \p map variable points to the mapped-in code that was written at persist time. The return value of the function indicates success of the resurrection. If the function returns false, the persisted cache file being loaded will be abandoned under the assumption of a non-recoverable error. Any validation that the persisted file is suitable for use should be performed by the function prior to any restoration work needed for the code. The \p map address should be updated to point to the end of the persisted data (i.e., on return it should equal its start value plus the size that was passed to dr_register_persist_rx_size()). DR will perform self-consistency checks, including whether the whole pcache is present and that a checksum of at least part of the file matches, prior to calling this callback. Thus, the client can assume that it is not truncated. \note \p func_resurrect may be called during persisted file generation if a persisted file already exists, in order to merge with that file. \return whether successful.