dr_ir_instrlist.h File Reference

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


Functions

instrlist_t * instrlist_create (void *drcontext)
void instrlist_init (instrlist_t *ilist)
void instrlist_destroy (void *drcontext, instrlist_t *ilist)
void instrlist_clear (void *drcontext, instrlist_t *ilist)
void instrlist_clear_and_destroy (void *drcontext, instrlist_t *ilist)
void instrlist_set_translation_target (instrlist_t *ilist, app_pc pc)
app_pc instrlist_get_translation_target (instrlist_t *ilist)
instr_tinstrlist_first (instrlist_t *ilist)
instr_tinstrlist_last (instrlist_t *ilist)
void instrlist_append (instrlist_t *ilist, instr_t *instr)
void instrlist_prepend (instrlist_t *ilist, instr_t *instr)
instrlist_t * instrlist_clone (void *drcontext, instrlist_t *old)
void instrlist_preinsert (instrlist_t *ilist, instr_t *where, instr_t *instr)
void instrlist_postinsert (instrlist_t *ilist, instr_t *where, instr_t *instr)
instr_tinstrlist_replace (instrlist_t *ilist, instr_t *oldinst, instr_t *newinst)
void instrlist_remove (instrlist_t *ilist, instr_t *instr)
void instrlist_disassemble (void *drcontext, app_pc tag, instrlist_t *ilist, file_t outfile)
byte * instrlist_encode (void *drcontext, instrlist_t *ilist, byte *pc, bool has_instr_jmp_targets)


Detailed Description

Functions to create and manipulate lists of instructions.


Function Documentation

void instrlist_append ( instrlist_t *  ilist,
instr_t instr 
)

Adds instr to the end of ilist.

void instrlist_clear ( void *  drcontext,
instrlist_t *  ilist 
)

Frees the instructions in ilist.

void instrlist_clear_and_destroy ( void *  drcontext,
instrlist_t *  ilist 
)

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

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_t* instrlist_create ( void *  drcontext  ) 

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

void instrlist_destroy ( void *  drcontext,
instrlist_t *  ilist 
)

Deallocates the thread-local heap storage for ilist.

void instrlist_disassemble ( void *  drcontext,
app_pc  tag,
instrlist_t *  ilist,
file_t  outfile 
)

Prints each instruction in ilist in sequence to outfile. The default is to use AT&T-style syntax, unless the -syntax_intel runtime option is specified.

byte* instrlist_encode ( void *  drcontext,
instrlist_t *  ilist,
byte *  pc,
bool  has_instr_jmp_targets 
)

Encodes each instruction in ilist in turn in contiguous memory starting at pc. Returns the pc after all of the encodings, or NULL if any one of the encodings failed. Uses the x86/x64 mode stored in each instr, not the mode of the current thread. In order for instr_t operands to be encoded properly, has_instr_jmp_targets must be true. If has_instr_jmp_targets is true, the note field of each instr_t in ilist will be overwritten, and if any instr_t targets are not in ilist, they must have their note fields set with their offsets relative to pc.

instr_t* instrlist_first ( instrlist_t *  ilist  ) 

Returns the first instr_t in ilist.

app_pc instrlist_get_translation_target ( instrlist_t *  ilist  ) 

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

void instrlist_init ( instrlist_t *  ilist  ) 

Initializes ilist.

instr_t* instrlist_last ( instrlist_t *  ilist  ) 

Returns the last instr_t in ilist.

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

Inserts instr into ilist after where.

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

Inserts instr into ilist prior to where.

void instrlist_prepend ( instrlist_t *  ilist,
instr_t instr 
)

Adds instr to the front of ilist.

void instrlist_remove ( instrlist_t *  ilist,
instr_t instr 
)

Removes (does not destroy) instr from ilist.

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

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

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()).


  DynamoRIO API version 2.0.0 --- Thu Apr 22 00:18:18 2010