From: Nicholas Nethercote Date: Sun, 19 Jun 2005 18:38:24 +0000 (+0000) Subject: Move VG_(bbs_done) out of main and make it local in scheduler.c. This X-Git-Tag: svn/VALGRIND_3_0_0~364 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62fa8833005e7373551856cb0a7943a492abdf6e;p=thirdparty%2Fvalgrind.git Move VG_(bbs_done) out of main and make it local in scheduler.c. This removes the dependence of m_translate.c and m_libcassert.c on m_main.c. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3954 --- diff --git a/coregrind/m_errormgr.c b/coregrind/m_errormgr.c index a192e35ffc..d8147efbde 100644 --- a/coregrind/m_errormgr.c +++ b/coregrind/m_errormgr.c @@ -750,7 +750,8 @@ void VG_(show_all_errors) ( void ) if ((i+1 == VG_(clo_dump_error))) { StackTrace ips = VG_(extract_StackTrace)(p_min->where); VG_(translate) ( 0 /* dummy ThreadId; irrelevant due to debugging*/, - ips[0], /*debugging*/True, 0xFE/*verbosity*/); + ips[0], /*debugging*/True, 0xFE/*verbosity*/, + /*bbs_done*/0); } p_min->count = 1 << 30; diff --git a/coregrind/m_libcassert.c b/coregrind/m_libcassert.c index ecaf6b6ac0..61504ab291 100644 --- a/coregrind/m_libcassert.c +++ b/coregrind/m_libcassert.c @@ -34,8 +34,7 @@ #include "pub_core_libcassert.h" #include "pub_core_libcprint.h" #include "pub_core_libcproc.h" -#include "pub_core_main.h" // for VG_(bbs_done) -- stupid! -#include "pub_core_options.h" // for VG_(bbs_done) -- stupid! +#include "pub_core_options.h" #include "pub_core_stacktrace.h" #include "pub_core_syscall.h" #include "pub_core_tooliface.h" @@ -110,7 +109,9 @@ static void report_and_quit ( const Char* report, Addr ip, Addr sp, Addr fp ) VG_(get_StackTrace2)(ips, BACKTRACE_DEPTH, ip, sp, fp, sp, stacktop); VG_(pp_StackTrace) (ips, BACKTRACE_DEPTH); - VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(bbs_done) ); + // Don't print this, as it's not terribly interesting and avoids a + // dependence on m_scheduler/, which would be crazy. + //VG_(printf)("\nBasic block ctr is approximately %llu\n", VG_(bbs_done) ); pp_sched_status(); VG_(printf)("\n"); diff --git a/coregrind/m_main.c b/coregrind/m_main.c index 17525f831c..78b829f04a 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -125,14 +125,6 @@ static Int vg_argc; static Char **vg_argv; -/* --------------------------------------------------------------------- - Running stuff - ------------------------------------------------------------------ */ - -/* 64-bit counter for the number of basic blocks done. */ -ULong VG_(bbs_done) = 0; - - /*====================================================================*/ /*=== Counters, for profiling purposes only ===*/ /*====================================================================*/ @@ -145,8 +137,6 @@ static void print_all_stats ( void ) { // Translation stats VG_(print_tt_tc_stats)(); - VG_(message)(Vg_DebugMsg, - " dispatch: %llu jumps (bb entries).", VG_(bbs_done) ); // Scheduler stats VG_(print_scheduler_stats)(); diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c index 762e80e511..d6d2d42f3c 100644 --- a/coregrind/m_scheduler/scheduler.c +++ b/coregrind/m_scheduler/scheduler.c @@ -104,6 +104,9 @@ Bool VG_(my_fault) = True; /* Counts downwards in VG_(run_innerloop). */ UInt VG_(dispatch_ctr); +/* 64-bit counter for the number of basic blocks done. */ +static ULong bbs_done = 0; + /* Forwards */ static void do_client_request ( ThreadId tid ); static void scheduler_sanity ( ThreadId tid ); @@ -117,7 +120,9 @@ static UInt n_scheduling_events_MAJOR = 0; void VG_(print_scheduler_stats)(void) { VG_(message)(Vg_DebugMsg, - " %d/%d major/minor sched events.", + "scheduler: %llu jumps (bb entries).", bbs_done ); + VG_(message)(Vg_DebugMsg, + "scheduler: %d/%d major/minor sched events.", n_scheduling_events_MAJOR, n_scheduling_events_MINOR); } @@ -419,7 +424,7 @@ UInt run_thread_for_a_while ( ThreadId tid ) done_this_time = (Int)dispatch_ctr_SAVED - (Int)VG_(dispatch_ctr) - 0; vg_assert(done_this_time >= 0); - VG_(bbs_done) += (ULong)done_this_time; + bbs_done += (ULong)done_this_time; VGP_POPCC(VgpRun); return trc; @@ -561,7 +566,7 @@ static void handle_tt_miss ( ThreadId tid ) found = VG_(search_transtab)( NULL, ip, True/*upd_fast_cache*/ ); if (!found) { /* Not found; we need to request a translation. */ - if (VG_(translate)( tid, ip, /*debug*/False, 0/*not verbose*/ )) { + if (VG_(translate)( tid, ip, /*debug*/False, 0/*not verbose*/, bbs_done )) { found = VG_(search_transtab)( NULL, ip, True ); vg_assert2(found, "VG_TRC_INNER_FASTMISS: missing tt_fast entry"); diff --git a/coregrind/m_translate.c b/coregrind/m_translate.c index d64914d19a..7e229e8796 100644 --- a/coregrind/m_translate.c +++ b/coregrind/m_translate.c @@ -36,7 +36,6 @@ #include "pub_core_libcbase.h" #include "pub_core_libcassert.h" #include "pub_core_libcprint.h" -#include "pub_core_main.h" // for VG_(bbs_done) #include "pub_core_options.h" #include "pub_core_profile.h" #include "pub_core_redir.h" @@ -417,7 +416,8 @@ static Bool chase_into_ok ( Addr64 addr64 ) Bool VG_(translate) ( ThreadId tid, Addr64 orig_addr, Bool debugging_translation, - Int debugging_verbosity ) + Int debugging_verbosity, + ULong bbs_done ) { Addr64 redir, orig_addr0 = orig_addr; Int tmpbuf_used, verbosity; @@ -501,9 +501,9 @@ Bool VG_(translate) ( ThreadId tid, Char fnname[64] = ""; VG_(get_fnname_w_offset)(orig_addr, fnname, 64); VG_(printf)( - "==== BB %d %s(0x%llx) approx BBs exec'd %lld ====\n", + "==== BB %d %s(0x%llx) BBs exec'd %lld ====\n", VG_(get_bbs_translated)(), fnname, orig_addr, - VG_(bbs_done)); + bbs_done); } if (seg == NULL || diff --git a/coregrind/m_transtab.c b/coregrind/m_transtab.c index e74cbcc242..a43453c22e 100644 --- a/coregrind/m_transtab.c +++ b/coregrind/m_transtab.c @@ -798,7 +798,7 @@ void VG_(show_BB_profile) ( void ) score_cumul, buf_cumul, score_here, buf_here, tops[r]->entry, name ); VG_(printf)("\n"); - VG_(translate)(0, tops[r]->entry, True, VG_(clo_profile_flags)); + VG_(translate)(0, tops[r]->entry, True, VG_(clo_profile_flags), 0); VG_(printf)("=-=-=-=-=-=-=-=-=-=-=-=-=-= end BB rank %d " "=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n", r); } diff --git a/coregrind/pub_core_main.h b/coregrind/pub_core_main.h index 667d9db587..541650d234 100644 --- a/coregrind/pub_core_main.h +++ b/coregrind/pub_core_main.h @@ -51,9 +51,6 @@ Char* VG_(build_child_exename) ( void ); /* Something of a function looking for a home ... start up debugger. */ extern void VG_(start_debugger) ( ThreadId tid ); -/* 64-bit counter for the number of basic blocks done. */ -extern ULong VG_(bbs_done); - // Set up the libc freeres wrapper extern void VG_(set_libc_freeres_wrapper_addr)(Addr); diff --git a/coregrind/pub_core_translate.h b/coregrind/pub_core_translate.h index d74f23c104..5d2bb7a11d 100644 --- a/coregrind/pub_core_translate.h +++ b/coregrind/pub_core_translate.h @@ -40,7 +40,8 @@ extern Bool VG_(translate) ( ThreadId tid, Addr64 orig_addr, Bool debugging_translation, - Int debugging_verbosity ); + Int debugging_verbosity, + ULong bbs_done ); #endif // __PUB_CORE_TRANSLATE_H