dr_ir_instr.h File Reference

Functions to create and manipulate instructions. More...

Data Structures

struct  _dr_instr_label_data_t
 
struct  instr_noalloc_t
 

Macros

#define PREFIX_LOCK   0x01
 
#define PREFIX_JCC_NOT_TAKEN   0x02
 
#define PREFIX_JCC_TAKEN   0x04
 
#define PREFIX_XACQUIRE   0x08
 
#define PREFIX_XRELEASE   0x10
 
#define EFLAGS_READ_CF   0x00000001
 
#define EFLAGS_READ_PF   0x00000002
 
#define EFLAGS_READ_AF   0x00000004
 
#define EFLAGS_READ_ZF   0x00000008
 
#define EFLAGS_READ_SF   0x00000010
 
#define EFLAGS_READ_TF   0x00000020
 
#define EFLAGS_READ_IF   0x00000040
 
#define EFLAGS_READ_DF   0x00000080
 
#define EFLAGS_READ_OF   0x00000100
 
#define EFLAGS_READ_NT   0x00000200
 
#define EFLAGS_READ_RF   0x00000400
 
#define EFLAGS_WRITE_CF   0x00000800
 
#define EFLAGS_WRITE_PF   0x00001000
 
#define EFLAGS_WRITE_AF   0x00002000
 
#define EFLAGS_WRITE_ZF   0x00004000
 
#define EFLAGS_WRITE_SF   0x00008000
 
#define EFLAGS_WRITE_TF   0x00010000
 
#define EFLAGS_WRITE_IF   0x00020000
 
#define EFLAGS_WRITE_DF   0x00040000
 
#define EFLAGS_WRITE_OF   0x00080000
 
#define EFLAGS_WRITE_NT   0x00100000
 
#define EFLAGS_WRITE_RF   0x00200000
 
#define EFLAGS_READ_AC   0x00400000
 
#define EFLAGS_WRITE_AC   0x00800000
 
#define EFLAGS_READ_ALL   0x004007ff
 
#define EFLAGS_READ_NON_PRED   EFLAGS_READ_ALL
 
#define EFLAGS_WRITE_ALL   0x00bff800
 
#define EFLAGS_READ_6   0x0000011f
 
#define EFLAGS_WRITE_6   0x0008f800
 
#define EFLAGS_READ_ARITH   EFLAGS_READ_6
 
#define EFLAGS_WRITE_ARITH   EFLAGS_WRITE_6
 
#define EFLAGS_WRITE_TO_READ(x)
 
#define EFLAGS_READ_TO_WRITE(x)
 

Typedefs

typedef enum _dr_encoding_hint_type_t dr_encoding_hint_type_t
 
typedef struct _dr_instr_label_data_t dr_instr_label_data_t
 
typedef void(* instr_label_callback_t) (void *drcontext, instr_t *instr)
 
typedef enum _dr_opnd_query_flags_t dr_opnd_query_flags_t
 
typedef struct instr_noalloc_t instr_noalloc_t
 
typedef enum _dr_pred_trigger_t dr_pred_trigger_t
 

Enumerations

enum  _dr_encoding_hint_type_t {
  DR_ENCODING_HINT_NONE = 0x0,
  DR_ENCODING_HINT_X86_EVEX = 0x1
}
 
enum  _dr_opnd_query_flags_t {
  DR_QUERY_INCLUDE_COND_DSTS = 0x01,
  DR_QUERY_INCLUDE_COND_SRCS = 0x02,
  DR_QUERY_DEFAULT = DR_QUERY_INCLUDE_COND_SRCS,
  DR_QUERY_INCLUDE_ALL = (DR_QUERY_INCLUDE_COND_DSTS | DR_QUERY_INCLUDE_COND_SRCS)
}
 
enum  _dr_pred_trigger_t {
  DR_PRED_TRIGGER_NOPRED,
  DR_PRED_TRIGGER_MATCH,
  DR_PRED_TRIGGER_MISMATCH,
  DR_PRED_TRIGGER_UNKNOWN,
  DR_PRED_TRIGGER_INVALID
}
 
enum  dr_instr_category_t {
  DR_INSTR_CATEGORY_UNCATEGORIZED = 0x0,
  DR_INSTR_CATEGORY_FP = 0x1,
  DR_INSTR_CATEGORY_LOAD = 0x2,
  DR_INSTR_CATEGORY_STORE = 0x4,
  DR_INSTR_CATEGORY_BRANCH = 0x8,
  DR_INSTR_CATEGORY_SIMD = 0x10,
  DR_INSTR_CATEGORY_STATE = 0x20,
  DR_INSTR_CATEGORY_MOVE = 0x40,
  DR_INSTR_CATEGORY_CONVERT = 0x80,
  DR_INSTR_CATEGORY_MATH = 0x100,
  DR_INSTR_CATEGORY_OTHER = 0x200
}
 
enum  dr_fp_type_t {
  DR_FP_STATE,
  DR_FP_MOVE,
  DR_FP_CONVERT,
  DR_FP_MATH
}
 
enum  {
  EFLAGS_CF = 0x00000001,
  EFLAGS_PF = 0x00000004,
  EFLAGS_AF = 0x00000010,
  EFLAGS_ZF = 0x00000040,
  EFLAGS_SF = 0x00000080,
  EFLAGS_DF = 0x00000400,
  EFLAGS_OF = 0x00000800,
  EFLAGS_ARITH = EFLAGS_CF | EFLAGS_PF | EFLAGS_AF | EFLAGS_ZF | EFLAGS_SF | EFLAGS_OF
}
 

Functions

DR_API instr_tinstr_create (void *drcontext)
 
DR_API void instr_init (void *drcontext, instr_t *instr)
 
DR_API void instr_noalloc_init (void *drcontext, instr_noalloc_t *instr)
 
DR_API INSTR_INLINE instr_tinstr_from_noalloc (instr_noalloc_t *noalloc)
 
DR_API void instr_free (void *drcontext, instr_t *instr)
 
DR_API void instr_reset (void *drcontext, instr_t *instr)
 
DR_API void instr_reuse (void *drcontext, instr_t *instr)
 
DR_API void instr_destroy (void *drcontext, instr_t *instr)
 
DR_API INSTR_INLINE instr_tinstr_get_next (instr_t *instr)
 
DR_API INSTR_INLINE instr_tinstr_get_next_app (instr_t *instr)
 
DR_API INSTR_INLINE instr_tinstr_get_prev (instr_t *instr)
 
DR_API INSTR_INLINE instr_tinstr_get_prev_app (instr_t *instr)
 
DR_API INSTR_INLINE void instr_set_next (instr_t *instr, instr_t *next)
 
DR_API INSTR_INLINE void instr_set_prev (instr_t *instr, instr_t *prev)
 
DR_API INSTR_INLINE void * instr_get_note (instr_t *instr)
 
DR_API INSTR_INLINE void instr_set_note (instr_t *instr, void *value)
 
DR_API app_pc instr_get_branch_target_pc (instr_t *cti_instr)
 
DR_API void instr_set_branch_target_pc (instr_t *cti_instr, app_pc pc)
 
DR_API bool instr_is_exit_cti (instr_t *instr)
 
DR_API bool instr_is_interrupt (instr_t *instr)
 
DR_API INSTR_INLINE bool instr_is_app (instr_t *instr)
 
DR_API void instr_set_app (instr_t *instr)
 
DR_API INSTR_INLINE bool instr_is_meta (instr_t *instr)
 
DR_API void instr_set_meta (instr_t *instr)
 
DR_API INSTR_INLINE bool instr_ok_to_mangle (instr_t *instr)
 
DR_API void instr_set_ok_to_mangle (instr_t *instr, bool val)
 
DR_API void instr_set_meta_no_translation (instr_t *instr)
 
INSTR_INLINE_INTERNALLY DR_API bool instr_ok_to_emit (instr_t *instr)
 
DR_API void instr_set_ok_to_emit (instr_t *instr, bool val)
 
DR_API int instr_length (void *drcontext, instr_t *instr)
 
DR_API int instr_mem_usage (instr_t *instr)
 
DR_API instr_tinstr_clone (void *drcontext, instr_t *orig)
 
DR_API instr_tinstr_build (void *drcontext, int opcode, int num_dsts, int num_srcs)
 
DR_API instr_tinstr_build_bits (void *drcontext, int opcode, uint num_bytes)
 
DR_API bool instr_valid (instr_t *instr)
 
DR_API app_pc instr_get_app_pc (instr_t *instr)
 
DR_API int instr_get_opcode (instr_t *instr)
 
DR_API uint instr_get_category (instr_t *instr)
 
DR_API size_t instr_get_offset (instr_t *instr)
 
DR_API void instr_set_opcode (instr_t *instr, int opcode)
 
DR_API void instr_set_category (instr_t *instr, uint category)
 
DR_API INSTR_INLINE int instr_num_srcs (instr_t *instr)
 
DR_API INSTR_INLINE int instr_num_dsts (instr_t *instr)
 
DR_API void instr_set_num_opnds (void *drcontext, instr_t *instr, int num_dsts, int num_srcs)
 
DR_API opnd_t instr_get_src (instr_t *instr, uint pos)
 
DR_API opnd_t instr_get_dst (instr_t *instr, uint pos)
 
DR_API void instr_set_src (instr_t *instr, uint pos, opnd_t opnd)
 
DR_API void instr_set_dst (instr_t *instr, uint pos, opnd_t opnd)
 
DR_API void instr_remove_srcs (void *drcontext, instr_t *instr, uint start, uint end)
 
DR_API void instr_remove_dsts (void *drcontext, instr_t *instr, uint start, uint end)
 
DR_API opnd_t instr_get_target (instr_t *cti_instr)
 
DR_API void instr_set_target (instr_t *cti_instr, opnd_t target)
 
DR_API bool instr_is_opnd_store_source (instr_t *store_instr, int source_ordinal)
 
INSTR_INLINE_INTERNALLY DR_API bool instr_operands_valid (instr_t *instr)
 
DR_API void instr_set_operands_valid (instr_t *instr, bool valid)
 
DR_API bool instr_opcode_valid (instr_t *instr)
 
DR_API uint instr_get_eflags (instr_t *instr, dr_opnd_query_flags_t flags)
 
DR_API uint instr_get_opcode_eflags (int opcode)
 
DR_API uint instr_get_arith_flags (instr_t *instr, dr_opnd_query_flags_t flags)
 
DR_API void instr_set_raw_bits (instr_t *instr, byte *addr, uint length)
 
DR_API void instr_set_raw_bits_valid (instr_t *instr, bool valid)
 
INSTR_INLINE_INTERNALLY DR_API bool instr_raw_bits_valid (instr_t *instr)
 
INSTR_INLINE_INTERNALLY DR_API bool instr_has_allocated_bits (instr_t *instr)
 
INSTR_INLINE_INTERNALLY DR_API bool instr_needs_encoding (instr_t *instr)
 
DR_API bool instr_is_meta_may_fault (instr_t *instr)
 
DR_API void instr_set_meta_may_fault (instr_t *instr, bool val)
 
DR_API void instr_allocate_raw_bits (void *drcontext, instr_t *instr, uint num_bytes)
 
DR_API instr_tinstr_set_translation (instr_t *instr, app_pc addr)
 
DR_API void instr_make_persistent (void *drcontext, instr_t *instr)
 
DR_API byte * instr_get_raw_bits (instr_t *instr)
 
DR_API void instr_free_raw_bits (void *drcontext, instr_t *instr)
 
DR_API byte instr_get_raw_byte (instr_t *instr, uint pos)
 
DR_API void instr_set_raw_byte (instr_t *instr, uint pos, byte byte)
 
DR_API void instr_set_raw_bytes (instr_t *instr, byte *start, uint num_bytes)
 
DR_API void instr_set_raw_word (instr_t *instr, uint pos, uint word)
 
DR_API uint instr_get_raw_word (instr_t *instr, uint pos)
 
DR_API instr_tinstr_set_prefix_flag (instr_t *instr, uint prefix)
 
DR_API bool instr_get_prefix_flag (instr_t *instr, uint prefix)
 
DR_API bool instr_is_predicated (instr_t *instr)
 
DR_API dr_pred_type_t instr_get_predicate (instr_t *instr)
 
const DR_API char * instr_predicate_name (dr_pred_type_t pred)
 
DR_API dr_pred_type_t instr_invert_predicate (dr_pred_type_t pred)
 
DR_API uint instr_it_block_get_count (instr_t *it_instr)
 
DR_API dr_pred_type_t instr_it_block_get_pred (instr_t *it_instr, uint index)
 
DR_API bool instr_it_block_compute_immediates (dr_pred_type_t pred0, dr_pred_type_t pred1, dr_pred_type_t pred2, dr_pred_type_t pred3, byte *firstcond_out, byte *mask_out)
 
DR_API instr_tinstr_it_block_create (void *drcontext, dr_pred_type_t pred0, dr_pred_type_t pred1, dr_pred_type_t pred2, dr_pred_type_t pred3)
 
DR_API bool instr_is_exclusive_load (instr_t *instr)
 
DR_API bool instr_is_exclusive_store (instr_t *instr)
 
DR_API bool instr_is_scatter (instr_t *instr)
 
DR_API bool instr_is_gather (instr_t *instr)
 
DR_API bool instr_predicate_is_cond (dr_pred_type_t pred)
 
DR_API instr_tinstr_set_predicate (instr_t *instr, dr_pred_type_t pred)
 
DR_API dr_pred_trigger_t instr_predicate_triggered (instr_t *instr, dr_mcontext_t *mc)
 
DR_API void instr_set_x86_mode (instr_t *instr, bool x86)
 
DR_API bool instr_get_x86_mode (instr_t *instr)
 
DR_API bool instr_set_isa_mode (instr_t *instr, dr_isa_mode_t mode)
 
DR_API dr_isa_mode_t instr_get_isa_mode (instr_t *instr)
 
DR_API instr_tinstr_set_encoding_hint (instr_t *instr, dr_encoding_hint_type_t hint)
 
DR_API bool instr_has_encoding_hint (instr_t *instr, dr_encoding_hint_type_t hint)
 
DR_API void instr_shrink_to_16_bits (instr_t *instr)
 
DR_API void instr_shrink_to_32_bits (instr_t *instr)
 
DR_API bool instr_uses_reg (instr_t *instr, reg_id_t reg)
 
DR_API bool instr_uses_fp_reg (instr_t *instr)
 
DR_API bool instr_reg_in_src (instr_t *instr, reg_id_t reg)
 
DR_API bool instr_reg_in_dst (instr_t *instr, reg_id_t reg)
 
DR_API bool instr_writes_to_reg (instr_t *instr, reg_id_t reg, dr_opnd_query_flags_t flags)
 
DR_API bool instr_reads_from_reg (instr_t *instr, reg_id_t reg, dr_opnd_query_flags_t flags)
 
DR_API bool instr_writes_to_exact_reg (instr_t *instr, reg_id_t reg, dr_opnd_query_flags_t flags)
 
DR_API bool instr_reads_from_exact_reg (instr_t *instr, reg_id_t reg, dr_opnd_query_flags_t flags)
 
DR_API bool instr_replace_src_opnd (instr_t *instr, opnd_t old_opnd, opnd_t new_opnd)
 
DR_API bool instr_replace_reg_resize (instr_t *instr, reg_id_t old_reg, reg_id_t new_reg)
 
DR_API bool instr_same (instr_t *instr1, instr_t *instr2)
 
DR_API bool instr_reads_memory (instr_t *instr)
 
DR_API bool instr_writes_memory (instr_t *instr)
 
DR_API bool instr_zeroes_ymmh (instr_t *instr)
 
DR_API bool instr_zeroes_zmmh (instr_t *instr)
 
DR_API bool instr_is_xsave (instr_t *instr)
 
DR_API bool instr_is_xrstor (instr_t *instr)
 
DR_API bool instr_get_rel_data_or_instr_target (instr_t *instr, app_pc *target)
 
DR_API bool instr_has_rel_addr_reference (instr_t *instr)
 
DR_API bool instr_get_rel_addr_target (instr_t *instr, app_pc *target)
 
DR_API int instr_get_rel_addr_dst_idx (instr_t *instr)
 
DR_API int instr_get_rel_addr_src_idx (instr_t *instr)
 
DR_API app_pc instr_compute_address (instr_t *instr, dr_mcontext_t *mc)
 
DR_API bool instr_compute_address_ex (instr_t *instr, dr_mcontext_t *mc, uint index, DR_PARAM_OUT app_pc *addr, DR_PARAM_OUT bool *write)
 
DR_API bool instr_compute_address_ex_pos (instr_t *instr, dr_mcontext_t *mc, uint index, DR_PARAM_OUT app_pc *addr, DR_PARAM_OUT bool *is_write, DR_PARAM_OUT uint *pos)
 
DR_API uint instr_memory_reference_size (instr_t *instr)
 
DR_API uint instr_num_memory_read_access (instr_t *instr)
 
DR_API uint instr_num_memory_write_access (instr_t *instr)
 
DR_API dr_instr_label_data_tinstr_get_label_data_area (instr_t *instr)
 
DR_API void instr_set_label_callback (instr_t *instr, instr_label_callback_t func)
 
DR_API void instr_clear_label_callback (instr_t *instr)
 
DR_API bool instr_is_mov (instr_t *instr)
 
DR_API bool instr_is_call (instr_t *instr)
 
DR_API bool instr_is_call_direct (instr_t *instr)
 
DR_API bool instr_is_near_call_direct (instr_t *instr)
 
DR_API bool instr_is_call_indirect (instr_t *instr)
 
DR_API bool instr_is_return (instr_t *instr)
 
DR_API bool instr_is_cti (instr_t *instr)
 
DR_API bool instr_is_cti_short (instr_t *instr)
 
DR_API bool instr_is_cti_loop (instr_t *instr)
 
DR_API bool instr_is_cti_short_rewrite (instr_t *instr, byte *pc)
 
DR_API bool instr_is_cbr (instr_t *instr)
 
DR_API bool instr_is_mbr (instr_t *instr)
 
DR_API bool instr_is_ubr (instr_t *instr)
 
DR_API bool instr_is_near_ubr (instr_t *instr)
 
DR_API bool instr_is_far_cti (instr_t *instr)
 
DR_API bool instr_is_far_abs_cti (instr_t *instr)
 
DR_API bool instr_is_syscall (instr_t *instr)
 
DR_API bool instr_is_wow64_syscall (instr_t *instr)
 
DR_API bool instr_is_prefetch (instr_t *instr)
 
DR_API bool instr_is_mov_constant (instr_t *instr, ptr_int_t *value)
 
DR_API bool instr_is_floating (instr_t *instr)
 
DR_API bool instr_is_string_op (instr_t *instr)
 
DR_API bool instr_is_rep_string_op (instr_t *instr)
 
const DR_API char * instr_get_category_name (dr_instr_category_t category)
 
DR_API bool instr_is_floating_type (instr_t *instr, dr_instr_category_t *type)
 
DR_API bool instr_is_floating_ex (instr_t *instr, dr_fp_type_t *type)
 
DR_API bool instr_is_mmx (instr_t *instr)
 
DR_API bool instr_is_opmask (instr_t *instr)
 
DR_API bool instr_is_sse (instr_t *instr)
 
DR_API bool instr_is_sse2 (instr_t *instr)
 
DR_API bool instr_is_sse_or_sse2 (instr_t *instr)
 
DR_API bool instr_is_3DNow (instr_t *instr)
 
DR_API bool instr_is_sse3 (instr_t *instr)
 
DR_API bool instr_is_ssse3 (instr_t *instr)
 
DR_API bool instr_is_sse41 (instr_t *instr)
 
DR_API bool instr_is_sse42 (instr_t *instr)
 
DR_API bool instr_is_sse4A (instr_t *instr)
 
DR_API bool instr_is_mov_imm_to_tos (instr_t *instr)
 
DR_API bool instr_is_label (instr_t *instr)
 
DR_API bool instr_is_undefined (instr_t *instr)
 
DR_API int instr_get_interrupt_number (instr_t *instr)
 
DR_API void instr_invert_cbr (instr_t *instr)
 
DR_API instr_tinstr_convert_short_meta_jmp_to_long (void *drcontext, instrlist_t *ilist, instr_t *instr)
 
DR_API opnd_size_t instr_get_operation_size (instr_t *instr)
 
DR_API void instr_set_operation_size (instr_t *instr, opnd_size_t operation_size)
 
DR_API void instr_convert_to_isa_regdeps (void *drcontext, instr_t *instr_real_isa, instr_t *instr_regdeps_isa)
 
DR_API bool instr_jcc_taken (instr_t *instr, reg_t eflags)
 
DR_API int instr_cmovcc_to_jcc (int cmovcc_opcode)
 
DR_API bool instr_cmovcc_triggered (instr_t *instr, reg_t eflags)
 
DR_API bool instr_is_nop (instr_t *instr)
 
DR_API instr_tinstr_create_0dst_0src (void *drcontext, int opcode)
 
DR_API instr_tinstr_create_0dst_1src (void *drcontext, int opcode, opnd_t src)
 
DR_API instr_tinstr_create_0dst_2src (void *drcontext, int opcode, opnd_t src1, opnd_t src2)
 
DR_API instr_tinstr_create_0dst_3src (void *drcontext, int opcode, opnd_t src1, opnd_t src2, opnd_t src3)
 
DR_API instr_tinstr_create_0dst_4src (void *drcontext, int opcode, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4)
 
DR_API instr_tinstr_create_1dst_0src (void *drcontext, int opcode, opnd_t dst)
 
DR_API instr_tinstr_create_1dst_1src (void *drcontext, int opcode, opnd_t dst, opnd_t src)
 
DR_API instr_tinstr_create_1dst_2src (void *drcontext, int opcode, opnd_t dst, opnd_t src1, opnd_t src2)
 
DR_API instr_tinstr_create_1dst_3src (void *drcontext, int opcode, opnd_t dst, opnd_t src1, opnd_t src2, opnd_t src3)
 
DR_API instr_tinstr_create_1dst_4src (void *drcontext, int opcode, opnd_t dst, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4)
 
DR_API instr_tinstr_create_1dst_5src (void *drcontext, int opcode, opnd_t dst, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5)
 
DR_API instr_tinstr_create_1dst_6src (void *drcontext, int opcode, opnd_t dst, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5, opnd_t src6)
 
DR_API instr_tinstr_create_2dst_0src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2)
 
DR_API instr_tinstr_create_2dst_1src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t src)
 
DR_API instr_tinstr_create_2dst_2src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t src1, opnd_t src2)
 
DR_API instr_tinstr_create_2dst_3src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t src1, opnd_t src2, opnd_t src3)
 
DR_API instr_tinstr_create_2dst_4src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4)
 
DR_API instr_tinstr_create_2dst_5src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5)
 
DR_API instr_tinstr_create_3dst_0src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3)
 
DR_API instr_tinstr_create_3dst_1src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t src1)
 
DR_API instr_tinstr_create_3dst_2src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t src1, opnd_t src2)
 
DR_API instr_tinstr_create_3dst_3src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t src1, opnd_t src2, opnd_t src3)
 
DR_API instr_tinstr_create_3dst_4src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4)
 
DR_API instr_tinstr_create_3dst_5src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5)
 
DR_API instr_tinstr_create_3dst_6src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5, opnd_t src6)
 
DR_API instr_tinstr_create_4dst_1src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t src)
 
DR_API instr_tinstr_create_4dst_2src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t src1, opnd_t src2)
 
DR_API instr_tinstr_create_4dst_3src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t src1, opnd_t src2, opnd_t src3)
 
DR_API instr_tinstr_create_4dst_4src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4)
 
DR_API instr_tinstr_create_4dst_5src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5)
 
DR_API instr_tinstr_create_4dst_6src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5, opnd_t src6)
 
DR_API instr_tinstr_create_4dst_7src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5, opnd_t src6, opnd_t src7)
 
DR_API instr_tinstr_create_5dst_3src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t dst5, opnd_t src1, opnd_t src2, opnd_t src3)
 
DR_API instr_tinstr_create_5dst_4src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t dst5, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4)
 
DR_API instr_tinstr_create_5dst_5src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t dst5, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5)
 
DR_API instr_tinstr_create_5dst_8src (void *drcontext, int opcode, opnd_t dst1, opnd_t dst2, opnd_t dst3, opnd_t dst4, opnd_t dst5, opnd_t src1, opnd_t src2, opnd_t src3, opnd_t src4, opnd_t src5, opnd_t src6, opnd_t src7, opnd_t src8)
 
DR_API instr_tinstr_create_Ndst_Msrc_varsrc (void *drcontext, int opcode, uint fixed_dsts, uint fixed_srcs, uint var_srcs, uint var_ord,...)
 
DR_API instr_tinstr_create_Ndst_Msrc_vardst (void *drcontext, int opcode, uint fixed_dsts, uint fixed_srcs, uint var_dsts, uint var_ord,...)
 
DR_API instr_tinstr_create_popa (void *drcontext)
 
DR_API instr_tinstr_create_pusha (void *drcontext)
 
DR_API bool instr_is_reg_spill_or_restore (void *drcontext, instr_t *instr, bool *tls DR_PARAM_OUT, bool *spill DR_PARAM_OUT, reg_id_t *reg DR_PARAM_OUT, uint *offs DR_PARAM_OUT)
 

Detailed Description

Functions to create and manipulate instructions.

Macro Definition Documentation

◆ EFLAGS_READ_6

#define EFLAGS_READ_6   0x0000011f

Reads all 6 arithmetic flags (CF, PF, AF, ZF, SF, OF).

◆ EFLAGS_READ_AC

#define EFLAGS_READ_AC   0x00400000

Reads AC (Alignment Check Flag).

◆ EFLAGS_READ_AF

#define EFLAGS_READ_AF   0x00000004

Reads AF (Auxiliary Carry Flag).

◆ EFLAGS_READ_ALL

#define EFLAGS_READ_ALL   0x004007ff

Reads all flags.

◆ EFLAGS_READ_ARITH

#define EFLAGS_READ_ARITH   EFLAGS_READ_6

Platform-independent macro for reads all arithmetic flags.

◆ EFLAGS_READ_CF

#define EFLAGS_READ_CF   0x00000001

Reads CF (Carry Flag).

◆ EFLAGS_READ_DF

#define EFLAGS_READ_DF   0x00000080

Reads DF (Direction Flag).

◆ EFLAGS_READ_IF

#define EFLAGS_READ_IF   0x00000040

Reads IF (Interrupt Enable Flag).

◆ EFLAGS_READ_NON_PRED

#define EFLAGS_READ_NON_PRED   EFLAGS_READ_ALL

Flags not read by predicates.

◆ EFLAGS_READ_NT

#define EFLAGS_READ_NT   0x00000200

Reads NT (Nested Task).

◆ EFLAGS_READ_OF

#define EFLAGS_READ_OF   0x00000100

Reads OF (Overflow Flag).

◆ EFLAGS_READ_PF

#define EFLAGS_READ_PF   0x00000002

Reads PF (Parity Flag).

◆ EFLAGS_READ_RF

#define EFLAGS_READ_RF   0x00000400

Reads RF (Resume Flag).

◆ EFLAGS_READ_SF

#define EFLAGS_READ_SF   0x00000010

Reads SF (Sign Flag).

◆ EFLAGS_READ_TF

#define EFLAGS_READ_TF   0x00000020

Reads TF (Trap Flag).

◆ EFLAGS_READ_TO_WRITE

#define EFLAGS_READ_TO_WRITE (   x)
Value:
((((x) & ((EFLAGS_READ_ALL) & ~(EFLAGS_READ_AC))) << 11) | \
(((x) & (EFLAGS_READ_AC)) << 1))

Converts an EFLAGS_READ_* value to the corresponding EFLAGS_WRITE_* value.

◆ EFLAGS_READ_ZF

#define EFLAGS_READ_ZF   0x00000008

Reads ZF (Zero Flag).

◆ EFLAGS_WRITE_6

#define EFLAGS_WRITE_6   0x0008f800

Writes all 6 arithmetic flags (CF, PF, AF, ZF, SF, OF).

◆ EFLAGS_WRITE_AC

#define EFLAGS_WRITE_AC   0x00800000

Writes AC (Alignment Check Flag).

◆ EFLAGS_WRITE_AF

#define EFLAGS_WRITE_AF   0x00002000

Writes AF (Auxiliary Carry Flag).

◆ EFLAGS_WRITE_ALL

#define EFLAGS_WRITE_ALL   0x00bff800

Writes all flags.

◆ EFLAGS_WRITE_ARITH

#define EFLAGS_WRITE_ARITH   EFLAGS_WRITE_6

Platform-independent macor for writes all arithmetic flags.

◆ EFLAGS_WRITE_CF

#define EFLAGS_WRITE_CF   0x00000800

Writes CF (Carry Flag).

◆ EFLAGS_WRITE_DF

#define EFLAGS_WRITE_DF   0x00040000

Writes DF (Direction Flag).

◆ EFLAGS_WRITE_IF

#define EFLAGS_WRITE_IF   0x00020000

Writes IF (Interrupt Enable Flag).

◆ EFLAGS_WRITE_NT

#define EFLAGS_WRITE_NT   0x00100000

Writes NT (Nested Task).

◆ EFLAGS_WRITE_OF

#define EFLAGS_WRITE_OF   0x00080000

Writes OF (Overflow Flag).

◆ EFLAGS_WRITE_PF

#define EFLAGS_WRITE_PF   0x00001000

Writes PF (Parity Flag).

◆ EFLAGS_WRITE_RF

#define EFLAGS_WRITE_RF   0x00200000

Writes RF (Resume Flag).

◆ EFLAGS_WRITE_SF

#define EFLAGS_WRITE_SF   0x00008000

Writes SF (Sign Flag).

◆ EFLAGS_WRITE_TF

#define EFLAGS_WRITE_TF   0x00010000

Writes TF (Trap Flag).

◆ EFLAGS_WRITE_TO_READ

#define EFLAGS_WRITE_TO_READ (   x)
Value:
((((x) & ((EFLAGS_WRITE_ALL) & ~(EFLAGS_WRITE_AC))) >> 11) | \
(((x) & (EFLAGS_WRITE_AC)) >> 1))

Converts an EFLAGS_WRITE_* value to the corresponding EFLAGS_READ_* value.

◆ EFLAGS_WRITE_ZF

#define EFLAGS_WRITE_ZF   0x00004000

Writes ZF (Zero Flag).

◆ PREFIX_JCC_NOT_TAKEN

#define PREFIX_JCC_NOT_TAKEN   0x02

Branch hint: conditional branch is taken.

◆ PREFIX_JCC_TAKEN

#define PREFIX_JCC_TAKEN   0x04

Branch hint: conditional branch is not taken.

◆ PREFIX_LOCK

#define PREFIX_LOCK   0x01

Makes the instruction's memory accesses atomic.

◆ PREFIX_XACQUIRE

#define PREFIX_XACQUIRE   0x08

Transaction hint: start lock elision.

◆ PREFIX_XRELEASE

#define PREFIX_XRELEASE   0x10

Transaction hint: end lock elision.

Typedef Documentation

◆ dr_encoding_hint_type_t

Specifies hints for how an instruction should be encoded if redundant encodings are available. Currently, we provide a hint for x86 evex encoded instructions. It can be used to encode an instruction in its evex form instead of its vex format (xref #3339).

◆ dr_instr_label_data_t

Data slots available in a label (instr_create_label()) instruction for storing client-controlled data. Accessible via instr_get_label_data_area().

◆ dr_opnd_query_flags_t

Bitmask values passed as flags to routines that ask about whether operands and condition codes are read or written. These flags determine how to treat conditionally executed instructions. As a special case, the addressing registers inside a destination memory operand are covered by DR_QUERY_INCLUDE_COND_SRCS rather than DR_QUERY_INCLUDE_COND_DSTS.

◆ dr_pred_trigger_t

This type holds the return values for instr_predicate_triggered().

◆ instr_label_callback_t

typedef void(* instr_label_callback_t) (void *drcontext, instr_t *instr)

Label instruction callback function. Set by instr_set_label_callback() and called when the label is freed. instr is the label instruction allowing the caller to free the label's auxiliary data.

◆ instr_noalloc_t

A version of instr_t which guarantees to not use heap allocation for regular decoding and encoding. It inlines all the possible operands and encoding space inside the structure. Some operations could still use heap if custom label data is used to point at heap-allocated structures through extension libraries or custom code.

The instr_from_noalloc() function should be used to obtain an instr_t pointer for passing to API functions:

instr_noalloc_init(dcontext, &noalloc);
instr_t *instr = instr_from_noalloc(&noalloc);
pc = decode(dcontext, ptr, instr);

No freeing is required. To re-use the same structure, instr_reset() can be called.

Some operations are not supported on this instruction format:

This format does not support caching encodings, so it is less efficient for encoding. It is intended for use when decoding in a signal handler or other locations where heap allocation is unsafe.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

The actual bits in the eflags register that we care about:

  11 10  9  8  7  6  5  4  3  2  1  0
  OF DF IF TF SF ZF  0 AF  0 PF  1 CF  
Enumerator
EFLAGS_CF 

The bit in the eflags register of CF (Carry Flag).

EFLAGS_PF 

The bit in the eflags register of PF (Parity Flag).

EFLAGS_AF 

The bit in the eflags register of AF (Aux Carry Flag).

EFLAGS_ZF 

The bit in the eflags register of ZF (Zero Flag).

EFLAGS_SF 

The bit in the eflags register of SF (Sign Flag).

EFLAGS_DF 

The bit in the eflags register of DF (Direction Flag).

EFLAGS_OF 

The bit in the eflags register of OF (Overflow Flag).

EFLAGS_ARITH 

The bits in the eflags register of CF, PF, AF, ZF, SF, OF.

◆ _dr_encoding_hint_type_t

Specifies hints for how an instruction should be encoded if redundant encodings are available. Currently, we provide a hint for x86 evex encoded instructions. It can be used to encode an instruction in its evex form instead of its vex format (xref #3339).

Enumerator
DR_ENCODING_HINT_NONE 

No encoding hint is present.

DR_ENCODING_HINT_X86_EVEX 

x86: Encode in EVEX form if available.

◆ _dr_opnd_query_flags_t

Bitmask values passed as flags to routines that ask about whether operands and condition codes are read or written. These flags determine how to treat conditionally executed instructions. As a special case, the addressing registers inside a destination memory operand are covered by DR_QUERY_INCLUDE_COND_SRCS rather than DR_QUERY_INCLUDE_COND_DSTS.

Enumerator
DR_QUERY_INCLUDE_COND_DSTS 

By default, routines that take in these flags will only consider destinations that are always written. Thus, all destinations are skipped for an instruction that is predicated and executes conditionally (see instr_is_predicated()). If this flag is set, a conditionally executed instruction's destinations are included just like any other instruction's. As a special case, the addressing registers inside a destination memory operand are covered by DR_QUERY_INCLUDE_COND_SRCS rather than this flag.

DR_QUERY_INCLUDE_COND_SRCS 

By default, routines that take in these flags will only consider sources that are always read. Thus, all sources are skipped for an instruction that is predicated and executes conditionally (see instr_is_predicated()), except for predication conditions that involve the source operand values. If this flag is set, a conditionally executed instruction's sources are included just like any other instruction's. As a special case, the addressing registers inside a destination memory operand are covered by this flag rather than DR_QUERY_INCLUDE_COND_DSTS.

DR_QUERY_DEFAULT 

The default value that typical liveness analysis would want to use.

DR_QUERY_INCLUDE_ALL 

Includes all operands whether conditional or not.

◆ _dr_pred_trigger_t

This type holds the return values for instr_predicate_triggered().

Enumerator
DR_PRED_TRIGGER_NOPRED 

This instruction is not predicated.

DR_PRED_TRIGGER_MATCH 

The predicate matches and the instruction will execute.

DR_PRED_TRIGGER_MISMATCH 

The predicate does not match and the instruction will not execute.

DR_PRED_TRIGGER_UNKNOWN 

It is unknown whether the predicate matches.

DR_PRED_TRIGGER_INVALID 

An invalid parameter was passed.

◆ dr_fp_type_t

Indicates which type of floating-point operation and instruction performs.

Deprecated:
Replaced by the more general dr_instr_category_t.
Enumerator
DR_FP_STATE 

Saves, restores, or queries processor state.

DR_FP_MOVE 

Moves floating point values from one location to another.

DR_FP_CONVERT 

Converts to or from floating point values.

DR_FP_MATH 

Performs arithmetic or conditional operations.

◆ dr_instr_category_t

Indicates which category the instruction corresponds to. Update instr_get_category_name() in core/ir/instr_shared.c when adding new categories in this enum.

Enumerator
DR_INSTR_CATEGORY_UNCATEGORIZED 

Uncategorized.

DR_INSTR_CATEGORY_FP 

Floating-Point operations.

DR_INSTR_CATEGORY_LOAD 

Loads.

DR_INSTR_CATEGORY_STORE 

Stores.

DR_INSTR_CATEGORY_BRANCH 

Branches.

DR_INSTR_CATEGORY_SIMD 

Operations with vector registers (SIMD).

DR_INSTR_CATEGORY_STATE 

Saves, restores, or queries processor state.

DR_INSTR_CATEGORY_MOVE 

Moves value from one location to another.

DR_INSTR_CATEGORY_CONVERT 

Converts to or from value.

DR_INSTR_CATEGORY_MATH 

Performs arithmetic or conditional operations.

DR_INSTR_CATEGORY_OTHER 

Other types of instructions.

Function Documentation

◆ instr_allocate_raw_bits()

DR_API void instr_allocate_raw_bits ( void *  drcontext,
instr_t instr,
uint  num_bytes 
)

Allocates num_bytes of memory for instr's raw bits. If instr currently points to raw bits, the allocated memory is initialized with the bytes pointed to. instr is then set to point to the allocated memory.

◆ instr_build()

DR_API instr_t* instr_build ( void *  drcontext,
int  opcode,
int  num_dsts,
int  num_srcs 
)

Convenience routine: calls

  • instr_create(dcontext)
  • instr_set_opcode(opcode)
  • instr_set_num_opnds(dcontext, instr, num_dsts, num_srcs)

and returns the resulting instr_t.

◆ instr_build_bits()

DR_API instr_t* instr_build_bits ( void *  drcontext,
int  opcode,
uint  num_bytes 
)

Convenience routine: calls

  • instr_create(dcontext)
  • instr_set_opcode(instr, opcode)
  • instr_allocate_raw_bits(dcontext, instr, num_bytes)

and returns the resulting instr_t.

◆ instr_clear_label_callback()

DR_API void instr_clear_label_callback ( instr_t instr)

Removes the callback set by instr_set_label_callback().

◆ instr_clone()

DR_API instr_t* instr_clone ( void *  drcontext,
instr_t orig 
)

Returns a copy of orig with separately allocated memory for operands and raw bytes if they were present in orig. Only a shallow copy of the note field is made. The label_cb field will not be copied at all if orig is a label instruction.

◆ instr_cmovcc_to_jcc()

DR_API int instr_cmovcc_to_jcc ( int  cmovcc_opcode)

Converts a cmovcc opcode cmovcc_opcode to the OP_jcc opcode that tests the same bits in eflags.

◆ instr_cmovcc_triggered()

DR_API bool instr_cmovcc_triggered ( instr_t instr,
reg_t  eflags 
)

Given eflags, returns whether or not the conditional move instruction instr would execute the move. The conditional move can be an OP_cmovcc or an OP_fcmovcc instruction.

◆ instr_compute_address()

DR_API app_pc instr_compute_address ( instr_t instr,
dr_mcontext_t mc 
)

Returns NULL if none of instr's operands is a memory reference. Otherwise, returns the effective address of the first memory operand when the operands are considered in this order: destinations and then sources. The address is computed using the passed-in registers. mc->flags must include DR_MC_CONTROL and DR_MC_INTEGER. For instructions that use vector addressing (VSIB, introduced in AVX2), mc->flags must additionally include DR_MC_MULTIMEDIA.

Like instr_reads_memory(), this routine does not consider multi-byte nops that use addressing operands, or the OP_lea instruction's source operand, to be memory references.

◆ instr_compute_address_ex()

DR_API bool instr_compute_address_ex ( instr_t instr,
dr_mcontext_t mc,
uint  index,
DR_PARAM_OUT app_pc *  addr,
DR_PARAM_OUT bool *  write 
)

Performs address calculation in the same manner as instr_compute_address() but handles multiple memory operands. The index parameter should be initially set to 0 and then incremented with each successive call until this routine returns false, which indicates that there are no more memory operands. The address of each is computed in the same manner as instr_compute_address() and returned in addr; whether it is a write is returned in is_write. Either or both OUT variables can be NULL. mc->flags must include DR_MC_CONTROL and DR_MC_INTEGER. For instructions that use vector addressing (x86 VSIB, introduced in AVX2, or AArch64 scatter/gather instructions introduced in SVE/SVE2), mc->flags must additionally include DR_MC_MULTIMEDIA.

Like instr_reads_memory(), this routine does not consider multi-byte nops that use addressing operands, or the OP_lea instruction's source operand, to be memory references.

◆ instr_compute_address_ex_pos()

DR_API bool instr_compute_address_ex_pos ( instr_t instr,
dr_mcontext_t mc,
uint  index,
DR_PARAM_OUT app_pc *  addr,
DR_PARAM_OUT bool *  is_write,
DR_PARAM_OUT uint *  pos 
)

Performs address calculation in the same manner as instr_compute_address_ex() with additional information of which opnd is used for address computation returned in pos. If pos is NULL, it is the same as instr_compute_address_ex().

Like instr_reads_memory(), this routine does not consider multi-byte nops that use addressing operands, or the OP_lea instruction's source operand, to be memory references.

◆ instr_convert_short_meta_jmp_to_long()

DR_API instr_t* instr_convert_short_meta_jmp_to_long ( void *  drcontext,
instrlist_t ilist,
instr_t instr 
)

Assumes that instr is a meta instruction (instr_is_meta()) and an instr_is_cti_short() (<=8-bit reach). Converts instr's opcode to a long form (32-bit reach for x86). If instr's opcode is OP_loop* or OP_jecxz for x86 or OP_cbnz or OP_cbz for ARM, converts it to a sequence of multiple instructions (which is different from instr_is_cti_short_rewrite()). Each added instruction is marked instr_is_meta(). Returns the long form of the instruction, which is identical to instr unless instr is OP_{loop*,jecxz,cbnz,cbz}, in which case the return value is the final instruction in the sequence, the one that has long reach.

Note
DR automatically converts app short ctis to long form.

◆ instr_convert_to_isa_regdeps()

DR_API void instr_convert_to_isa_regdeps ( void *  drcontext,
instr_t instr_real_isa,
instr_t instr_regdeps_isa 
)

Converts a real ISA (e.g., DR_ISA_AMD64) instruction instr_real_isa into a DR_ISA_REGDEPS instruction and stores it into instr_regdeps_isa. Assumes instr_regdeps_isa has been allocated by the caller (e.g., using instr_create()). Assumes instr_real_isa is a fully-decoded or synthesized instruction of a real ISA with valid operand information.

Note
instr_regdeps_isa will contain only the information of a DR_ISA_REGDEPS synthetic instruction.

◆ instr_create()

DR_API instr_t* instr_create ( void *  drcontext)

Returns an initialized instr_t allocated on the thread-local heap. Sets the x86/x64 mode of the returned instr_t to the mode of dcontext. The instruction should be de-allocated with instr_destroy(), which will be called automatically if this instruction is added to the instruction list passed to the basic block or trace events.

◆ instr_create_0dst_0src()

DR_API instr_t* instr_create_0dst_0src ( void *  drcontext,
int  opcode 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode and no sources or destinations.

◆ instr_create_0dst_1src()

DR_API instr_t* instr_create_0dst_1src ( void *  drcontext,
int  opcode,
opnd_t  src 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode and a single source (src).

◆ instr_create_0dst_2src()

DR_API instr_t* instr_create_0dst_2src ( void *  drcontext,
int  opcode,
opnd_t  src1,
opnd_t  src2 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode and two sources (src1, src2).

◆ instr_create_0dst_3src()

DR_API instr_t* instr_create_0dst_3src ( void *  drcontext,
int  opcode,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode and three sources (src1, src2, src3).

◆ instr_create_0dst_4src()

DR_API instr_t* instr_create_0dst_4src ( void *  drcontext,
int  opcode,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode and four sources (src1, src2, src3, src4).

◆ instr_create_1dst_0src()

DR_API instr_t* instr_create_1dst_0src ( void *  drcontext,
int  opcode,
opnd_t  dst 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode and one destination (dst).

◆ instr_create_1dst_1src()

DR_API instr_t* instr_create_1dst_1src ( void *  drcontext,
int  opcode,
opnd_t  dst,
opnd_t  src 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, one destination(dst), and one source (src).

◆ instr_create_1dst_2src()

DR_API instr_t* instr_create_1dst_2src ( void *  drcontext,
int  opcode,
opnd_t  dst,
opnd_t  src1,
opnd_t  src2 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, one destination (dst), and two sources (src1, src2).

◆ instr_create_1dst_3src()

DR_API instr_t* instr_create_1dst_3src ( void *  drcontext,
int  opcode,
opnd_t  dst,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, one destination (dst), and three sources (src1, src2, src3).

◆ instr_create_1dst_4src()

DR_API instr_t* instr_create_1dst_4src ( void *  drcontext,
int  opcode,
opnd_t  dst,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, one destination (dst), and four sources (src1, src2, src3, src4).

◆ instr_create_1dst_5src()

DR_API instr_t* instr_create_1dst_5src ( void *  drcontext,
int  opcode,
opnd_t  dst,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, one destination (dst), and five sources (src1, src2, src3, src4, src5).

◆ instr_create_1dst_6src()

DR_API instr_t* instr_create_1dst_6src ( void *  drcontext,
int  opcode,
opnd_t  dst,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5,
opnd_t  src6 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, one destination (dst), and six sources (src1, src2, src3, src4, src5, src6).

◆ instr_create_2dst_0src()

DR_API instr_t* instr_create_2dst_0src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, two destinations (dst1, dst2) and no sources.

◆ instr_create_2dst_1src()

DR_API instr_t* instr_create_2dst_1src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  src 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, two destinations (dst1, dst2) and one source (src).

◆ instr_create_2dst_2src()

DR_API instr_t* instr_create_2dst_2src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  src1,
opnd_t  src2 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, two destinations (dst1, dst2) and two sources (src1, src2).

◆ instr_create_2dst_3src()

DR_API instr_t* instr_create_2dst_3src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, two destinations (dst1, dst2) and three sources (src1, src2, src3).

◆ instr_create_2dst_4src()

DR_API instr_t* instr_create_2dst_4src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, two destinations (dst1, dst2) and four sources (src1, src2, src3, src4).

◆ instr_create_2dst_5src()

DR_API instr_t* instr_create_2dst_5src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, two destinations (dst1, dst2) and five sources (src1, src2, src3, src4, src5).

◆ instr_create_3dst_0src()

DR_API instr_t* instr_create_3dst_0src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, three destinations (dst1, dst2, dst3) and no sources.

◆ instr_create_3dst_1src()

DR_API instr_t* instr_create_3dst_1src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  src1 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, three destinations

  • (dst1, dst2, dst3) and one source (src1).

◆ instr_create_3dst_2src()

DR_API instr_t* instr_create_3dst_2src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  src1,
opnd_t  src2 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, three destinations (dst1, dst2, dst3) and two sources (src1, src2).

◆ instr_create_3dst_3src()

DR_API instr_t* instr_create_3dst_3src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, three destinations (dst1, dst2, dst3) and three sources (src1, src2, src3).

◆ instr_create_3dst_4src()

DR_API instr_t* instr_create_3dst_4src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, three destinations (dst1, dst2, dst3) and four sources (src1, src2, src3, src4).

◆ instr_create_3dst_5src()

DR_API instr_t* instr_create_3dst_5src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, three destinations (dst1, dst2, dst3) and five sources (src1, src2, src3, src4, src5).

◆ instr_create_3dst_6src()

DR_API instr_t* instr_create_3dst_6src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5,
opnd_t  src6 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, three destinations (dst1, dst2, dst3) and six sources (src1, src2, src3, src4, src5, src6).

◆ instr_create_4dst_1src()

DR_API instr_t* instr_create_4dst_1src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  src 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, four destinations (dst1, dst2, dst3, dst4) and 1 source (src).

◆ instr_create_4dst_2src()

DR_API instr_t* instr_create_4dst_2src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  src1,
opnd_t  src2 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, four destinations (dst1, dst2, dst3, dst4) and 2 sources (src1 and src2).

◆ instr_create_4dst_3src()

DR_API instr_t* instr_create_4dst_3src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, four destinations (dst1, dst2, dst3, dst4) and 3 sources (src1, src2 and src3).

◆ instr_create_4dst_4src()

DR_API instr_t* instr_create_4dst_4src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, four destinations (dst1, dst2, dst3, dst4) and four sources (src1, src2, src3, src4).

◆ instr_create_4dst_5src()

DR_API instr_t* instr_create_4dst_5src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, four destinations (dst1, dst2, dst3, dst4) and five sources (src1, src2, src3, src4, src5).

◆ instr_create_4dst_6src()

DR_API instr_t* instr_create_4dst_6src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5,
opnd_t  src6 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, four destinations (dst1, dst2, dst3, dst4) and six sources (src1, src2, src3, src4, src5, src6).

◆ instr_create_4dst_7src()

DR_API instr_t* instr_create_4dst_7src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5,
opnd_t  src6,
opnd_t  src7 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, four destinations (dst1, dst2, dst3, dst4) and seven sources (src1, src2, src3, src4, src5, src6, src7).

◆ instr_create_5dst_3src()

DR_API instr_t* instr_create_5dst_3src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  dst5,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, five destinations (dst1, dst2, dst3, dst4, dst5) and five sources (src1, src2, src3).

◆ instr_create_5dst_4src()

DR_API instr_t* instr_create_5dst_4src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  dst5,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, five destinations (dst1, dst2, dst3, dst4, dst5) and five sources (src1, src2, src3, src4).

◆ instr_create_5dst_5src()

DR_API instr_t* instr_create_5dst_5src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  dst5,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, five destinations (dst1, dst2, dst3, dst4, dst5) and five sources (src1, src2, src3, src4, src5).

◆ instr_create_5dst_8src()

DR_API instr_t* instr_create_5dst_8src ( void *  drcontext,
int  opcode,
opnd_t  dst1,
opnd_t  dst2,
opnd_t  dst3,
opnd_t  dst4,
opnd_t  dst5,
opnd_t  src1,
opnd_t  src2,
opnd_t  src3,
opnd_t  src4,
opnd_t  src5,
opnd_t  src6,
opnd_t  src7,
opnd_t  src8 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, five destinations (dst1, dst2, dst3, dst4, dst5) and eight sources (src1, src2, src3, src4, src5, src6, src7, src8).

◆ instr_create_Ndst_Msrc_vardst()

DR_API instr_t* instr_create_Ndst_Msrc_vardst ( void *  drcontext,
int  opcode,
uint  fixed_dsts,
uint  fixed_srcs,
uint  var_dsts,
uint  var_ord,
  ... 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, fixed_dsts plus var_dsts destination operands, and fixed_srcs source operands. The variable arguments must start with the fixed destinations, followed by the (fixed) sources, followed by the variable destinations. The var_ord parameter specifies the (0-based) ordinal position within the resulting instruction's destination array at which the variable destinations should be placed, allowing them to be inserted in the middle of the fixed destinations.

◆ instr_create_Ndst_Msrc_varsrc()

DR_API instr_t* instr_create_Ndst_Msrc_varsrc ( void *  drcontext,
int  opcode,
uint  fixed_dsts,
uint  fixed_srcs,
uint  var_srcs,
uint  var_ord,
  ... 
)

Convenience routine that returns an initialized instr_t allocated on the thread-local heap with opcode opcode, fixed_dsts destination operands, and fixed_srcs plus var_srcs source operands. The variable arguments must start with the (fixed) destinations, followed by the fixed sources, followed by the variable sources. The var_ord parameter specifies the (0-based) ordinal position within the resulting instruction's source array at which the variable sources should be placed, allowing them to be inserted in the middle of the fixed sources.

◆ instr_create_popa()

DR_API instr_t* instr_create_popa ( void *  drcontext)

Convenience routine that returns an initialized instr_t for OP_popa.

◆ instr_create_pusha()

DR_API instr_t* instr_create_pusha ( void *  drcontext)

Convenience routine that returns an initialized instr_t for OP_pusha.

◆ instr_destroy()

DR_API void instr_destroy ( void *  drcontext,
instr_t instr 
)

Performs instr_free() and then deallocates the thread-local heap storage for instr that was performed by instr_create().

◆ instr_free()

DR_API void instr_free ( void *  drcontext,
instr_t instr 
)

Deallocates all memory that was allocated by instr. This includes raw bytes allocated by instr_allocate_raw_bits() and operands allocated by instr_set_num_opnds(). Does not deallocate the storage for instr itself (use instr_destroy() instead if instr was created with instr_create()).

◆ instr_free_raw_bits()

DR_API void instr_free_raw_bits ( void *  drcontext,
instr_t instr 
)

If instr has raw bits allocated, frees them.

◆ instr_from_noalloc()

DR_API INSTR_INLINE instr_t* instr_from_noalloc ( instr_noalloc_t noalloc)

Given an instr_noalloc_t where all operands are included, returns an instr_t pointer corresponding to that no-alloc structure suitable for passing to instruction API functions.

◆ instr_get_app_pc()

DR_API app_pc instr_get_app_pc ( instr_t instr)

Get the original application PC of instr if it exists.

◆ instr_get_arith_flags()

DR_API uint instr_get_arith_flags ( instr_t instr,
dr_opnd_query_flags_t  flags 
)

Returns instr's arithmetic flags (bottom 6 eflags) use as EFLAGS_ constants (e.g., EFLAGS_READ_CF, EFLAGS_WRITE_OF, etc.) or'ed together. If instr's eflags behavior has not been calculated yet or is invalid, the entire eflags use is calculated and returned (not just the arithmetic flags). Which eflags are considered to be accessed for conditionally executed instructions are controlled by flags.

◆ instr_get_branch_target_pc()

DR_API app_pc instr_get_branch_target_pc ( instr_t cti_instr)

Return the taken target pc of the (direct branch) instruction.

◆ instr_get_category()

DR_API uint instr_get_category ( instr_t instr)

Returns instr's set of categories (set of DR_INSTR_CATEGORY_ constants). See dr_instr_category_t. This API is only supported for decoded instructions, not for synthetic ones. Currently this is only supported for AArch64.

◆ instr_get_category_name()

const DR_API char* instr_get_category_name ( dr_instr_category_t  category)

Assumes category is a DR_INSTR_CATEGORY_ constant. See dr_instr_category_t. Returns category name in string format.

◆ instr_get_dst()

DR_API opnd_t instr_get_dst ( instr_t instr,
uint  pos 
)

Returns instr's destination operand at position pos (0-based).

◆ instr_get_eflags()

DR_API uint instr_get_eflags ( instr_t instr,
dr_opnd_query_flags_t  flags 
)

Returns instr's eflags use as EFLAGS_ constants (e.g., EFLAGS_READ_CF, EFLAGS_WRITE_OF, etc.) or'ed together. Which eflags are considered to be accessed for conditionally executed instructions are controlled by flags.

◆ instr_get_interrupt_number()

DR_API int instr_get_interrupt_number ( instr_t instr)

Assumes that instr's opcode is OP_int and that either instr's operands or its raw bits are valid. Returns the first source operand if instr's operands are valid, else if instr's raw bits are valid returns the first raw byte.

◆ instr_get_isa_mode()

DR_API dr_isa_mode_t instr_get_isa_mode ( instr_t instr)

Each instruction stores the processor mode under which it should be interpreted. This routine returns the mode for instr.

◆ instr_get_label_data_area()

DR_API dr_instr_label_data_t* instr_get_label_data_area ( instr_t instr)
Returns
a pointer to user-controlled data fields in a label instruction. These fields are available for use by clients for their own purposes. Returns NULL if instr is not a label instruction.
Note
These data fields are copied (shallowly) across instr_clone().

◆ instr_get_next()

DR_API INSTR_INLINE instr_t* instr_get_next ( instr_t instr)

Returns the next instr_t in the instrlist_t that contains instr.

Note
The next pointer for an instr_t is inside the instr_t data structure itself, making it impossible to have on instr_t in two different InstrLists (but removing the need for an extra data structure for each element of the instrlist_t).

◆ instr_get_next_app()

DR_API INSTR_INLINE instr_t* instr_get_next_app ( instr_t instr)

Returns the next application (non-meta) instruction in the instruction list that contains instr.

Note
As opposed to instr_get_next(), this routine skips all meta instructions inserted by either DynamoRIO or its clients.
We recommend using this routine during the phase of application code analysis, as any meta instructions present are guaranteed to be ok to skip. However, caution should be exercised if using this routine after any instrumentation insertion has already happened, as instrumentation might affect register usage or other factors being analyzed.

◆ instr_get_note()

DR_API INSTR_INLINE void* instr_get_note ( instr_t instr)

Gets the value of the user-controlled note field in instr.

Note
The note field is copied (shallowly) by instr_clone().

◆ instr_get_offset()

DR_API size_t instr_get_offset ( instr_t instr)

Get the relative offset of instr in an encoded instruction list.

Note
instrlist_encode* sets the offset field in each instr_t in the encoded instruction list. Therefore, this API must be called only after calling instrlist_encode*.

◆ instr_get_opcode()

DR_API int instr_get_opcode ( instr_t instr)

Returns instr's opcode (an OP_ constant).

◆ instr_get_opcode_eflags()

DR_API uint instr_get_opcode_eflags ( int  opcode)

Returns the eflags usage of instructions with opcode opcode, as EFLAGS_ constants (e.g., EFLAGS_READ_CF, EFLAGS_WRITE_OF, etc.) or'ed together. If opcode is predicated (see instr_is_predicated()) or if the set of flags read or written varies with an operand value, this routine returns the maximal set that might be accessed or written.

◆ instr_get_operation_size()

DR_API opnd_size_t instr_get_operation_size ( instr_t instr)

Returns the operation size of instr if it's a DR_ISA_REGDEPS instruction, OPSZ_NA otherwise.

◆ instr_get_predicate()

DR_API dr_pred_type_t instr_get_predicate ( instr_t instr)

Returns the DR_PRED_ constant for instr that describes what its conditional execution is dependent on.

◆ instr_get_prefix_flag()

DR_API bool instr_get_prefix_flag ( instr_t instr,
uint  prefix 
)

Assumes that prefix is a PREFIX_ constant. Returns true if instr's prefixes contain the flag prefix.

◆ instr_get_prev()

DR_API INSTR_INLINE instr_t* instr_get_prev ( instr_t instr)

Returns the previous instr_t in the instrlist_t that contains instr.

◆ instr_get_prev_app()

DR_API INSTR_INLINE instr_t* instr_get_prev_app ( instr_t instr)

Returns the previous application (non-meta) instruction in the instruction list that contains instr.

Note
As opposed to instr_get_prev(), this routine skips all meta instructions inserted by either DynamoRIO or its clients.
We recommend using this routine during the phase of application code analysis, as any meta instructions present are guaranteed to be ok to skip. However, caution should be exercised if using this routine after any instrumentation insertion has already happened, as instrumentation might affect register usage or other factors being analyzed.

◆ instr_get_raw_bits()

DR_API byte* instr_get_raw_bits ( instr_t instr)

Assumes that instr's raw bits are valid. Returns a pointer to instr's raw bits.

Note
A freshly-decoded instruction has valid raw bits that point to the address from which it was decoded. However, for instructions presented in the basic block or trace events, use instr_get_app_pc() to retrieve the corresponding application address, as the raw bits will not be set for instructions added after decoding, and may point to a different location for insructions that have been modified.

◆ instr_get_raw_byte()

DR_API byte instr_get_raw_byte ( instr_t instr,
uint  pos 
)

Assumes that instr's raw bits are valid and have > pos bytes. Returns a pointer to instr's raw byte at position pos (beginning with 0).

◆ instr_get_raw_word()

DR_API uint instr_get_raw_word ( instr_t instr,
uint  pos 
)

Assumes that instr's raw bits are valid and have > pos + 3 bytes. Returns the 4 bytes beginning at position pos (0-based).

◆ instr_get_rel_addr_dst_idx()

DR_API int instr_get_rel_addr_dst_idx ( instr_t instr)

If any of instr's destination operands is a rip-relative data memory reference, returns the operand position. If there is no such destination operand, returns -1.

Note
For 64-bit DR builds only.

◆ instr_get_rel_addr_src_idx()

DR_API int instr_get_rel_addr_src_idx ( instr_t instr)

If any of instr's source operands is a rip-relative memory reference, returns the operand position. If there is no such source operand, returns -1.

Note
For 64-bit DR builds only.

◆ instr_get_rel_addr_target()

DR_API bool instr_get_rel_addr_target ( instr_t instr,
app_pc *  target 
)

If any of instr's operands is a rip-relative data memory reference, returns the address that reference targets. Else returns false.

Note
For 64-bit DR builds only.

◆ instr_get_rel_data_or_instr_target()

DR_API bool instr_get_rel_data_or_instr_target ( instr_t instr,
app_pc *  target 
)

If any of instr's operands is a rip-relative data or instruction memory reference, returns the address that reference targets. Else returns false. For instruction references, only PC operands are considered: not instruction pointer operands.

Note
Currently this is only implemented for x86.

◆ instr_get_src()

DR_API opnd_t instr_get_src ( instr_t instr,
uint  pos 
)

Returns instr's source operand at position pos (0-based).

◆ instr_get_target()

DR_API opnd_t instr_get_target ( instr_t cti_instr)

Assumes that cti_instr is a control transfer instruction Returns the first source operand of cti_instr (its target).

◆ instr_get_x86_mode()

DR_API bool instr_get_x86_mode ( instr_t instr)

Returns true if instr is an x86 instruction (32-bit) and false if instr is an x64 instruction (64-bit).

Note
For 64-bit DR builds only.
Deprecated:
Replaced by instr_get_isa_mode().

◆ instr_has_allocated_bits()

INSTR_INLINE_INTERNALLY DR_API bool instr_has_allocated_bits ( instr_t instr)

Returns true iff instr has its own allocated memory for raw bits.

◆ instr_has_encoding_hint()

DR_API bool instr_has_encoding_hint ( instr_t instr,
dr_encoding_hint_type_t  hint 
)

Each instruction may store a hint for how the instruction should be encoded if redundant encodings are available. This presumes that the user knows that a redundant encoding is available. This routine returns whether the hint is set for instr.

◆ instr_has_rel_addr_reference()

DR_API bool instr_has_rel_addr_reference ( instr_t instr)

Returns true iff any of instr's operands is a rip-relative data memory reference.

Note
For 64-bit DR builds only.

◆ instr_init()

DR_API void instr_init ( void *  drcontext,
instr_t instr 
)

Initializes instr. Sets the x86/x64 mode of instr to the mode of dcontext. When finished with it, the instruction's internal memory should be freed with instr_free(), or instr_reset() for reuse.

◆ instr_invert_cbr()

DR_API void instr_invert_cbr ( instr_t instr)

Assumes that instr is a conditional branch instruction Reverses the logic of instr's conditional e.g., changes OP_jb to OP_jnb. Works on cti_short_rewrite as well.

◆ instr_invert_predicate()

DR_API dr_pred_type_t instr_invert_predicate ( dr_pred_type_t  pred)

Returns the DR_PRED_ constant that represents the opposite condition from pred. A valid conditional branch predicate must be passed (i.e., not DR_PRED_NONE, DR_PRED_AL, or DR_PRED_OP for ARM and not DR_PRED_NONE, DR_PRED_AL, or DR_PRED_NV for AArch64).

Note
ARM and AArch64-only.

◆ instr_is_3DNow()

DR_API bool instr_is_3DNow ( instr_t instr)

Returns true iff instr is part of AMD's 3D-Now! instructions.

◆ instr_is_app()

DR_API INSTR_INLINE bool instr_is_app ( instr_t instr)

Return true iff instr is an application (non-meta) instruction (see instr_set_app() for more information).

◆ instr_is_call()

DR_API bool instr_is_call ( instr_t instr)

Returns true iff instr's opcode is OP_call, OP_call_far, OP_call_ind, or OP_call_far_ind on x86; OP_bl, OP_blx, or OP_blx_ind on ARM.

◆ instr_is_call_direct()

DR_API bool instr_is_call_direct ( instr_t instr)

Returns true iff instr's opcode is OP_call or OP_call_far.

◆ instr_is_call_indirect()

DR_API bool instr_is_call_indirect ( instr_t instr)

Returns true iff instr's opcode is OP_call_ind or OP_call_far_ind on x86; OP_blx_ind on ARM.

◆ instr_is_cbr()

DR_API bool instr_is_cbr ( instr_t instr)

Returns true iff instr is a conditional branch: OP_jcc, OP_jcc_short, OP_loop*, or OP_jecxz on x86; OP_cbnz, OP_cbz, or when a predicate is present any of OP_b, OP_b_short, OP_bx, OP_bxj, OP_bl, OP_blx, OP_blx_ind on ARM.

◆ instr_is_cti()

DR_API bool instr_is_cti ( instr_t instr)

Returns true iff instr is a control transfer instruction of any kind, whether direct, indirect, conditional, or unconditional.

◆ instr_is_cti_loop()

DR_API bool instr_is_cti_loop ( instr_t instr)

Returns true iff instr is one of OP_loop* or OP_jecxz on x86.

◆ instr_is_cti_short()

DR_API bool instr_is_cti_short ( instr_t instr)

Returns true iff instr is a control transfer instruction that takes an 8-bit offset on x86 (OP_loop*, OP_jecxz, OP_jmp_short, or OP_jcc_short) or a small offset on ARM (OP_cbz, OP_cbnz, OP_b_short). This routine does NOT try to decode an opcode in a Level 1 or Level 0 routine, and can thus be called on Level 0 routines. Levels are not exposed in the API anymore, however.

◆ instr_is_cti_short_rewrite()

DR_API bool instr_is_cti_short_rewrite ( instr_t instr,
byte *  pc 
)

Returns true iff instr's opcode is OP_loop* or OP_jecxz on x86 or OP_cbz or OP_cbnz on ARM and instr has been transformed to a sequence of instruction that will allow a larger offset. If pc != NULL, pc is expected to point to the beginning of the encoding of instr, and the following instructions are assumed to be encoded in sequence after instr. Otherwise, the encoding is expected to be found in instr's allocated bits. This routine does NOT try to decode an opcode in a Level 1 or Level 0 routine, and can thus be called on Level 0 routines. Levels are not exposed in the API anymore, however.

◆ instr_is_exclusive_load()

DR_API bool instr_is_exclusive_load ( instr_t instr)

Returns true iff instr is an exclusive load instruction, e.g., OP_ldrex on ARM.

◆ instr_is_exclusive_store()

DR_API bool instr_is_exclusive_store ( instr_t instr)

Returns true iff instr is an exclusive store instruction, e.g., OP_strex on ARM.

◆ instr_is_exit_cti()

DR_API bool instr_is_exit_cti ( instr_t instr)

Returns true iff instr is a conditional branch, unconditional branch, or indirect branch with a program address target (NOT an instr_t address target) and instr is ok to mangle.

◆ instr_is_far_abs_cti()

DR_API bool instr_is_far_abs_cti ( instr_t instr)

Returns true if instr is an absolute call or jmp that is far.

◆ instr_is_far_cti()

DR_API bool instr_is_far_cti ( instr_t instr)

Returns true iff instr is a far control transfer instruction: OP_jmp_far, OP_call_far, OP_jmp_far_ind, OP_call_far_ind, OP_ret_far, or OP_iret, on x86.

◆ instr_is_floating()

DR_API bool instr_is_floating ( instr_t instr)

Returns true iff instr is a floating point instruction.

◆ instr_is_floating_ex()

DR_API bool instr_is_floating_ex ( instr_t instr,
dr_fp_type_t type 
)

Returns true iff instr is a floating point instruction.

Parameters
[in]instrThe instruction to query
[out]typeIf the return value is true and type is non-NULL, the type of the floating point operation is written to type.
Deprecated:
Prefer instr_is_floating_type() which uses the more general dr_instr_category_t.

◆ instr_is_floating_type()

DR_API bool instr_is_floating_type ( instr_t instr,
dr_instr_category_t type 
)

Returns true iff instr is a floating point instruction.

Parameters
[in]instrThe instruction to query
[out]typeIf the return value is true and type is non-NULL, the type of the floating point operation is written to type.

◆ instr_is_gather()

DR_API bool instr_is_gather ( instr_t instr)

Returns true iff instr is a gather-load instruction.

◆ instr_is_interrupt()

DR_API bool instr_is_interrupt ( instr_t instr)

Return true iff instr's opcode is OP_int, OP_into, or OP_int3.

◆ instr_is_label()

DR_API bool instr_is_label ( instr_t instr)

Returns true iff instr is a label meta-instruction.

◆ instr_is_mbr()

DR_API bool instr_is_mbr ( instr_t instr)

Returns true iff instr is a multi-way (indirect) branch: OP_jmp_ind, OP_call_ind, OP_ret, OP_jmp_far_ind, OP_call_far_ind, OP_ret_far, or OP_iret on x86; OP_bx, OP_bxj, OP_blx_ind, or any instruction with a destination register operand of DR_REG_PC on ARM.

◆ instr_is_meta()

DR_API INSTR_INLINE bool instr_is_meta ( instr_t instr)

Return true iff instr is a meta instruction (see instr_set_meta() for more information).

◆ instr_is_meta_may_fault()

DR_API bool instr_is_meta_may_fault ( instr_t instr)

Return true iff instr is not a meta-instruction that can fault (see instr_set_meta_may_fault() for more information).

Deprecated:
Any meta instruction can fault if it has a non-NULL translation field and the client fully handles all of its faults, so this routine is no longer needed.

◆ instr_is_mmx()

DR_API bool instr_is_mmx ( instr_t instr)

Returns true iff instr is part of Intel's MMX instructions.

◆ instr_is_mov()

DR_API bool instr_is_mov ( instr_t instr)

Returns true iff instr is an IA-32/AMD64 "mov" instruction: either OP_mov_st, OP_mov_ld, OP_mov_imm, OP_mov_seg, or OP_mov_priv.

◆ instr_is_mov_constant()

DR_API bool instr_is_mov_constant ( instr_t instr,
ptr_int_t *  value 
)

Tries to identify common cases of moving a constant into either a register or a memory address. Returns true and sets *value to the constant being moved for the following cases: OP_mov_imm, OP_mov_st, and OP_xor where the source equals the destination, for x86; OP_mov, OP_movs, OP_movw, OP_mvn, OP_mvns, or OP_eor where the sources equal the destination and there is no shift, for ARM.

◆ instr_is_mov_imm_to_tos()

DR_API bool instr_is_mov_imm_to_tos ( instr_t instr)

Returns true iff instr is a "mov $imm -> (%esp)".

◆ instr_is_near_call_direct()

DR_API bool instr_is_near_call_direct ( instr_t instr)

Returns true iff instr's opcode is OP_call on x86; OP_bl or OP_blx on ARM.

◆ instr_is_near_ubr()

DR_API bool instr_is_near_ubr ( instr_t instr)

Returns true iff instr is a near unconditional direct branch: OP_jmp, or OP_jmp_short on x86; OP_b with no predicate on ARM.

◆ instr_is_nop()

DR_API bool instr_is_nop ( instr_t instr)

Returns true if instr is one of a class of common nops. currently checks:

  • nop
  • nop reg/mem
  • xchg reg, reg
  • mov reg, reg
  • lea reg, (reg)

◆ instr_is_opmask()

DR_API bool instr_is_opmask ( instr_t instr)

Returns true iff instr is part of Intel's AVX-512 scalar opmask instructions.

◆ instr_is_opnd_store_source()

DR_API bool instr_is_opnd_store_source ( instr_t store_instr,
int  source_ordinal 
)

If store_instr is not a store (instr_writes_memory() returns false), returns false. If store_instr is a store (instr_writes_memory() returns true), returns whether its source operand with index source_ordinal (as passed to instr_get_src()) is a source for the value that is stored. (If not, it may be an address register that is updated for pre-index or post-index writeback forms, or some other source that does not directly affect the value written to memory.)

◆ instr_is_predicated()

DR_API bool instr_is_predicated ( instr_t instr)

Returns whether instr is predicated: i.e., whether its operation is conditional.

◆ instr_is_prefetch()

DR_API bool instr_is_prefetch ( instr_t instr)

Returns true iff instr is a prefetch instruction.

◆ instr_is_reg_spill_or_restore()

DR_API bool instr_is_reg_spill_or_restore ( void *  drcontext,
instr_t instr,
bool *tls  DR_PARAM_OUT,
bool *spill  DR_PARAM_OUT,
reg_id_t *reg  DR_PARAM_OUT,
uint *offs  DR_PARAM_OUT 
)

Returns whether instr is a register spill or restore, whether it was created by dr_save_reg(), dr_restore_reg(), dr_insert_read_raw_tls(), dr_insert_write_raw_tls(), routines that call the aforementioned routines (e.g., dr_save_arith_flags()), or DR's own internal spills and restores. Returns information about the spill/restore in the OUT parameters. The returned offs is the raw offset in bytes from the TLS segment base, the stolen register base, or the thread-private context area.

◆ instr_is_rep_string_op()

DR_API bool instr_is_rep_string_op ( instr_t instr)

Returns true iff instr is an Intel repeated-loop string operation instruction.

◆ instr_is_return()

DR_API bool instr_is_return ( instr_t instr)

Returns true iff instr's opcode is OP_ret, OP_ret_far, or OP_iret on x86. On ARM, returns true iff instr reads DR_REG_LR and writes DR_REG_PC.

◆ instr_is_scatter()

DR_API bool instr_is_scatter ( instr_t instr)

Returns true iff instr is a scatter-store instruction.

◆ instr_is_sse()

DR_API bool instr_is_sse ( instr_t instr)

Returns true iff instr is part of Intel's SSE instructions.

◆ instr_is_sse2()

DR_API bool instr_is_sse2 ( instr_t instr)

Returns true iff instr is part of Intel's SSE2 instructions.

◆ instr_is_sse3()

DR_API bool instr_is_sse3 ( instr_t instr)

Returns true iff instr is part of Intel's SSE3 instructions.

◆ instr_is_sse41()

DR_API bool instr_is_sse41 ( instr_t instr)

Returns true iff instr is part of Intel's SSE4.1 instructions.

◆ instr_is_sse42()

DR_API bool instr_is_sse42 ( instr_t instr)

Returns true iff instr is part of Intel's SSE4.2 instructions.

◆ instr_is_sse4A()

DR_API bool instr_is_sse4A ( instr_t instr)

Returns true iff instr is part of AMD's SSE4A instructions.

◆ instr_is_sse_or_sse2()

DR_API bool instr_is_sse_or_sse2 ( instr_t instr)

Returns true iff instr is part of Intel's SSE or SSE2 instructions.

Deprecated:
Use instr_is_sse() combined with instr_is_sse2() instead.

◆ instr_is_ssse3()

DR_API bool instr_is_ssse3 ( instr_t instr)

Returns true iff instr is part of Intel's SSSE3 instructions.

◆ instr_is_string_op()

DR_API bool instr_is_string_op ( instr_t instr)

Returns true iff instr is an Intel string operation instruction.

◆ instr_is_syscall()

DR_API bool instr_is_syscall ( instr_t instr)

Returns true iff instr is used to implement system calls: OP_int with a source operand of 0x80 on linux or 0x2e on windows, or OP_sysenter, or OP_syscall, or instr_is_wow64_syscall() for WOW64.

◆ instr_is_ubr()

DR_API bool instr_is_ubr ( instr_t instr)

Returns true iff instr is an unconditional direct branch: OP_jmp, OP_jmp_short, or OP_jmp_far on x86; OP_b or OP_b_short with no predicate on ARM.

◆ instr_is_undefined()

DR_API bool instr_is_undefined ( instr_t instr)

Returns true iff instr is an "undefined" instruction (ud2)

◆ instr_is_wow64_syscall()

DR_API bool instr_is_wow64_syscall ( instr_t instr)

Returns true iff instr is the indirect transfer from the 32-bit ntdll.dll to the wow64 system call emulation layer. This instruction will also return true for instr_is_syscall, as well as appear as an indirect call, so clients modifying indirect calls may want to avoid modifying this type.

Note
Windows-only

◆ instr_is_xrstor()

DR_API bool instr_is_xrstor ( instr_t instr)

Returns true if instr's opcode is OP_xrstor32, OP_xrstor64, OP_xrstors32, or OP_xrstors64.

◆ instr_is_xsave()

DR_API bool instr_is_xsave ( instr_t instr)

◆ instr_it_block_compute_immediates()

DR_API bool instr_it_block_compute_immediates ( dr_pred_type_t  pred0,
dr_pred_type_t  pred1,
dr_pred_type_t  pred2,
dr_pred_type_t  pred3,
byte *  firstcond_out,
byte *  mask_out 
)

Computes immediates (firstcond and mask) for creating a new instruction with opcode OP_it with the given predicates. Up to four instructions can exist in a single IT block. Pass DR_PRED_NONE for all predicates beyond the desired instruction count in the newly created IT block. Returns whether the given predicates are valid for creating an IT block.

Note
ARM-only.

◆ instr_it_block_create()

DR_API instr_t* instr_it_block_create ( void *  drcontext,
dr_pred_type_t  pred0,
dr_pred_type_t  pred1,
dr_pred_type_t  pred2,
dr_pred_type_t  pred3 
)

Creates a new instruction with opcode OP_it and immediates set to encode an IT block with the given predicates. Up to four instructions can exist in a single IT block. Pass DR_PRED_NONE for all predicates beyond the desired instruction count in the newly created IT block.

Note
ARM-only.

◆ instr_it_block_get_count()

DR_API uint instr_it_block_get_count ( instr_t it_instr)

Assumes that it_instr's opcode is OP_it. Returns the number of instructions in the IT block that it_instr heads.

Note
ARM-only.

◆ instr_it_block_get_pred()

DR_API dr_pred_type_t instr_it_block_get_pred ( instr_t it_instr,
uint  index 
)

Assumes that it_instr's opcode is OP_it. Returns the predicate for the instruction with ordinal index in IT block that it_instr heads.

Note
ARM-only.

◆ instr_jcc_taken()

DR_API bool instr_jcc_taken ( instr_t instr,
reg_t  eflags 
)

Given eflags, returns whether or not the conditional branch, instr, would be taken.

◆ instr_length()

DR_API int instr_length ( void *  drcontext,
instr_t instr 
)

Returns the length of instr. As a side effect, if instr_is_app(instr) and instr's raw bits are invalid, encodes instr into bytes allocated with instr_allocate_raw_bits(), after which instr is marked as having valid raw bits.

◆ instr_make_persistent()

DR_API void instr_make_persistent ( void *  drcontext,
instr_t instr 
)

Calling this function with instr makes it safe to keep the instruction around indefinitely when its raw bits point into the cache. The function allocates memory local to instr to hold a copy of the raw bits. If this was not done, the original raw bits could be deleted at some point. Making an instruction persistent is necessary if you want to keep it beyond returning from the call that produced the instruction.

◆ instr_mem_usage()

DR_API int instr_mem_usage ( instr_t instr)

Returns the total number of bytes of memory used by instr.

◆ instr_memory_reference_size()

DR_API uint instr_memory_reference_size ( instr_t instr)

Calculates the size, in bytes, of the memory read or write of instr. If instr does not reference memory, or is invalid, returns 0. If instr is a repeated string instruction, considers only one iteration. If instr uses vector addressing (VSIB, introduced in AVX2), considers only the size of each separate memory access.

◆ instr_needs_encoding()

INSTR_INLINE_INTERNALLY DR_API bool instr_needs_encoding ( instr_t instr)

Returns true iff instr's raw bits are not a valid encoding of instr.

◆ instr_noalloc_init()

DR_API void instr_noalloc_init ( void *  drcontext,
instr_noalloc_t instr 
)

Initializes the no-heap-allocation structure instr. Sets the x86/x64 mode of instr to the mode of dcontext.

◆ instr_num_dsts()

DR_API INSTR_INLINE int instr_num_dsts ( instr_t instr)

Returns the number of destination operands of instr.

◆ instr_num_memory_read_access()

DR_API uint instr_num_memory_read_access ( instr_t instr)

Returns the number of memory read accesses of the instruction.

◆ instr_num_memory_write_access()

DR_API uint instr_num_memory_write_access ( instr_t instr)

Returns the number of memory write accesses of the instruction.

◆ instr_num_srcs()

DR_API INSTR_INLINE int instr_num_srcs ( instr_t instr)

Returns the number of source operands of instr.

Note
Addressing registers used in destination memory references (i.e., base, index, or segment registers) are not separately listed as source operands.

◆ instr_ok_to_emit()

INSTR_INLINE_INTERNALLY DR_API bool instr_ok_to_emit ( instr_t instr)

Return true iff instr is to be emitted into the cache.

◆ instr_ok_to_mangle()

DR_API INSTR_INLINE bool instr_ok_to_mangle ( instr_t instr)

Return true iff instr is not a meta-instruction (see instr_set_app() for more information).

Deprecated:
instr_is_app()/instr_is_meta() should be used instead.

◆ instr_opcode_valid()

DR_API bool instr_opcode_valid ( instr_t instr)

Returns true iff instr's opcode is valid. If the opcode is ever set to other than OP_INVALID or OP_UNDECODED it is assumed to be valid. However, calling instr_get_opcode() will attempt to decode a valid opcode, hence the purpose of this routine.

◆ instr_operands_valid()

INSTR_INLINE_INTERNALLY DR_API bool instr_operands_valid ( instr_t instr)

Returns true iff instr's operands are up to date.

◆ instr_predicate_is_cond()

DR_API bool instr_predicate_is_cond ( dr_pred_type_t  pred)

Returns true iff pred denotes a truly conditional predicate: on all architectures, this excludes DR_PRED_NONE. On ARM it also excludes DR_PRED_AL and DR_PRED_OP; on AArch64, it also excludes DR_PRED_AL and DR_PRED_NV.

◆ instr_predicate_name()

const DR_API char* instr_predicate_name ( dr_pred_type_t  pred)

Returns the string name corresponding to the given DR_PRED_ constant.

Note
ARM-only.

◆ instr_predicate_triggered()

DR_API dr_pred_trigger_t instr_predicate_triggered ( instr_t instr,
dr_mcontext_t mc 
)

Given the machine context mc, returns whether or not the predicated instruction instr will execute. Currently condition-code predicates are supported and OP_bsf and OP_bsr from DR_PRED_COMPLEX; other instances of DR_PRED_COMPLEX are not supported. mc->flags must include DR_MC_CONTROL for condition-code predicates, and additionally DR_MC_INTEGER for OP_bsf and OP_bsr.

Note
More complex predicates will be added in the future and they may require additional state in mc.

◆ instr_raw_bits_valid()

INSTR_INLINE_INTERNALLY DR_API bool instr_raw_bits_valid ( instr_t instr)

Returns true iff instr's raw bits are a valid encoding of instr.

◆ instr_reads_from_exact_reg()

DR_API bool instr_reads_from_exact_reg ( instr_t instr,
reg_id_t  reg,
dr_opnd_query_flags_t  flags 
)

Assumes that reg is a DR_REG_ constant. Returns true iff at least one of instr's source operands is the same register (not enough to just overlap) as reg.

For example, false is returned if the instruction instr is vmov [m], zmm0 and the register being tested reg is DR_REG_XMM0.

Registers used in memory operands, namely base, index and segmentation registers, are checked also by this routine. This also includes destination operands.

Which operands are considered to be accessed for conditionally executed instructions are controlled by flags.

◆ instr_reads_from_reg()

DR_API bool instr_reads_from_reg ( instr_t instr,
reg_id_t  reg,
dr_opnd_query_flags_t  flags 
)

Assumes that reg is a DR_REG_ constant. Returns true iff at least one of instr's operands reads from a register that overlaps reg (checks both source operands and addressing registers used in destination operands).

Returns false for multi-byte nops with an operand using reg.

Which operands are considered to be accessed for conditionally executed instructions are controlled by flags. As a special case, the addressing registers inside a destination memory operand are covered by DR_QUERY_INCLUDE_COND_SRCS rather than DR_QUERY_INCLUDE_COND_DSTS.

◆ instr_reads_memory()

DR_API bool instr_reads_memory ( instr_t instr)

Returns true iff any of instr's source operands is a memory reference.

Unlike opnd_is_memory_reference(), this routine conisders the semantics of the instruction and returns false for both multi-byte nops with a memory operand and for the OP_lea instruction, as they do not really reference the memory. It does return true for prefetch instructions.

If instr is predicated (see instr_is_predicated()), the memory reference may not always be accessed.

◆ instr_reg_in_dst()

DR_API bool instr_reg_in_dst ( instr_t instr,
reg_id_t  reg 
)

Assumes that reg is a DR_REG_ constant. Returns true iff at least one of instr's destination operands references reg.

◆ instr_reg_in_src()

DR_API bool instr_reg_in_src ( instr_t instr,
reg_id_t  reg 
)

Assumes that reg is a DR_REG_ constant. Returns true iff at least one of instr's source operands references reg.

Returns false for multi-byte nops with a source operand using reg.

Note
Use instr_reads_from_reg() to also consider addressing registers in destination operands.

◆ instr_remove_dsts()

DR_API void instr_remove_dsts ( void *  drcontext,
instr_t instr,
uint  start,
uint  end 
)

Removes instr's destination operands from position start up to but not including position end (so pass n,n+1 to remove just position n). Shifts all subsequent destination operands (if any) down in the operand array. Also calls instr_set_raw_bits_valid(instr, false) and instr_set_operands_valid(instr, true).

◆ instr_remove_srcs()

DR_API void instr_remove_srcs ( void *  drcontext,
instr_t instr,
uint  start,
uint  end 
)

Removes instr's source operands from position start up to but not including position end (so pass n,n+1 to remove just position n). Shifts all subsequent source operands (if any) down in the operand array. Also calls instr_set_raw_bits_valid(instr, false) and instr_set_operands_valid(instr, true).

◆ instr_replace_reg_resize()

DR_API bool instr_replace_reg_resize ( instr_t instr,
reg_id_t  old_reg,
reg_id_t  new_reg 
)

Replaces all instances of old_reg (or any size variant) in instr's operands with new_reg. Resizes new_reg to match sub-full-size uses of old_reg. Returns whether it replaced anything.

◆ instr_replace_src_opnd()

DR_API bool instr_replace_src_opnd ( instr_t instr,
opnd_t  old_opnd,
opnd_t  new_opnd 
)

Replaces all instances of old_opnd in instr's source operands with new_opnd (uses opnd_same() to detect sameness). Returns whether it replaced anything.

◆ instr_reset()

DR_API void instr_reset ( void *  drcontext,
instr_t instr 
)

Performs both instr_free() and instr_init(). instr must have been initialized.

◆ instr_reuse()

DR_API void instr_reuse ( void *  drcontext,
instr_t instr 
)

Frees all dynamically allocated storage that was allocated by instr, except for allocated bits. Also zeroes out instr's fields, except for raw bit fields, whether instr is instr_is_meta(), and the x86 mode of instr. instr must have been initialized.

◆ instr_same()

DR_API bool instr_same ( instr_t instr1,
instr_t instr2 
)

Returns true iff instr1 and instr2 have the same opcode, prefixes, and source and destination operands (uses opnd_same() to compare the operands).

◆ instr_set_app()

DR_API void instr_set_app ( instr_t instr)

Sets instr as an application (non-meta) instruction. An application instruction might be mangled by DR if necessary, e.g., to create an exit stub for a branch instruction. All application instructions that are added to basic blocks or traces should have their translation fields set (via instr_set_translation()).

◆ instr_set_branch_target_pc()

DR_API void instr_set_branch_target_pc ( instr_t cti_instr,
app_pc  pc 
)

Set the taken target pc of the (direct branch) instruction.

◆ instr_set_category()

DR_API void instr_set_category ( instr_t instr,
uint  category 
)

Assumes category is a set of DR_INSTR_CATEGORY_ constants and sets it to be instr's category. See dr_instr_category_t.

◆ instr_set_dst()

DR_API void instr_set_dst ( instr_t instr,
uint  pos,
opnd_t  opnd 
)

Sets instr's destination operand at position pos to be opnd. Also calls instr_set_raw_bits_valid(instr, false) and instr_set_operands_valid(instr, true).

◆ instr_set_encoding_hint()

DR_API instr_t* instr_set_encoding_hint ( instr_t instr,
dr_encoding_hint_type_t  hint 
)

Each instruction may store a hint for how the instruction should be encoded if redundant encodings are available. This presumes that the user knows that a redundant encoding is available. This routine sets the hint for instr. Returns instr (for easy chaining).

◆ instr_set_isa_mode()

DR_API bool instr_set_isa_mode ( instr_t instr,
dr_isa_mode_t  mode 
)

Each instruction stores the processor mode under which it should be interpreted. This routine sets the mode for instr.

◆ instr_set_label_callback()

DR_API void instr_set_label_callback ( instr_t instr,
instr_label_callback_t  func 
)

Set a function func which is called when the label instruction is freed. instr is the label instruction allowing func to free the label's auxiliary data.

Note
This data field is not copied across instr_clone(). Instead, the clone's field will be NULL (xref i#3962).

◆ instr_set_meta()

DR_API void instr_set_meta ( instr_t instr)

Sets instr as a meta instruction. A meta instruction will not be mangled by DR in any way, which is necessary to have DR not create an exit stub for a branch instruction. Meta instructions should not fault (unless such faults are handled by the client) and are not considered application instructions but rather added instrumentation code (see dr_register_bb_event() for further information).

◆ instr_set_meta_may_fault()

DR_API void instr_set_meta_may_fault ( instr_t instr,
bool  val 
)
Deprecated:
Any meta instruction can fault if it has a non-NULL translation field and the client fully handles all of its faults, so this routine is no longer needed.

◆ instr_set_meta_no_translation()

DR_API void instr_set_meta_no_translation ( instr_t instr)

A convenience routine that calls both instr_set_meta (instr) and instr_set_translation (instr, NULL).

◆ instr_set_next()

DR_API INSTR_INLINE void instr_set_next ( instr_t instr,
instr_t next 
)

Sets the next field of instr to point to next.

◆ instr_set_note()

DR_API INSTR_INLINE void instr_set_note ( instr_t instr,
void *  value 
)

Sets the user-controlled note field in instr to value.

◆ instr_set_num_opnds()

DR_API void instr_set_num_opnds ( void *  drcontext,
instr_t instr,
int  num_dsts,
int  num_srcs 
)

Assumes that instr has been initialized but does not have any operands yet. Allocates storage for num_srcs source operands and num_dsts destination operands.

◆ instr_set_ok_to_emit()

DR_API void instr_set_ok_to_emit ( instr_t instr,
bool  val 
)

Set instr to "ok to emit" if val is true and "not ok to emit" if val is false. An instruction that should not be emitted is treated normally by DR for purposes of exits but is not placed into the cache. It is used for final jumps that are to be elided.

◆ instr_set_ok_to_mangle()

DR_API void instr_set_ok_to_mangle ( instr_t instr,
bool  val 
)

Sets instr to "ok to mangle" if val is true and "not ok to mangle" if val is false.

Deprecated:
instr_set_app()/instr_set_meta() should be used instead.

◆ instr_set_opcode()

DR_API void instr_set_opcode ( instr_t instr,
int  opcode 
)

Assumes opcode is an OP_ constant and sets it to be instr's opcode.

◆ instr_set_operands_valid()

DR_API void instr_set_operands_valid ( instr_t instr,
bool  valid 
)

Sets instr's operands to be valid if valid is true, invalid otherwise.

◆ instr_set_operation_size()

DR_API void instr_set_operation_size ( instr_t instr,
opnd_size_t  operation_size 
)

Sets the operation size of instr to operation_size only if instr is a DR_ISA_REGDEPS instruction.

◆ instr_set_predicate()

DR_API instr_t* instr_set_predicate ( instr_t instr,
dr_pred_type_t  pred 
)

Sets the predication for instr to the given DR_PRED_ constant. Returns instr if successful, or NULL if unsuccessful.

◆ instr_set_prefix_flag()

DR_API instr_t* instr_set_prefix_flag ( instr_t instr,
uint  prefix 
)

Assumes that prefix is a PREFIX_ constant. Ors instr's prefixes with prefix. Returns the supplied instr (for easy chaining).

◆ instr_set_prev()

DR_API INSTR_INLINE void instr_set_prev ( instr_t instr,
instr_t prev 
)

Sets the prev field of instr to point to prev.

◆ instr_set_raw_bits()

DR_API void instr_set_raw_bits ( instr_t instr,
byte *  addr,
uint  length 
)

Assumes that instr does not currently have any raw bits allocated. Sets instr's raw bits to be length bytes starting at addr. Does not set the operands invalid.

◆ instr_set_raw_bits_valid()

DR_API void instr_set_raw_bits_valid ( instr_t instr,
bool  valid 
)

Sets instr's raw bits to be valid if valid is true, invalid otherwise.

◆ instr_set_raw_byte()

DR_API void instr_set_raw_byte ( instr_t instr,
uint  pos,
byte  byte 
)

Assumes that instr's raw bits are valid and allocated by instr and have > pos bytes. Sets instr's raw byte at position pos (beginning with 0) to the value byte.

◆ instr_set_raw_bytes()

DR_API void instr_set_raw_bytes ( instr_t instr,
byte *  start,
uint  num_bytes 
)

Assumes that instr's raw bits are valid and allocated by instr and have >= num_bytes bytes. Copies the num_bytes beginning at start to instr's raw bits.

◆ instr_set_raw_word()

DR_API void instr_set_raw_word ( instr_t instr,
uint  pos,
uint  word 
)

Assumes that instr's raw bits are valid and allocated by instr and have > pos+3 bytes. Sets the 4 bytes beginning at position pos (0-based) to the value word.

◆ instr_set_src()

DR_API void instr_set_src ( instr_t instr,
uint  pos,
opnd_t  opnd 
)

Sets instr's source operand at position pos to be opnd. Also calls instr_set_raw_bits_valid(instr, false) and instr_set_operands_valid(instr, true).

◆ instr_set_target()

DR_API void instr_set_target ( instr_t cti_instr,
opnd_t  target 
)

Assumes that cti_instr is a control transfer instruction. Sets the first source operand of cti_instr to be target. Also calls instr_set_raw_bits_valid(instr, false) and instr_set_operands_valid(instr, true).

◆ instr_set_translation()

DR_API instr_t* instr_set_translation ( instr_t instr,
app_pc  addr 
)

Sets the translation pointer for instr, used to recreate the application address corresponding to this instruction. When adding or modifying instructions that are to be considered application instructions (i.e., non meta-instructions: see instr_is_app), the translation should always be set. Pick the application address that if executed will be equivalent to restarting instr. Currently the translation address must lie within the existing bounds of the containing code block. Returns the supplied instr (for easy chaining). Use instr_get_app_pc to see the current value of the translation.

◆ instr_set_x86_mode()

DR_API void instr_set_x86_mode ( instr_t instr,
bool  x86 
)

Each instruction stores whether it should be interpreted in 32-bit (x86) or 64-bit (x64) mode. This routine sets the mode for instr.

Note
For 64-bit DR builds only.
Deprecated:
Replaced by instr_set_isa_mode().

◆ instr_shrink_to_16_bits()

DR_API void instr_shrink_to_16_bits ( instr_t instr)

Shrinks all registers not used as addresses, and all immed integer and address sizes, to 16 bits. Does not shrink DR_REG_ESI or DR_REG_EDI used in string instructions.

◆ instr_shrink_to_32_bits()

DR_API void instr_shrink_to_32_bits ( instr_t instr)

Shrinks all registers, including addresses, and all immed integer and address sizes, to 32 bits.

Note
For 64-bit DR builds only.

◆ instr_uses_fp_reg()

DR_API bool instr_uses_fp_reg ( instr_t instr)

Returns true iff at least one of instr's operands references a floating point register.

◆ instr_uses_reg()

DR_API bool instr_uses_reg ( instr_t instr,
reg_id_t  reg 
)

Assumes that reg is a DR_REG_ constant. Returns true iff at least one of instr's operands references a register that overlaps reg.

Returns false for multi-byte nops with an operand using reg.

◆ instr_valid()

DR_API bool instr_valid ( instr_t instr)

Returns true iff instr's opcode is NOT OP_INVALID. Not to be confused with an invalid opcode, which can be OP_INVALID or OP_UNDECODED. OP_INVALID means an instruction with no valid fields: raw bits (may exist but do not correspond to a valid instr), opcode, eflags, or operands. It could be an uninitialized instruction or the result of decoding an invalid sequence of bytes.

◆ instr_writes_memory()

DR_API bool instr_writes_memory ( instr_t instr)

Returns true iff any of instr's destination operands is a memory reference. If instr is predicated (see instr_is_predicated()), the destination may not always be written.

◆ instr_writes_to_exact_reg()

DR_API bool instr_writes_to_exact_reg ( instr_t instr,
reg_id_t  reg,
dr_opnd_query_flags_t  flags 
)

Assumes that reg is a DR_REG_ constant. Returns true iff at least one of instr's destination operands is the same register (not enough to just overlap) as reg. Which operands are considered to be accessed for conditionally executed instructions are controlled by flags.

◆ instr_writes_to_reg()

DR_API bool instr_writes_to_reg ( instr_t instr,
reg_id_t  reg,
dr_opnd_query_flags_t  flags 
)

Assumes that reg is a DR_REG_ constant. Returns true iff at least one of instr's destination operands is a register operand for a register that overlaps reg. Which operands are considered to be accessed for conditionally executed instructions are controlled by flags.

◆ instr_zeroes_ymmh()

DR_API bool instr_zeroes_ymmh ( instr_t instr)

Returns true iff instr writes to an xmm register and zeroes the top half of the corresponding ymm register as a result (some instructions preserve the top half while others zero it when writing to the bottom half). This zeroing will occur even if instr is predicated (see instr_is_predicated()).

◆ instr_zeroes_zmmh()

DR_API bool instr_zeroes_zmmh ( instr_t instr)

Returns true iff instr writes to an xmm or ymm register and zeroes the top half of the corresponding zmm register as a result (some instructions preserve the top half while others zero it when writing to the bottom half). This zeroing will occur even if instr is predicated (see instr_is_predicated()).

DR_API byte * decode(void *drcontext, byte *pc, instr_t *instr)
DR_API void instr_noalloc_init(void *drcontext, instr_noalloc_t *instr)
#define EFLAGS_READ_AC
Definition: dr_ir_instr.h:2532
#define EFLAGS_WRITE_ALL
Definition: dr_ir_instr.h:2537
DR_API INSTR_INLINE instr_t * instr_from_noalloc(instr_noalloc_t *noalloc)
#define EFLAGS_WRITE_AC
Definition: dr_ir_instr.h:2533
#define EFLAGS_READ_ALL
Definition: dr_ir_instr.h:2535
Definition: dr_defines.h:378
Definition: dr_ir_instr.h:279