]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
De-globalise a few more counters.
authorNicholas Nethercote <n.nethercote@gmail.com>
Sat, 7 Aug 2004 17:52:25 +0000 (17:52 +0000)
committerNicholas Nethercote <n.nethercote@gmail.com>
Sat, 7 Aug 2004 17:52:25 +0000 (17:52 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2574

coregrind/vg_include.h
coregrind/vg_main.c
coregrind/vg_translate.c
coregrind/vg_transtab.c

index 0d1c37e943657fdfa98019e72b83a7e132550a35..f70dcb9f2fd066585905ec5a981469831f05aebc 100644 (file)
@@ -1277,26 +1277,11 @@ extern Int      VG_(fatal_sigNo);               /* the fatal signal */
 
 /* --- Counters, for informational purposes only. --- */
 
-/* Number of lookups which miss the fast tt helper. */
-extern UInt VG_(tt_fast_misses);
-
-/* Counts for TT/TC informational messages. */
-
-/* Number and total o/t size of translations overall. */
-extern UInt VG_(overall_in_count);
-extern UInt VG_(overall_in_osize);
-extern UInt VG_(overall_in_tsize);
-/* Number and total o/t size of discards overall. */
-extern UInt VG_(overall_out_count);
-extern UInt VG_(overall_out_osize);
-extern UInt VG_(overall_out_tsize);
-/* The number of discards of TT/TC. */
-extern UInt VG_(number_of_tc_discards);
-/* Counts of chain and unchain operations done. */
-extern UInt VG_(bb_enchain_count);
-extern UInt VG_(bb_dechain_count);
-/* Number of unchained jumps performed. */
-extern UInt VG_(unchained_jumps_done);
+// These counters must be declared here because they're maintained by
+// vg_dispatch.S.
+extern UInt VG_(bb_enchain_count);     // Counts of chain operations done
+extern UInt VG_(bb_dechain_count);     // Counts of unchain operations done
+extern UInt VG_(unchained_jumps_done); // Number of unchained jumps performed
 
 extern void VG_(print_scheduler_stats) ( void );
 
@@ -1426,16 +1411,20 @@ extern void VG_(show_open_fds) ( void );
 /* The fast-cache for tt-lookup. */
 extern Addr VG_(tt_fast)[VG_TT_FAST_SIZE];
 
+extern void VG_(init_tt_tc)       ( void );
 extern void VG_(add_to_trans_tab) ( Addr orig_addr,  Int orig_size,
                                     Addr trans_addr, Int trans_size,
                                    UShort jumps[VG_MAX_JUMPS]);
+extern Addr VG_(search_transtab)  ( Addr original_addr );
 
-extern void VG_(invalidate_translations) ( Addr start, UInt range, Bool unchain_blocks );
+extern void VG_(invalidate_translations) ( Addr start, UInt range,
+                                           Bool unchain_blocks );
 
-extern void VG_(init_tt_tc) ( void );
+extern void VG_(sanity_check_tt_tc) ( void );
 
-extern void VG_(sanity_check_tc_tt) ( void );
-extern Addr VG_(search_transtab) ( Addr original_addr );
+extern void VG_(print_tt_tc_stats) ( void );
+
+extern Int  VG_(get_bbs_translated) ( void );
 
 /* ---------------------------------------------------------------------
    Exports of vg_syscall.S
index 5ef5ea357d7f13c5b31ecaa2b42b916b68c05f61..41897a44c5d9d14905d14b9dce444f597122ca09 100644 (file)
@@ -153,9 +153,9 @@ UInt VG_(sigstack)[VG_SIGSTACK_SIZE_W];
 
 /* jmp_buf for fatal signals;  VG_(fatal_signal_jmpbuf_ptr) is NULL until
    the time is right that it can be used. */
-Int      VG_(fatal_sigNo) = -1;
-jmp_buf* VG_(fatal_signal_jmpbuf_ptr) = NULL;
-jmp_buf  fatal_signal_jmpbuf;
+       Int      VG_(fatal_sigNo) = -1;
+       jmp_buf* VG_(fatal_signal_jmpbuf_ptr) = NULL;
+static jmp_buf  fatal_signal_jmpbuf;
 
 /* Counts downwards in VG_(run_innerloop). */
 UInt VG_(dispatch_ctr);
@@ -175,60 +175,22 @@ Bool VG_(logging_to_filedes) = True;
 /*=== Counters, for profiling purposes only                        ===*/
 /*====================================================================*/
 
-/* Number of lookups which miss the fast tt helper. */
-UInt VG_(tt_fast_misses) = 0;
-
-
-/* Counts for TT/TC informational messages. */
-
-/* Number and total o/t size of translations overall. */
-UInt VG_(overall_in_count) = 0;
-UInt VG_(overall_in_osize) = 0;
-UInt VG_(overall_in_tsize) = 0;
-/* Number and total o/t size of discards overall. */
-UInt VG_(overall_out_count) = 0;
-UInt VG_(overall_out_osize) = 0;
-UInt VG_(overall_out_tsize) = 0;
-/* The number of discards of TT/TC. */
-UInt VG_(number_of_tc_discards) = 0;
-/* Counts of chain and unchain operations done. */
-UInt VG_(bb_enchain_count) = 0;
-UInt VG_(bb_dechain_count) = 0;
-/* Number of unchained jumps performed. */
-UInt VG_(unchained_jumps_done) = 0;
+// These ones maintained by vg_dispatch.S
+UInt VG_(bb_enchain_count) = 0;        // Number of chain operations done
+UInt VG_(bb_dechain_count) = 0;        // Number of unchain operations done
+UInt VG_(unchained_jumps_done) = 0;    // Number of unchained jumps done
 
 /* Counts pertaining to internal sanity checking. */
 static UInt sanity_fast_count = 0;
 static UInt sanity_slow_count = 0;
 
-static __inline__ Int safe_idiv(Int a, Int b)
-{
-   return (b == 0 ? 0 : a / b);
-}
-
 static void print_all_stats ( void )
 {
    // Translation stats
+   VG_(print_tt_tc_stats)();
    VG_(message)(Vg_DebugMsg,
-                "    TT/TC: %d tc sectors discarded.",
-                VG_(number_of_tc_discards) );
-   VG_(message)(Vg_DebugMsg,
-                "           %d tt_fast misses.", VG_(tt_fast_misses));
-   VG_(message)(Vg_DebugMsg,
-                "           %d chainings, %d unchainings.",
+                "chainings: %d chainings, %d unchainings.",
                 VG_(bb_enchain_count), VG_(bb_dechain_count) );
-   VG_(message)(Vg_DebugMsg,
-                "translate: new     %d (%d -> %d; ratio %d:10)",
-                VG_(overall_in_count),
-                VG_(overall_in_osize),
-                VG_(overall_in_tsize),
-                safe_idiv(10*VG_(overall_in_tsize), VG_(overall_in_osize)));
-   VG_(message)(Vg_DebugMsg,
-                "           discard %d (%d -> %d; ratio %d:10).",
-                VG_(overall_out_count),
-                VG_(overall_out_osize),
-                VG_(overall_out_tsize),
-                safe_idiv(10*VG_(overall_out_tsize), VG_(overall_out_osize)));
    VG_(message)(Vg_DebugMsg,
       " dispatch: %llu jumps (bb entries); of them %u (%lu%%) unchained.",
       VG_(bbs_done), 
@@ -2615,7 +2577,7 @@ void VG_(sanity_check_general) ( Bool force_expensive )
 #     endif
 
       if ((sanity_fast_count % 250) == 0)
-         VG_(sanity_check_tc_tt)();
+         VG_(sanity_check_tt_tc)();
 
       if (VG_(needs).sanity_checks) {
           VGP_PUSHCC(VgpSkinExpensiveSanity);
index 6c9e8a1b1f66334eef270ec34849bab3c6b4a092..3659820110b946f26ad2d4fe887c9ae71a817df6 100644 (file)
@@ -2465,7 +2465,7 @@ void VG_(translate) ( ThreadId tid, Addr orig_addr,
       few blocks translated prior to a failure.  Set
       notrace_until_limit to be the number of translations to be made
       before --trace-codegen= style printing takes effect. */
-   notrace_until_done = VG_(overall_in_count) >= notrace_until_limit;
+   notrace_until_done = VG_(get_bbs_translated)() >= notrace_until_limit;
 
    seg = VG_(find_segment)(orig_addr);
 
@@ -2495,9 +2495,8 @@ void VG_(translate) ( ThreadId tid, Addr orig_addr,
       Char fnname[64] = "";
       VG_(get_fnname_if_entry)(orig_addr, fnname, 64);
       VG_(printf)(
-              "==== BB %d %s(%p) in %dB, out %dB, BBs exec'd %llu ====\n\n",
-              VG_(overall_in_count), fnname, orig_addr, 
-              VG_(overall_in_osize), VG_(overall_in_tsize),
+              "==== BB %d %s(%p) approx BBs exec'd %llu ====\n\n",
+              VG_(get_bbs_translated)(), fnname, orig_addr, 
               VG_(bbs_done));
    }
 
index e954ef80ca599dcefd6fecf927fc90d5e3adeb40..41f535660c2d80246977231410f8eefda53b5ad1 100644 (file)
@@ -121,6 +121,19 @@ static Int vg_tc_stats_count[VG_TC_N_SECTORS];
 static Int vg_tc_stats_osize[VG_TC_N_SECTORS];
 static Int vg_tc_stats_tsize[VG_TC_N_SECTORS];
 
+static UInt n_tt_fast_misses = 0;   // number of lookups missing fast TT helper
+static UInt n_tc_discards = 0;      // number of TT/TC discards
+
+// Number and total original/translated size of translations overall.
+static UInt overall_in_count  = 0;
+static UInt overall_in_osize  = 0;
+static UInt overall_in_tsize  = 0;
+// Number and total original/t size of discards overall.
+static UInt overall_out_count = 0;
+static UInt overall_out_osize = 0;
+static UInt overall_out_tsize = 0;
+
+
 
 /*------------------ TRANSLATION TABLE ------------------*/
 
@@ -353,14 +366,14 @@ void discard_oldest_sector ( void )
       }
 
       pp_tt_tc_status ( msg );
-      VG_(overall_out_count) += vg_tc_stats_count[s];
-      VG_(overall_out_osize) += vg_tc_stats_osize[s];
-      VG_(overall_out_tsize) += vg_tc_stats_tsize[s]; 
+      overall_out_count += vg_tc_stats_count[s];
+      overall_out_osize += vg_tc_stats_osize[s];
+      overall_out_tsize += vg_tc_stats_tsize[s]; 
       vg_tc_used[s] = 0;
       vg_tc_stats_count[s] = 0;
       vg_tc_stats_osize[s] = 0;
       vg_tc_stats_tsize[s] = 0;
-      VG_(number_of_tc_discards) ++;
+      n_tc_discards++;
    }
 }
 
@@ -374,13 +387,13 @@ Int maybe_commission_sector ( void )
    Int  s;
    for (s = 0; s < VG_TC_N_SECTORS; s++) {
       if (vg_tc[s] != NULL && vg_tc_used[s] == 0) {
-         vg_tc_age[s] = VG_(overall_in_count);
+         vg_tc_age[s] = overall_in_count;
          VG_(sprintf)(msg, "after  commission of sector %d "
                            "at time %d", 
                            s, vg_tc_age[s]);
          pp_tt_tc_status ( msg );
 #        ifdef DEBUG_TRANSTAB
-         VG_(sanity_check_tc_tt)();
+         VG_(sanity_check_tt_tc)();
 #        endif
          return s;
       }
@@ -459,7 +472,7 @@ UChar* allocate ( Int nBytes )
    vg_tc_current = maybe_commission_sector();
    vg_assert(vg_tc_current >= 0 && vg_tc_current < VG_TC_N_SECTORS);
 #  ifdef DEBUG_TRANSTAB
-   VG_(sanity_check_tc_tt)();
+   VG_(sanity_check_tt_tc)();
 #  endif
 
    return allocate(nBytes);
@@ -480,7 +493,7 @@ void VG_(get_tt_tc_used) ( UInt* tt_used, UInt* tc_used )
 
 /* Do a sanity check on TT/TC.
 */
-void VG_(sanity_check_tc_tt) ( void )
+void VG_(sanity_check_tt_tc) ( void )
 {
    Int i, s;
    TTEntry* tte;
@@ -508,6 +521,33 @@ void VG_(sanity_check_tc_tt) ( void )
    }
 }
 
+static __inline__ Int safe_idiv(Int a, Int b)
+{
+   return (b == 0 ? 0 : a / b);
+}
+
+void VG_(print_tt_tc_stats)(void)
+{
+   VG_(message)(Vg_DebugMsg,
+                "    TT/TC: %d tc sectors discarded.",
+                n_tc_discards );
+   VG_(message)(Vg_DebugMsg,
+                "           %d tt_fast misses.",
+                n_tt_fast_misses);
+   VG_(message)(Vg_DebugMsg,
+                "translate: new     %d (%d -> %d; ratio %d:10)",
+                overall_in_count, overall_in_osize, overall_in_tsize,
+                safe_idiv(10*overall_in_tsize, overall_in_osize));
+   VG_(message)(Vg_DebugMsg,
+                "           discard %d (%d -> %d; ratio %d:10).",
+                overall_out_count, overall_out_osize, overall_out_tsize,
+                safe_idiv(10*overall_out_tsize, overall_out_osize));
+}
+
+Int VG_(get_bbs_translated) ( void )
+{
+   return overall_in_count;
+}
 
 /* Add this already-filled-in entry to the TT.  Assumes that the
    relevant code chunk has been placed in TC, along with a dummy back
@@ -553,9 +593,9 @@ void VG_(add_to_trans_tab) ( Addr orig_addr,  Int orig_size,
    add_tt_entry(tce);
 
    /* Update stats. */
-   VG_(overall_in_count) ++;
-   VG_(overall_in_osize) += orig_size;
-   VG_(overall_in_tsize) += trans_size;
+   overall_in_count ++;
+   overall_in_osize += orig_size;
+   overall_in_tsize += trans_size;
 
    vg_tc_stats_count[vg_tc_current] ++;
    vg_tc_stats_osize[vg_tc_current] += orig_size;
@@ -581,7 +621,7 @@ Addr VG_(search_transtab) ( Addr original_addr )
       /* Found it.  Put the search result into the fast cache now. */
       UInt cno = (UInt)original_addr & VG_TT_FAST_MASK;
       VG_(tt_fast)[cno] = (Addr)(tte->tcentry);
-      VG_(tt_fast_misses)++;
+      n_tt_fast_misses++;
       VGP_POPCC(VgpSlowFindT);
       return (Addr)&(tte->tcentry->payload[0]);
    }
@@ -600,7 +640,7 @@ void VG_(invalidate_translations) ( Addr start, UInt range, Bool unchain_blocks
    Int      i, j;
    TCEntry* tce;
 #  ifdef DEBUG_TRANSTAB
-   VG_(sanity_check_tc_tt)();
+   VG_(sanity_check_tt_tc)();
 #  endif
    i_start = start;
    i_end   = start + range - 1;
@@ -630,9 +670,9 @@ void VG_(invalidate_translations) ( Addr start, UInt range, Bool unchain_blocks
          }
       }
 
-      VG_(overall_out_count) ++;
-      VG_(overall_out_osize) += tce->orig_size;
-      VG_(overall_out_tsize) += tce->trans_size;
+      overall_out_count ++;
+      overall_out_osize += tce->orig_size;
+      overall_out_tsize += tce->trans_size;
       out_count ++;
       out_osize += tce->orig_size;
       out_tsize += tce->trans_size;
@@ -640,7 +680,7 @@ void VG_(invalidate_translations) ( Addr start, UInt range, Bool unchain_blocks
 
    if (out_count > 0) {
       vg_invalidate_tt_fast();
-      VG_(sanity_check_tc_tt)();
+      VG_(sanity_check_tt_tc)();
 #     ifdef DEBUG_TRANSTAB
       { Addr aa;
         for (aa = i_start; aa <= i_end; aa++)
@@ -705,7 +745,7 @@ void VG_(init_tt_tc) ( void )
    }
 
 #  ifdef DEBUG_TRANSTAB
-   VG_(sanity_check_tc_tt)();
+   VG_(sanity_check_tt_tc)();
 #  endif
 }