/* Insert/Inc. the usage of bbls and the exit status of a bbl */ VOID BblExit_Info(ADDRINT bbl_addr, ADDRINT trace_addr) { TRACE_MAP::iterator tr_it = Trace_Information.find(trace_addr); assert( tr_it != Trace_Information.end() ); TRACE_INFO& tr_info = tr_it->second; BBL_MAP& Bbl_Information = tr_info.bbl_info; BBL_MAP::iterator bbl_it = Bbl_Information.begin(); for (; bbl_it != Bbl_Information.end(); bbl_it++) { BBL_INFO& bbl_info = bbl_it->second; /* Inc usage of every bbl above the exit bbl for it is utilized */ bbl_info.exec_cnt++; /* The exit bbl itself */ if (bbl_addr == bbl_it->first) { bbl_info.bbl_exit_cnt++; return; } } assert( bbl_it != Bbl_Information.end() ); }
/* Inc. the counter for a trace when the trace is short and results in the program falling off the trace and into a new trace */ VOID TraceFall_Info(ADDRINT trace_addr) { TRACE_MAP::iterator tr_it = Trace_Information.find(trace_addr); assert( tr_it == Trace_Information.end() ); TRACE_INFO& tr_info = tr_it->second; tr_info.fall_cnt++; }
/* Insert/Inc. the usage of a trace */ VOID Trace_Info(ADDRINT trace_addr, UINT32 bbl_cnt, UINT32 ins_cnt) { TRACE_MAP::iterator it = Trace_Information.find(trace_addr); // First visit if (it == Trace_Information.end()) { TRACE_INFO tr_info; tr_info.bbl_cnt = bbl_cnt; tr_info.ins_cnt = ins_cnt; tr_info.exec_cnt = 0; Trace_Information.insert( make_pair(trace_addr, tr_info) ); } else { it->second.exec_cnt++; } }
/* Insert a new bbl record into the trace record */ VOID Bbl_Info(ADDRINT bbl_addr, UINT32 ins_cnt, ADDRINT trace_addr, UINT32 code_size, UINT32 accum_code_size) { TRACE_MAP::iterator tr_it = Trace_Information.find(trace_addr); assert( tr_it != Trace_Information.end() ); TRACE_INFO& tr_info = tr_it->second; BBL_MAP& Bbl_Information = tr_info.bbl_info; BBL_MAP::iterator bbl_it = Bbl_Information.find(bbl_addr); if (bbl_it == Bbl_Information.end()) { BBL_INFO bbl_info; bbl_info.ins_cnt = ins_cnt; bbl_info.code_size = code_size; bbl_info.accum_code_size = accum_code_size; bbl_info.exec_cnt = 0; bbl_info.bbl_exit_cnt = 0; Bbl_Information.insert(make_pair(bbl_addr, bbl_info)); } }
/* Output the trace usage to a file */ VOID DumpTraceInfo(INT32 code, VOID *v) { for_each(Trace_Information.begin(), Trace_Information.end(), PrintTrace); }