Actually, I should ensure a program can run normally. This program may include multiple condition branches. At every conditon branch, I need to collect the memory access trace of a basic block along the flipped direction of the branch, and after that I need to make the program recover from this flipped direction. However, using
instr_invert_cbr directly will trigger a exception and interrupt the program. So, how should I do ?
Now, to collect the memory access trace of a basic block along the flipped direction of the branch, I insert part of memtrace_x86.c code ( in bold below) into at_not_taken function of cbr.c. (I also upload an attachment for this. )
But, the Instrumentation results show " saw 0 memory references" .
/* Clean call for the 'not taken' case */
static void at_not_taken(app_pc src, app_pc fall)
{
dr_mcontext_t mcontext = {
sizeof(mcontext),
DR_MC_ALL,
};
void *drcontext = dr_get_current_drcontext();
app_pc trans_pc = fall;
instrlist_t * trans_bb = decode_as_bb(drcontext,trans_pc);
instr_t *trans_instr, *trans_next;
int i = 0;
for (trans_instr = instrlist_first(trans_bb);
trans_instr != NULL;
trans_instr = instr_get_next(trans_instr)) {
if (instr_reads_memory(trans_instr)) {
for (i = 0; i < instr_num_srcs(trans_instr); i++) {
if (opnd_is_memory_reference(instr_get_src(trans_instr, i))) {
instrument_mem(drcontext, trans_bb, trans_instr, i, false);
}
}
}
if (instr_writes_memory(trans_instr)) {
for (i = 0; i < instr_num_dsts(trans_instr); i++) {
if (opnd_is_memory_reference(instr_get_dst(trans_instr, i))) {
instrument_mem(drcontext, trans_bb, trans_instr, i, true);
}
}
}
}
/*
* Record the fact that we've seen the not_taken case.
*/
elem_t *elem = lookup(global_table, src);
ASSERT(elem != NULL);
elem->state |= CBR_NOT_TAKEN;
/*