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
This commit is contained in:
Nicholas Nethercote 2005-06-19 18:38:24 +00:00
parent 5a9e619817
commit 62fa883300
8 changed files with 21 additions and 26 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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)();

View File

@ -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");

View File

@ -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 ||

View File

@ -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);
}

View File

@ -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);

View File

@ -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