dr_ir_instrlist.h File Reference

Functions to create and manipulate lists of instructions. More...

Functions

DR_API instrlist_tinstrlist_create (void *drcontext)
 
DR_API void instrlist_init (instrlist_t *ilist)
 
DR_API void instrlist_destroy (void *drcontext, instrlist_t *ilist)
 
DR_API void instrlist_clear (void *drcontext, instrlist_t *ilist)
 
DR_API void instrlist_clear_and_destroy (void *drcontext, instrlist_t *ilist)
 
DR_API void instrlist_set_translation_target (instrlist_t *ilist, app_pc pc)
 
DR_API app_pc instrlist_get_translation_target (instrlist_t *ilist)
 
DR_API void instrlist_set_auto_predicate (instrlist_t *ilist, dr_pred_type_t pred)
 
DR_API dr_pred_type_t instrlist_get_auto_predicate (instrlist_t *ilist)
 
DR_API instr_tinstrlist_first (instrlist_t *ilist)
 
DR_API instr_tinstrlist_first_app (instrlist_t *ilist)
 
DR_API instr_tinstrlist_first_nonlabel (instrlist_t *ilist)
 
DR_API instr_tinstrlist_last (instrlist_t *ilist)
 
DR_API instr_tinstrlist_last_app (instrlist_t *ilist)
 
DR_API void instrlist_cut (instrlist_t *ilist, instr_t *instr)
 
DR_API void instrlist_append (instrlist_t *ilist, instr_t *instr)
 
DR_API void instrlist_prepend (instrlist_t *ilist, instr_t *instr)
 
DR_API instrlist_tinstrlist_clone (void *drcontext, instrlist_t *old)
 
DR_API void instrlist_preinsert (instrlist_t *ilist, instr_t *where, instr_t *instr)
 
DR_API void instrlist_postinsert (instrlist_t *ilist, instr_t *where, instr_t *instr)
 
DR_API instr_tinstrlist_replace (instrlist_t *ilist, instr_t *oldinst, instr_t *newinst)
 
DR_API void instrlist_remove (instrlist_t *ilist, instr_t *instr)
 
DR_API bool instrlist_set_fall_through_target (instrlist_t *bb, app_pc tgt)
 
DR_API bool instrlist_set_return_target (instrlist_t *bb, app_pc tgt)
 

Detailed Description

Functions to create and manipulate lists of instructions.

Function Documentation

◆ instrlist_append()

DR_API void instrlist_append ( instrlist_t ilist,
instr_t instr 
)

Adds instr to the end of ilist.

◆ instrlist_clear()

DR_API void instrlist_clear ( void *  drcontext,
instrlist_t ilist 
)

Frees the instructions in ilist.

◆ instrlist_clear_and_destroy()

DR_API void instrlist_clear_and_destroy ( void *  drcontext,
instrlist_t ilist 
)

Destroys the instructions in ilist and destroys the instrlist_t object itself.

◆ instrlist_clone()

DR_API instrlist_t* instrlist_clone ( void *  drcontext,
instrlist_t old 
)

Allocates a new instrlist_t and for each instr_t in old allocates a new instr_t using instr_clone to produce a complete copy of old. Each operand that is opnd_is_instr() has its target updated to point to the corresponding instr_t in the new instrlist_t (this routine assumes that all such targets are contained within old, and may fault otherwise).

◆ instrlist_create()

DR_API instrlist_t* instrlist_create ( void *  drcontext)

Returns an initialized instrlist_t allocated on the thread-local heap.

◆ instrlist_cut()

DR_API void instrlist_cut ( instrlist_t ilist,
instr_t instr 
)

Cuts off subsequent instructions starting from instr from ilist.

◆ instrlist_destroy()

DR_API void instrlist_destroy ( void *  drcontext,
instrlist_t ilist 
)

Deallocates the thread-local heap storage for ilist.

◆ instrlist_first()

DR_API instr_t* instrlist_first ( instrlist_t ilist)

Returns the first instr_t in ilist.

◆ instrlist_first_app()

DR_API instr_t* instrlist_first_app ( instrlist_t ilist)

Returns the first application (non-meta) instruction in the instruction list ilist.

Note
All preceding meta instructions will be skipped.
We recommend using this routine during the phase of application code analysis, as any non-app 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.

◆ instrlist_first_nonlabel()

DR_API instr_t* instrlist_first_nonlabel ( instrlist_t ilist)

Returns the first instruction in the instruction list ilist for which instr_is_label() returns false.

◆ instrlist_get_auto_predicate()

DR_API dr_pred_type_t instrlist_get_auto_predicate ( instrlist_t ilist)

Returns the predicate for ilist.

◆ instrlist_get_translation_target()

DR_API app_pc instrlist_get_translation_target ( instrlist_t ilist)

Returns the translation target, or NULL if none is set.

◆ instrlist_init()

DR_API void instrlist_init ( instrlist_t ilist)

Initializes ilist.

◆ instrlist_last()

DR_API instr_t* instrlist_last ( instrlist_t ilist)

Returns the last instr_t in ilist.

◆ instrlist_last_app()

DR_API instr_t* instrlist_last_app ( instrlist_t ilist)

Returns the last application (non-meta) instruction in the instruction list ilist.

Note
All preceding meta instructions will be skipped.
We recommend using this routine during the phase of application code analysis, as any non-app 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.

◆ instrlist_postinsert()

DR_API void instrlist_postinsert ( instrlist_t ilist,
instr_t where,
instr_t instr 
)

Inserts instr into ilist after where.

◆ instrlist_preinsert()

DR_API void instrlist_preinsert ( instrlist_t ilist,
instr_t where,
instr_t instr 
)

Inserts instr into ilist prior to where.

◆ instrlist_prepend()

DR_API void instrlist_prepend ( instrlist_t ilist,
instr_t instr 
)

Adds instr to the front of ilist.

◆ instrlist_remove()

DR_API void instrlist_remove ( instrlist_t ilist,
instr_t instr 
)

Removes (does not destroy) instr from ilist.

◆ instrlist_replace()

DR_API instr_t* instrlist_replace ( instrlist_t ilist,
instr_t oldinst,
instr_t newinst 
)

Replaces oldinst with newinst in ilist (does not destroy oldinst).

◆ instrlist_set_auto_predicate()

DR_API void instrlist_set_auto_predicate ( instrlist_t ilist,
dr_pred_type_t  pred 
)

All future instructions inserted into ilist will be predicated with pred. This is a convenience routine to make it easy to have emitted code from internal DR components predicated.

Note
only has an effect on ARM
clients may not emit instrumentation that writes to flags, nor may clients insert cti's. Internal DR components such as dr_insert_clean_call() handle auto predication gracefully and are thus safe for use with auto predication.

◆ instrlist_set_fall_through_target()

DR_API bool instrlist_set_fall_through_target ( instrlist_t bb,
app_pc  tgt 
)

Specifies the fall-through target of a basic block if its last instruction is a conditional branch instruction. It can only be called in basic block building event callbacks when the for_trace parameter is false, and has NO EFFECT in other cases.

◆ instrlist_set_return_target()

DR_API bool instrlist_set_return_target ( instrlist_t bb,
app_pc  tgt 
)

Specifies the return target of a basic block if its last instruction is a call instruction. It can only be called in basic block building event callbacks when the for_trace parameter is false, and has NO EFFECT in other cases.

◆ instrlist_set_translation_target()

DR_API void instrlist_set_translation_target ( instrlist_t ilist,
app_pc  pc 
)

All future instructions inserted into ilist that do not have raw bits will have instr_set_translation() called with pc as the target. This is a convenience routine to make it easy to have the same code generate non-translation and translation instructions, and it does not try to enforce that all instructions have translations (e.g., some could be inserted via instr_set_next()).