static int replacewith2(int *x) { ptr_int_t param = dr_read_saved_reg(dr_get_current_drcontext(), DRWRAP_REPLACE_NATIVE_DATA_SLOT); CHECK(param == DRWRAP_NATIVE_PARAM, "native param wrong"); /* Test dr_call_on_clean_stack() */ *x = (int)(ptr_uint_t) dr_call_on_clean_stack(dr_get_current_drcontext(), (void *(*)(void)) on_clean_stack, (void *)(ptr_uint_t)500, (void *)(ptr_uint_t)400, (void *)(ptr_uint_t)50, (void *)(ptr_uint_t)40, (void *)(ptr_uint_t)4, (void *)(ptr_uint_t)3, (void *)(ptr_uint_t)1, (void *)(ptr_uint_t)1); /* We must call this prior to returning, to avoid going native. * This also serves as a test of dr_redirect_native_target() * as drwrap's continuation relies on that. * Because drwrap performs a bunch of flushes, it tests * the unlink/relink of the client ibl xfer gencode. * * XXX: could also verify that retaddr is app's, and that * traces continue on the other side. The latter, certainly, * is very difficult to write a simple test for. */ drwrap_replace_native_fini(dr_get_current_drcontext()); return 1; }
/** Restores state after guard page hit. */ void restore_state(void* ctx, dr_mcontext_t* mcontext, struct tag_info_t* tag_info) { struct instr_info_t* instr_info; instr_info = &tag_info->instr_info; if(instr_info->restore_tls_reg) { reg_set_value(instr_info->tls_reg, mcontext, dr_read_saved_reg(ctx, SPILL_SLOT_2)); } if(instr_info->restore_current_reg) { reg_set_value(instr_info->current_reg, mcontext, dr_read_saved_reg(ctx, SPILL_SLOT_3)); } }
static int replace_callsite(int *x) { ptr_int_t param = dr_read_saved_reg(dr_get_current_drcontext(), DRWRAP_REPLACE_NATIVE_DATA_SLOT); CHECK(param == DRWRAP_NATIVE_PARAM, "native param wrong"); *x = 777; drwrap_replace_native_fini(dr_get_current_drcontext()); return 2; }