void CLG_(print_bbcc_fn)(BBCC* bbcc) { obj_node* obj; if (!bbcc) { VG_(printf)("%08x", 0); return; } VG_(printf)("%08lx/%c %d:", bb_addr(bbcc->bb), (bbcc->bb->sect_kind == Vg_SectText) ? 'T' : (bbcc->bb->sect_kind == Vg_SectData) ? 'D' : (bbcc->bb->sect_kind == Vg_SectBSS) ? 'B' : (bbcc->bb->sect_kind == Vg_SectGOT) ? 'G' : (bbcc->bb->sect_kind == Vg_SectPLT) ? 'P' : 'U', bbcc->cxt->base_number+bbcc->rec_index); print_mangled_cxt(bbcc->cxt, bbcc->rec_index); obj = bbcc->cxt->fn[0]->file->obj; if (obj->name[0]) VG_(printf)(" %s", obj->name+obj->last_slash_pos); if (VG_(strcmp)(bbcc->cxt->fn[0]->file->name, "???") !=0) { VG_(printf)(" %s", bbcc->cxt->fn[0]->file->name); if ((bbcc->cxt->fn[0] == bbcc->bb->fn) && (bbcc->bb->line>0)) VG_(printf)(":%d", bbcc->bb->line); } }
/* * Zero all costs of a BBCC */ void CLG_(zero_bbcc)(BBCC* bbcc) { Int i; jCC* jcc; CLG_ASSERT(bbcc->cxt != 0); CLG_DEBUG(1, " zero_bbcc: BB %#lx, Cxt %d " "(fn '%s', rec %d)\n", bb_addr(bbcc->bb), bbcc->cxt->base_number + bbcc->rec_index, bbcc->cxt->fn[0]->name, bbcc->rec_index); if ((bbcc->ecounter_sum ==0) && (bbcc->ret_counter ==0)) return; for(i=0;i<bbcc->bb->cost_count;i++) bbcc->cost[i] = 0; for(i=0;i <= bbcc->bb->cjmp_count;i++) { bbcc->jmp[i].ecounter = 0; for(jcc=bbcc->jmp[i].jcc_list; jcc; jcc=jcc->next_from) CLG_(init_cost)( CLG_(sets).full, jcc->cost ); } bbcc->ecounter_sum = 0; bbcc->ret_counter = 0; }
/* Lookup for a BBCC in hash. */ static BBCC* lookup_bbcc(BB* bb, Context* cxt) { BBCC* bbcc = bb->last_bbcc; UInt idx; /* check LRU */ if (bbcc->cxt == cxt) { if (!CLG_(clo).separate_threads) { /* if we don't dump threads separate, tid doesn't have to match */ return bbcc; } if (bbcc->tid == CLG_(current_tid)) return bbcc; } CLG_(stat).bbcc_lru_misses++; idx = bbcc_hash_idx(bb, cxt, current_bbccs.size); bbcc = current_bbccs.table[idx]; while (bbcc && (bb != bbcc->bb || cxt != bbcc->cxt)) { bbcc = bbcc->next; } CLG_DEBUG(2," lookup_bbcc(BB %#lx, Cxt %d, fn '%s'): %p (tid %d)\n", bb_addr(bb), cxt->base_number, cxt->fn[0]->name, bbcc, bbcc ? bbcc->tid : 0); CLG_DEBUGIF(2) if (bbcc) CLG_(print_bbcc)(-2,bbcc); return bbcc; }
void CLG_(print_bbcc)(int s, BBCC* bbcc, Bool jumpaddr) { BB* bb; if (s<0) { s = -s; print_indent(s); } if (!bbcc) { VG_(printf)("BBCC 0x0\n"); return; } bb = bbcc->bb; CLG_ASSERT(bb!=0); #if 0 if (jumpaddr) VG_(printf)("%s +%p=%p, ", bb->obj->name + bb->obj->last_slash_pos, bb->jmp_offset, bb_jmpaddr(bb)); else #endif VG_(printf)("%s +%p=%p, ", bb->obj->name + bb->obj->last_slash_pos, bb->offset, bb_addr(bb)); CLG_(print_cxt)(s+8, bbcc->cxt, bbcc->rec_index); }
void CLG_(print_bb)(int s, BB* bb) { if (s<0) { s = -s; print_indent(s); } VG_(printf)("BB %#lx (Obj '%s')", bb_addr(bb), bb->obj->name); }
void CLG_(print_short_jcc)(jCC* jcc) { if (jcc) VG_(printf)("%#lx => %#lx [%llu/%llu,%llu,%llu]", bb_jmpaddr(jcc->from->bb), bb_addr(jcc->to->bb), jcc->call_counter, jcc->cost ? jcc->cost[CLG_(sets).off_sim_Ir]:0, jcc->cost ? jcc->cost[CLG_(sets).off_sim_Dr]:0, jcc->cost ? jcc->cost[CLG_(sets).off_sim_Dw]:0); else VG_(printf)("[Skipped JCC]"); }
void CLG_(print_short_jcc)(jCC* jcc) { if (jcc) VG_(printf)("%#lx => %#lx [calls %llu/Ir %llu, Dr %llu, Dw %llu]", bb_jmpaddr(jcc->from->bb), bb_addr(jcc->to->bb), jcc->call_counter, jcc->cost ? jcc->cost[fullOffset(EG_IR)]:0, jcc->cost ? jcc->cost[fullOffset(EG_DR)]:0, jcc->cost ? jcc->cost[fullOffset(EG_DW)]:0); else VG_(printf)("[Skipped JCC]"); }
/* dump out the current call stack */ void CLG_(print_stackentry)(int s, int sp) { call_entry* ce; if (s<0) { s = -s; print_indent(s); } ce = CLG_(get_call_entry)(sp); VG_(printf)("[%-2d] SP %#lx, RA %#lx", sp, ce->sp, ce->ret_addr); if (ce->nonskipped) VG_(printf)(" NonSkipped BB %#lx / %s", bb_addr(ce->nonskipped->bb), ce->nonskipped->cxt->fn[0]->name); VG_(printf)("\n"); print_indent(s+5); CLG_(print_jcc)(5,ce->jcc); }
void CLG_(print_bbcc)(int s, BBCC* bbcc) { BB* bb; if (s<0) { s = -s; print_indent(s); } if (!bbcc) { VG_(printf)("BBCC 0x0\n"); return; } bb = bbcc->bb; CLG_ASSERT(bb!=0); VG_(printf)("%s +%#lx=%#lx, ", bb->obj->name + bb->obj->last_slash_pos, bb->offset, bb_addr(bb)); CLG_(print_cxt)(s+8, bbcc->cxt, bbcc->rec_index); }