core/x86/instr.c
/* If instr is not an exit cti, does nothing.  
 * If instr is an exit cti, sets stub to be custom exit stub code
 * that will be inserted in the exit stub prior to the normal exit
 * stub code.  If instr already has custom exit stub code, that
 * existing instrlist_t is cleared and destroyed (using current thread's
 * context).  (If stub is NULL, any existing stub code is NOT destroyed.)
 * The creator of the instrlist_t containing instr is
 * responsible for destroying stub.  
 */
If instr is not an exit cti, does nothing.
If instr is an exit cti, sets stub to be custom exit stub code
that will be inserted in the exit stub prior to the normal exit
stub code.  If instr already has custom exit stub code, that
existing instrlist_t is cleared and destroyed (using current thread's
context).  (If stub is NULL, any existing stub code is NOT destroyed.)
The creator of the instrlist_t containing instr is
responsible for destroying stub.
If instr is not an exit cti does nothing . If instr is an exit cti sets stub to be custom exit stub code that will be inserted in the exit stub prior to the normal exit stub code . If instr already has custom exit stub code that existing instrlist_t is cleared and destroyed ( using current thread ' s context ) . ( If stub is NULL any existing stub code is NOT destroyed . ) The creator of the instrlist_t containing instr is responsible for destroying stub .
void
instr_set_exit_stub_code(instr_t *instr, instrlist_t *stub)
{
    CLIENT_ASSERT(instr_is_cbr(instr) || instr_is_ubr(instr),
                  "instr_set_exit_stub_code called on non-exit");
    CLIENT_ASSERT(instr->num_dsts == 0, "instr_set_exit_stub_code: instr invalid");
    if (stub != NULL && (instr->flags & INSTR_HAS_CUSTOM_STUB) != 0) {
        instrlist_t *existing = (instrlist_t *) instr->dsts;
        instrlist_clear_and_destroy(get_thread_private_dcontext(), existing);
    }
    if (stub == NULL) {
        instr->flags &= ~INSTR_HAS_CUSTOM_STUB;
        instr->dsts = NULL;
    } else {
        instr->flags |= INSTR_HAS_CUSTOM_STUB;
        instr->dsts = (opnd_t *) stub;
    }
}
void instr_set_exit_stub_code ( instr_t * instr , instrlist_t * stub ) { CLIENT_ASSERT ( instr_is_cbr ( instr ) || instr_is_ubr ( instr ) , " " ) ; CLIENT_ASSERT ( instr -> num_dsts == 0 , " " ) ; if ( stub != NULL && ( instr -> flags & INSTR_HAS_CUSTOM_STUB ) != 0 ) { instrlist_t * existing = ( instrlist_t * ) instr -> dsts ; instrlist_clear_and_destroy ( get_thread_private_dcontext ( ) , existing ) ; } if ( stub == NULL ) { instr -> flags &= ~ INSTR_HAS_CUSTOM_STUB ; instr -> dsts = NULL ; } else { instr -> flags |= INSTR_HAS_CUSTOM_STUB ; instr -> dsts = ( opnd_t * ) stub ; } }
If instr is not an exit cti, does nothing.
If instr is not an exit cti does nothing .
/* HACK: dsts array is NULL, so we use the dsts pointer
     * FIXME: put checks in set_num_opnds, etc. that may overwrite this?
     * FIXME: make separate call to clear existing stubs?
     * having it not clear for stub==NULL a little hacky
     */ /* delete existing */