void offline_instru_t::insert_save_pc(void *drcontext, instrlist_t *ilist, instr_t *where, reg_id_t reg_ptr, reg_id_t scratch, int adjust, uint64_t value) { int disp = adjust; #ifdef X64 instrlist_insert_mov_immed_ptrsz(drcontext, (ptr_int_t) value, opnd_create_reg(scratch), ilist, where, NULL, NULL); MINSERT(ilist, where, XINST_CREATE_store(drcontext, OPND_CREATE_MEMPTR(reg_ptr, disp), opnd_create_reg(scratch))); #else instrlist_insert_mov_immed_ptrsz(drcontext, (int)value, opnd_create_reg(scratch), ilist, where, NULL, NULL); MINSERT(ilist, where, XINST_CREATE_store(drcontext, OPND_CREATE_MEMPTR(reg_ptr, disp), opnd_create_reg(scratch))); instrlist_insert_mov_immed_ptrsz(drcontext, (int)(value >> 32), opnd_create_reg(scratch), ilist, where, NULL, NULL); MINSERT(ilist, where, XINST_CREATE_store(drcontext, OPND_CREATE_MEMPTR(reg_ptr, disp + 4), opnd_create_reg(scratch))); #endif }
static void insert_save_pc(void *drcontext, instrlist_t *ilist, instr_t *where, reg_id_t base, reg_id_t scratch, app_pc pc) { instrlist_insert_mov_immed_ptrsz(drcontext, (ptr_int_t)pc, opnd_create_reg(scratch), ilist, where, NULL, NULL); MINSERT(ilist, where, XINST_CREATE_store(drcontext, OPND_CREATE_MEMPTR(base, offsetof(mem_ref_t, addr)), opnd_create_reg(scratch))); }
static void insert_save_addr(void *drcontext, instrlist_t *ilist, instr_t *where, opnd_t ref, reg_id_t reg_ptr, reg_id_t reg_addr) { bool ok; /* we use reg_ptr as scratch to get addr */ ok = drutil_insert_get_mem_addr(drcontext, ilist, where, ref, reg_addr, reg_ptr); DR_ASSERT(ok); insert_load_buf_ptr(drcontext, ilist, where, reg_ptr); MINSERT(ilist, where, XINST_CREATE_store(drcontext, OPND_CREATE_MEMPTR(reg_ptr, offsetof(mem_ref_t, addr)), opnd_create_reg(reg_addr))); }
void offline_instru_t::insert_save_addr(void *drcontext, instrlist_t *ilist, instr_t *where, reg_id_t reg_ptr, reg_id_t reg_addr, int adjust, opnd_t ref) { bool ok; int disp = adjust; if (opnd_uses_reg(ref, reg_ptr)) drreg_get_app_value(drcontext, ilist, where, reg_ptr, reg_ptr); if (opnd_uses_reg(ref, reg_addr)) drreg_get_app_value(drcontext, ilist, where, reg_addr, reg_addr); // We use reg_ptr as scratch to get the address. ok = drutil_insert_get_mem_addr(drcontext, ilist, where, ref, reg_addr, reg_ptr); DR_ASSERT(ok); // drutil_insert_get_mem_addr may clobber reg_ptr, so we need to re-load reg_ptr. // XXX i#2001: determine whether we have to and avoid it when we don't. insert_load_buf_ptr(drcontext, ilist, where, reg_ptr); MINSERT(ilist, where, XINST_CREATE_store(drcontext, OPND_CREATE_MEMPTR(reg_ptr, disp), opnd_create_reg(reg_addr))); // We allow either 0 or all 1's as the type so no need to write anything else. }