Lines Matching refs:CLG_
49 CommandLineOptions CLG_(clo);
50 Statistics CLG_(stat);
51 Bool CLG_(instrument_state) = True; /* Instrumentation on ? */
54 exec_state CLG_(current_state);
58 Int CLG_(min_line_size) = 0;
65 static void CLG_(init_statistics)(Statistics* s)
115 CLG_(bb_base) + ii->instr_offset, ii->instr_size);
117 if (!CLG_(current_state).collect) return;
121 CLG_(current_state).cost[ fullOffset(EG_BUS) ]++;
123 if (CLG_(current_state).nonskipped)
124 cost_Bus = CLG_(current_state).nonskipped->skipped + fullOffset(EG_BUS);
126 cost_Bus = CLG_(cost_base) + ii->cost_offset + ii->eventset->offset[EG_BUS];
144 CLG_(bb_base) + ii->instr_offset, taken);
146 miss = 1 & do_cond_branch_predict(CLG_(bb_base) + ii->instr_offset, taken);
148 if (!CLG_(current_state).collect) return;
152 if (CLG_(current_state).nonskipped)
153 cost_Bc = CLG_(current_state).nonskipped->skipped + fullOffset(EG_BC);
155 cost_Bc = CLG_(cost_base) + ii->cost_offset + ii->eventset->offset[EG_BC];
158 CLG_(current_state).cost[ fullOffset_Bc ]++;
161 CLG_(current_state).cost[ fullOffset_Bc+1 ]++;
174 CLG_(bb_base) + ii->instr_offset, actual_dst);
176 miss = 1 & do_ind_branch_predict(CLG_(bb_base) + ii->instr_offset, actual_dst);
178 if (!CLG_(current_state).collect) return;
182 if (CLG_(current_state).nonskipped)
183 cost_Bi = CLG_(current_state).nonskipped->skipped + fullOffset(EG_BI);
185 cost_Bi = CLG_(cost_base) + ii->cost_offset + ii->eventset->offset[EG_BI];
188 CLG_(current_state).cost[ fullOffset_Bi ]++;
191 CLG_(current_state).cost[ fullOffset_Bi+1 ]++;
399 ev->inode->eventset = CLG_(sets).base;
403 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
409 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
414 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
419 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
424 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
471 helperName = CLG_(cachesim).log_1I1Dr_name;
472 helperAddr = CLG_(cachesim).log_1I1Dr;
483 helperName = CLG_(cachesim).log_1I1Dw_name;
484 helperAddr = CLG_(cachesim).log_1I1Dw;
494 helperName = CLG_(cachesim).log_3I0D_name;
495 helperAddr = CLG_(cachesim).log_3I0D;
505 helperName = CLG_(cachesim).log_2I0D_name;
506 helperAddr = CLG_(cachesim).log_2I0D;
514 helperName = CLG_(cachesim).log_1I0D_name;
515 helperAddr = CLG_(cachesim).log_1I0D;
523 helperName = CLG_(cachesim).log_0I1Dr_name;
524 helperAddr = CLG_(cachesim).log_0I1Dr;
534 helperName = CLG_
535 helperAddr = CLG_(cachesim).log_0I1Dw;
604 if (!CLG_(clo).simulate_cache) return;
622 if (!CLG_(clo).simulate_cache) return;
623 tl_assert(datasize <= CLG_(min_line_size));
644 if (!CLG_(clo).simulate_cache) return;
645 tl_assert(datasize <= CLG_(min_line_size));
681 if (!CLG_(clo).simulate_cache) return;
682 tl_assert(datasize <= CLG_(min_line_size));
701 helperName = isWrite ? CLG_(cachesim).log_0I1Dw_name
702 : CLG_(cachesim).log_0I1Dr_name;
703 helperAddr = isWrite ? CLG_(cachesim).log_0I1Dw
704 : CLG_(cachesim).log_0I1Dr;
723 if (!CLG_(clo).simulate_branch) return;
743 if (!CLG_(clo).simulate_branch) return;
760 if (!CLG_(clo).collect_bus) return;
799 CLG_(stat).distinct_instrs++;
859 * Called from CLG_(get_bb)
861 void CLG_(collectBlockInfo)(IRSB* sbIn,
946 VG_(fnptr_to_fnentry)( & CLG_(setup_bbcc) ),
953 IRSB* CLG_(instrument)( VgCallbackClosure* closure,
974 if (! CLG_(instrument_state)) {
1007 clgs.bb = CLG_(get_bb)(origAddr, sbIn, &(clgs.seen_before));
1107 if (CLG_(clo).simulate_cache && dataSize > CLG_(min_line_size))
1108 dataSize = CLG_(min_line_size);
1174 * This heuristic is precalculated in CLG_(collectBlockInfo)().
1249 (UWord) &CLG_(current_state).jmps_passed,
1295 * As CLG_(current_state).jmps_passed is reset to 0 in setup_bbcc,
1303 (UWord) &CLG_(current_state).jmps_passed,
1385 CLG_(delete_bb)(vge.base[0]);
1390 /*--- CLG_(fini)() and related function ---*/
1399 for(i = 0; i < CLG_(current_call_stack).sp; i++) {
1400 if (!CLG_(current_call_stack).entry[i].jcc) continue;
1403 CLG_(copy_cost)( CLG_(sets).full,
1404 CLG_(current_call_stack).entry[i].enter_cost,
1405 CLG_(current_state).cost );
1406 CLG_(current_call_stack).entry[i].jcc->call_counter = 0;
1409 CLG_(forall_bbccs)(CLG_(zero_bbcc));
1412 CLG_(copy_cost)( CLG_(sets).full,
1413 t->lastdump_cost, CLG_(current_state).cost );
1416 void CLG_(zero_all_cost)(Bool only_current_thread)
1422 zero_thread_cost(CLG_(get_current_thread)());
1424 CLG_(forall_threads)(zero_thread_cost);
1434 while(CLG_(current_state).sig !=0)
1435 CLG_(post_signal)(CLG_(current_tid),CLG_(current_state).sig);
1438 while(CLG_(current_call_stack).sp>0)
1439 CLG_(pop_call_stack)();
1442 CLG_(init_exec_state)( &CLG_(current_state) );
1443 CLG_(current_fn_stack).top = CLG_(current_fn_stack).bottom;
1449 CLG_(zero_cost)( CLG_(sets).full, CLG_(current_state).cost );
1452 void CLG_(set_instrument_state)(const HChar* reason, Bool state)
1454 if (CLG_(instrument_state) == state) {
1459 CLG_(instrument_state) = state;
1466 CLG_(forall_threads)(unwind_thread);
1467 CLG_(forall_threads)(zero_state_cost);
1468 (*CLG_(cachesim).clear)();
1484 t = CLG_(current_tid);
1485 CLG_(init_cost_lz)( CLG_(sets).full, &sum );
1486 CLG_(copy_cost_lz)( CLG_(sets).full, &tmp, ti->lastdump_cost );
1487 CLG_(add_diff_cost)( CLG_(sets).full, sum, ti->lastdump_cost,
1489 CLG_(copy_cost)( CLG_(sets).full, ti->lastdump_cost, tmp );
1490 mcost = CLG_(mappingcost_as_string)(CLG_(dumpmap), sum);
1493 VG_(gdb_printf)("frames-%d: %d\n", t, CLG_(current_call_stack).sp);
1496 for(i = 0; i < CLG_(current_call_stack).sp; i++) {
1497 ce = CLG_(get_call_entry)(i);
1506 CLG_(copy_cost)( CLG_(sets).full, sum, ce->jcc->cost );
1507 CLG_(copy_cost)( CLG_(sets).full, tmp, ce->enter_cost );
1508 CLG_(add_diff_cost)( CLG_(sets).full, sum,
1509 ce->enter_cost, CLG_(current_state).cost );
1510 CLG_(copy_cost)( CLG_(sets).full, ce->enter_cost, tmp );
1512 mcost = CLG_(mappingcost_as_string)(CLG_(dumpmap), sum);
1527 Int orig_tid = CLG_(current_tid);
1530 CLG_(instrument_state) ? "on":"off");
1531 if (!CLG_(instrument_state)) return;
1533 VG_(gdb_printf)("executed-bbs: %llu\n", CLG_(stat).bb_executions);
1534 VG_(gdb_printf)("executed-calls: %llu\n", CLG_(stat).call_counter);
1535 VG_(gdb_printf)("distinct-bbs: %d\n", CLG_(stat).distinct_bbs);
1536 VG_(gdb_printf)("distinct-calls: %d\n", CLG_(stat).distinct_jccs);
1537 VG_(gdb_printf)("distinct-functions: %d\n", CLG_(stat).distinct_fns);
1538 VG_(gdb_printf)("distinct-contexts: %d\n", CLG_
1541 HChar *evmap = CLG_(eventmapping_as_string)(CLG_(dumpmap));
1545 VG_(gdb_printf)("part: %d\n", CLG_(get_dump_counter)());
1548 th = CLG_(get_threads)();
1556 CLG_(forall_threads)(dump_state_of_thread_togdb);
1595 CLG_(dump_profile)(req, False);
1599 CLG_(zero_all_cost)(False);
1611 if (!CLG_(instrument_state)) {
1615 thread_info** th = CLG_(get_threads)();
1628 CLG_(instrument_state) ? "on":"off");
1631 CLG_(set_instrument_state)("Command", VG_(strcmp)(arg,"off")!=0);
1642 Bool CLG_(handle_client_request)(ThreadId tid, UWord *args, UWord *ret)
1650 CLG_(dump_profile)("Client Request", True);
1659 CLG_(dump_profile)(buf, True);
1665 CLG_(zero_all_cost)(True);
1670 CLG_(current_state).collect = !CLG_(current_state).collect;
1672 CLG_(current_state).collect ? "ON" : "OFF");
1677 CLG_(set_instrument_state)("Client Request", True);
1682 CLG_(set_instrument_state)("Client Request", False);
1712 void CLG_(pre_syscalltime)(ThreadId tid, UInt syscallno,
1715 if (CLG_(clo).collect_systime) {
1727 void CLG_(post_syscalltime)(ThreadId tid, UInt syscallno,
1730 if (CLG_(clo).collect_systime &&
1731 CLG_(current_state).bbcc) {
1749 CLG_(current_state).cost[o] ++;
1750 CLG_(current_state).cost[o+1] += diff;
1751 if (!CLG_(current_state).bbcc->skipped)
1752 CLG_(init_cost_lz)(CLG_(sets).full,
1753 &(CLG_(current_state).bbcc->skipped));
1754 CLG_(current_state).bbcc->skipped[o] ++;
1755 CLG_(current_state).bbcc->skipped[o+1] += diff;
1778 total = CLG_(total_cost);
1810 CLG_(stat).full_debug_BBs +
1811 CLG_(stat).fn_name_debug_BBs +
1812 CLG_(stat).file_line_debug_BBs +
1813 CLG_(stat).no_debug_BBs;
1817 CLG_(stat).distinct_objs);
1819 CLG_(stat).distinct_files);
1821 CLG_(stat).distinct_fns);
1823 CLG_(stat).distinct_contexts);
1825 CLG_(stat).distinct_bbs);
1827 CLG_(costarray_entries), CLG_(costarray_chunks));
1829 CLG_(stat).distinct_bbccs);
1831 CLG_(stat).distinct_jccs);
1833 CLG_(stat).distinct_skips);
1838 CLG_(stat).full_debug_BBs * 100 / BB_lookups,
1839 CLG_(stat).full_debug_BBs);
1841 CLG_(stat).file_line_debug_BBs * 100 / BB_lookups,
1842 CLG_(stat).file_line_debug_BBs);
1844 CLG_(stat).fn_name_debug_BBs * 100 / BB_lookups,
1845 CLG_(stat).fn_name_debug_BBs);
1847 CLG_(stat).no_debug_BBs * 100 / BB_lookups,
1848 CLG_(stat).no_debug_BBs);
1851 CLG_(stat).bbcc_clones);
1853 CLG_(stat).bb_retranslations);
1855 CLG_(stat).distinct_instrs);
1858 CLG_(stat).cxt_lru_misses);
1860 CLG_(stat).bbcc_lru_misses);
1862 CLG_(stat).jcc_lru_misses);
1864 CLG_(stat).bb_executions);
1866 CLG_(stat).call_counter);
1868 CLG_(stat).jcnd_counter);
1870 CLG_(stat).jump_counter);
1872 CLG_(stat).rec_call_counter);
1874 CLG_(stat).ret_counter);
1887 (*CLG_(cachesim).finish)();
1891 CLG_(forall_threads)(unwind_thread);
1893 CLG_(dump_profile)(0, False);
1903 HChar *evmap = CLG_(eventmapping_as_string)(CLG_(dumpmap));
1906 HChar *mcost = CLG_(mappingcost_as_string)(CLG_(dumpmap), CLG_(total_cost));
1912 total = CLG_(total_cost);
1915 if (CLG_(clo).simulate_cache) {
1919 if (CLG_(clo).simulate_branch) {
1932 if (CLG_(clo).simulate_cache)
1933 (*CLG_(cachesim).printstat)(l1, l2, l3);
1935 if (CLG_(clo).simulate_branch)
1941 void CLG_(fini)(Int exitcode)
1958 /* throttle calls to CLG_(run_thread) by number of BBs executed */
1962 CLG_(run_thread)( tid );
1966 void CLG_(post_clo_init)(void)
2000 CLG_DEBUG(1, " dump threads: %s\n", CLG_(clo).separate_threads ? "Yes":"No");
2001 CLG_DEBUG(1, " call sep. : %d\n", CLG_(clo).separate_callers);
2002 CLG_DEBUG(1, " rec. sep. : %d\n", CLG_(clo).separate_recursions);
2004 if (!CLG_(clo).dump_line && !CLG_(clo).dump_instr && !CLG_(clo).dump_bb) {
2006 CLG_(clo).dump_line = True;
2009 CLG_(init_dumps)();
2011 (*CLG_(cachesim).post_clo_init)();
2013 CLG_(init_eventsets)();
2014 CLG_(init_statistics)(& CLG_(stat));
2015 CLG_(init_cost_lz)( CLG_(sets).full, &CLG_(total_cost) );
2018 CLG_(init_obj_table)();
2019 CLG_(init_cxt_table)();
2020 CLG_(init_bb_hash)();
2022 CLG_(init_threads)();
2023 CLG_(run_thread)(1);
2025 CLG_(instrument_state) = CLG_(clo).instrument_atstart;
2036 void CLG_(pre_clo_init)(void)
2053 VG_(basic_tool_funcs) (CLG_(post_clo_init),
2054 CLG_(instrument),
2055 CLG_(fini));
2060 VG_(needs_command_line_options)(CLG_(process_cmd_line_option),
2061 CLG_(print_usage),
2062 CLG_(print_debug_usage));
2064 VG_(needs_client_requests)(CLG_(handle_client_request));
2066 VG_(needs_syscall_wrapper)(CLG_(pre_syscalltime),
2067 CLG_(post_syscalltime));
2070 VG_(track_pre_deliver_signal) ( & CLG_(pre_signal) );
2071 VG_(track_post_deliver_signal)( & CLG_(post_signal) );
2073 CLG_(set_clo_defaults)();
2082 VG_DETERMINE_INTERFACE_VERSION(CLG_(pre_clo_init))