Lines Matching defs:CLG_
48 CommandLineOptions CLG_(clo);
49 Statistics CLG_(stat);
50 Bool CLG_(instrument_state) = True; /* Instrumentation on ? */
53 exec_state CLG_(current_state);
57 Int CLG_(min_line_size) = 0;
64 static void CLG_(init_statistics)(Statistics* s)
114 CLG_(bb_base) + ii->instr_offset, ii->instr_size);
116 if (!CLG_(current_state).collect) return;
120 CLG_(current_state).cost[ fullOffset(EG_BUS) ]++;
122 if (CLG_(current_state).nonskipped)
123 cost_Bus = CLG_(current_state).nonskipped->skipped + fullOffset(EG_BUS);
125 cost_Bus = CLG_(cost_base) + ii->cost_offset + ii->eventset->offset[EG_BUS];
143 CLG_(bb_base) + ii->instr_offset, taken);
145 miss = 1 & do_cond_branch_predict(CLG_(bb_base) + ii->instr_offset, taken);
147 if (!CLG_(current_state).collect) return;
151 if (CLG_(current_state).nonskipped)
152 cost_Bc = CLG_(current_state).nonskipped->skipped + fullOffset(EG_BC);
154 cost_Bc = CLG_(cost_base) + ii->cost_offset + ii->eventset->offset[EG_BC];
157 CLG_(current_state).cost[ fullOffset_Bc ]++;
160 CLG_(current_state).cost[ fullOffset_Bc+1 ]++;
173 CLG_(bb_base) + ii->instr_offset, actual_dst);
175 miss = 1 & do_ind_branch_predict(CLG_(bb_base) + ii->instr_offset, actual_dst);
177 if (!CLG_(current_state).collect) return;
181 if (CLG_(current_state).nonskipped)
182 cost_Bi = CLG_(current_state).nonskipped->skipped + fullOffset(EG_BI);
184 cost_Bi = CLG_(cost_base) + ii->cost_offset + ii->eventset->offset[EG_BI];
187 CLG_(current_state).cost[ fullOffset_Bi ]++;
190 CLG_(current_state).cost[ fullOffset_Bi+1 ]++;
398 ev->inode->eventset = CLG_(sets).base;
402 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
408 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
413 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
418 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
423 ev->inode->eventset = CLG_(add_event_group)(ev->inode->eventset,
470 helperName = CLG_(cachesim).log_1I1Dr_name;
471 helperAddr = CLG_(cachesim).log_1I1Dr;
482 helperName = CLG_(cachesim).log_1I1Dw_name;
483 helperAddr = CLG_(cachesim).log_1I1Dw;
493 helperName = CLG_(cachesim).log_3I0D_name;
494 helperAddr = CLG_(cachesim).log_3I0D;
504 helperName = CLG_(cachesim).log_2I0D_name;
505 helperAddr = CLG_(cachesim).log_2I0D;
513 helperName = CLG_(cachesim).log_1I0D_name;
514 helperAddr = CLG_(cachesim).log_1I0D;
522 helperName = CLG_(cachesim).log_0I1Dr_name;
523 helperAddr = CLG_(cachesim).log_0I1Dr;
533 helperName = CLG_(cachesim).log_0I1Dw_name;
534 helperAddr = CLG_(cachesim).log_0I1Dw;
603 if (!CLG_(clo).simulate_cache) return;
621 if (!CLG_(clo).simulate_cache) return;
622 tl_assert(datasize <= CLG_(min_line_size));
643 if (!CLG_(clo).simulate_cache) return;
644 tl_assert(datasize <= CLG_(min_line_size));
678 if (!CLG_(clo).simulate_branch) return;
698 if (!CLG_(clo).simulate_branch) return;
715 if (!CLG_(clo).collect_bus) return;
754 CLG_(stat).distinct_instrs++;
814 * Called from CLG_(get_bb)
816 void CLG_(collectBlockInfo)(IRSB* sbIn,
901 VG_(fnptr_to_fnentry)( & CLG_(setup_bbcc) ),
908 IRSB* CLG_(instrument)( VgCallbackClosure* closure,
928 if (! CLG_(instrument_state)) {
961 clgs.bb = CLG_(get_bb)(origAddr, sbIn, &(clgs.seen_before));
1036 if (CLG_(clo).simulate_cache && dataSize > CLG_(min_line_size))
1037 dataSize = CLG_(min_line_size);
1101 * This heuristic is precalculated in CLG_(collectBlockInfo)().
1175 (UWord) &CLG_(current_state).jmps_passed,
1227 (UWord) &CLG_(current_state).jmps_passed,
1309 CLG_(delete_bb)(orig_addr);
1314 /*--- CLG_(fini)() and related function ---*/
1323 for(i = 0; i < CLG_(current_call_stack).sp; i++) {
1324 if (!CLG_(current_call_stack).entry[i].jcc) continue;
1327 CLG_(copy_cost)( CLG_(sets).full,
1328 CLG_(current_call_stack).entry[i].enter_cost,
1329 CLG_(current_state).cost );
1330 CLG_(current_call_stack).entry[i].jcc->call_counter = 0;
1333 CLG_(forall_bbccs)(CLG_(zero_bbcc));
1336 CLG_(copy_cost)( CLG_(sets).full,
1337 t->lastdump_cost, CLG_(current_state).cost );
1340 void CLG_(zero_all_cost)(Bool only_current_thread)
1346 zero_thread_cost(CLG_(get_current_thread)());
1348 CLG_(forall_threads)(zero_thread_cost);
1358 while(CLG_(current_state).sig !=0)
1359 CLG_(post_signal)(CLG_(current_tid),CLG_(current_state).sig);
1362 while(CLG_(current_call_stack).sp>0)
1363 CLG_(pop_call_stack)();
1366 CLG_(init_exec_state)( &CLG_(current_state) );
1367 CLG_(current_fn_stack).top = CLG_(current_fn_stack).bottom;
1373 CLG_(zero_cost)( CLG_(sets).full, CLG_(current_state).cost );
1379 void CLG_(set_instrument_state)(Char* reason, Bool state)
1381 if (CLG_(instrument_state) == state) {
1386 CLG_(instrument_state) = state;
1393 CLG_(forall_threads)(unwind_thread);
1394 CLG_(forall_threads)(zero_state_cost);
1395 (*CLG_(cachesim).clear)();
1411 t = CLG_(current_tid);
1412 CLG_(init_cost_lz)( CLG_(sets).full, &sum );
1413 CLG_(copy_cost_lz)( CLG_(sets).full, &tmp, ti->lastdump_cost );
1414 CLG_(add_diff_cost)( CLG_(sets).full, sum, ti->lastdump_cost,
1416 CLG_(copy_cost)( CLG_(sets).full, ti->lastdump_cost, tmp );
1417 CLG_(sprint_mappingcost)(buf, CLG_(dumpmap), sum);
1419 VG_(gdb_printf)("frames-%d: %d\n", t, CLG_(current_call_stack).sp);
1422 for(i = 0; i < CLG_(current_call_stack).sp; i++) {
1423 ce = CLG_(get_call_entry)(i);
1432 CLG_(copy_cost)( CLG_(sets).full, sum, ce->jcc->cost );
1433 CLG_(copy_cost)( CLG_(sets).full, tmp, ce->enter_cost );
1434 CLG_(add_diff_cost)( CLG_(sets).full, sum,
1435 ce->enter_cost, CLG_(current_state).cost );
1436 CLG_(copy_cost)( CLG_(sets).full, ce->enter_cost, tmp );
1439 CLG_(sprint_mappingcost)(buf + p, CLG_(dumpmap), sum );
1454 Int orig_tid = CLG_(current_tid);
1457 CLG_(instrument_state) ? "on":"off");
1458 if (!CLG_(instrument_state)) return;
1460 VG_(gdb_printf)("executed-bbs: %llu\n", CLG_(stat).bb_executions);
1461 VG_(gdb_printf)("executed-calls: %llu\n", CLG_(stat).call_counter);
1462 VG_(gdb_printf)("distinct-bbs: %d\n", CLG_(stat).distinct_bbs);
1463 VG_(gdb_printf)("distinct-calls: %d\n", CLG_(stat).distinct_jccs);
1464 VG_(gdb_printf)("distinct-functions: %d\n", CLG_(stat).distinct_fns);
1465 VG_(gdb_printf)("distinct-contexts: %d\n", CLG_(stat).distinct_contexts);
1469 CLG_(sprint_eventmapping)(buf+p, CLG_(dumpmap));
1472 VG_(gdb_printf)("part: %d\n", CLG_(get_dump_counter)());
1475 th = CLG_(get_threads)();
1483 CLG_(forall_threads)(dump_state_of_thread_togdb);
1522 CLG_(dump_profile)(req, False);
1526 CLG_(zero_all_cost)(False);
1538 if (!CLG_(instrument_state)) {
1542 thread_info** th = CLG_(get_threads)();
1555 CLG_(instrument_state) ? "on":"off");
1558 CLG_(set_instrument_state)("Command", VG_(strcmp)(arg,"off")!=0);
1569 Bool CLG_(handle_client_request)(ThreadId tid, UWord *args, UWord *ret)
1577 CLG_(dump_profile)("Client Request", True);
1585 CLG_(dump_profile)(buf, True);
1591 CLG_(zero_all_cost)(True);
1596 CLG_(current_state).collect = !CLG_(current_state).collect;
1598 CLG_(current_state).collect ? "ON" : "OFF");
1603 CLG_(set_instrument_state)("Client Request", True);
1608 CLG_(set_instrument_state)("Client Request", False);
1642 void CLG_(pre_syscalltime)(ThreadId tid, UInt syscallno,
1645 if (CLG_(clo).collect_systime) {
1657 void CLG_(post_syscalltime)(ThreadId tid, UInt syscallno,
1660 if (CLG_(clo).collect_systime &&
1661 CLG_(current_state).bbcc) {
1678 CLG_(current_state).cost[o] ++;
1679 CLG_(current_state).cost[o+1] += diff;
1680 if (!CLG_(current_state).bbcc->skipped)
1681 CLG_(init_cost_lz)(CLG_(sets).full,
1682 &(CLG_(current_state).bbcc->skipped));
1683 CLG_(current_state).bbcc->skipped[o] ++;
1684 CLG_(current_state).bbcc->skipped[o+1] += diff;
1707 total = CLG_(total_cost);
1746 (*CLG_(cachesim).finish)();
1750 CLG_(forall_threads)(unwind_thread);
1752 CLG_(dump_profile)(0, False);
1759 CLG_(stat).full_debug_BBs +
1760 CLG_(stat).fn_name_debug_BBs +
1761 CLG_(stat).file_line_debug_BBs +
1762 CLG_(stat).no_debug_BBs;
1766 CLG_(stat).distinct_objs);
1768 CLG_(stat).distinct_files);
1770 CLG_(stat).distinct_fns);
1772 CLG_(stat).distinct_contexts);
1774 CLG_(stat).distinct_bbs);
1776 CLG_(costarray_entries), CLG_(costarray_chunks));
1778 CLG_(stat).distinct_bbccs);
1780 CLG_(stat).distinct_jccs);
1782 CLG_(stat).distinct_skips);
1787 CLG_(stat).full_debug_BBs * 100 / BB_lookups,
1788 CLG_(stat).full_debug_BBs);
1790 CLG_(stat).file_line_debug_BBs * 100 / BB_lookups,
1791 CLG_(stat).file_line_debug_BBs);
1793 CLG_(stat).fn_name_debug_BBs * 100 / BB_lookups,
1794 CLG_(stat).fn_name_debug_BBs);
1796 CLG_(stat).no_debug_BBs * 100 / BB_lookups,
1797 CLG_(stat).no_debug_BBs);
1800 CLG_(stat).bbcc_clones);
1802 CLG_(stat).bb_retranslations);
1804 CLG_(stat).distinct_instrs);
1808 CLG_(stat).cxt_lru_misses);
1810 CLG_(stat).bbcc_lru_misses);
1812 CLG_(stat).jcc_lru_misses);
1814 CLG_(stat).bb_executions);
1816 CLG_(stat).call_counter);
1818 CLG_(stat).jcnd_counter);
1820 CLG_(stat).jump_counter);
1822 CLG_(stat).rec_call_counter);
1824 CLG_(stat).ret_counter);
1829 CLG_(sprint_eventmapping)(buf, CLG_(dumpmap));
1831 CLG_(sprint_mappingcost)(buf, CLG_(dumpmap), CLG_(total_cost));
1836 total = CLG_(total_cost);
1839 if (CLG_(clo).simulate_cache) {
1843 if (CLG_(clo).simulate_branch) {
1856 if (CLG_(clo).simulate_cache)
1857 (*CLG_(cachesim).printstat)(l1, l2, l3);
1859 if (CLG_(clo).simulate_branch)
1865 void CLG_(fini)(Int exitcode)
1882 /* throttle calls to CLG_(run_thread) by number of BBs executed */
1886 CLG_(run_thread)( tid );
1890 void CLG_(post_clo_init)(void)
1895 CLG_DEBUG(1, " dump threads: %s\n", CLG_(clo).separate_threads ? "Yes":"No");
1896 CLG_DEBUG(1, " call sep. : %d\n", CLG_(clo).separate_callers);
1897 CLG_DEBUG(1, " rec. sep. : %d\n", CLG_(clo).separate_recursions);
1899 if (!CLG_(clo).dump_line && !CLG_(clo).dump_instr && !CLG_(clo).dump_bb) {
1901 CLG_(clo).dump_line = True;
1904 CLG_(init_dumps)();
1906 (*CLG_(cachesim).post_clo_init)();
1908 CLG_(init_eventsets)();
1909 CLG_(init_statistics)(& CLG_(stat));
1910 CLG_(init_cost_lz)( CLG_(sets).full, &CLG_(total_cost) );
1913 CLG_(init_obj_table)();
1914 CLG_(init_cxt_table)();
1915 CLG_(init_bb_hash)();
1917 CLG_(init_threads)();
1918 CLG_(run_thread)(1);
1920 CLG_(instrument_state) = CLG_(clo).instrument_atstart;
1929 void CLG_(pre_clo_init)(void)
1939 VG_(basic_tool_funcs) (CLG_(post_clo_init),
1940 CLG_(instrument),
1941 CLG_(fini));
1946 VG_(needs_command_line_options)(CLG_(process_cmd_line_option),
1947 CLG_(print_usage),
1948 CLG_(print_debug_usage));
1950 VG_(needs_client_requests)(CLG_(handle_client_request));
1951 VG_(needs_syscall_wrapper)(CLG_(pre_syscalltime),
1952 CLG_(post_syscalltime));
1955 VG_(track_pre_deliver_signal) ( & CLG_(pre_signal) );
1956 VG_(track_post_deliver_signal)( & CLG_(post_signal) );
1958 CLG_(set_clo_defaults)();
1961 VG_DETERMINE_INTERFACE_VERSION(CLG_(pre_clo_init))