]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix statistics with multiple changes of instrumentation state
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Mon, 29 Jun 2009 21:00:33 +0000 (21:00 +0000)
committerJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Mon, 29 Jun 2009 21:00:33 +0000 (21:00 +0000)
This fixeds bug 150606.

When switching on instrumentation, the current function got the
wrong (too large) inclusive cost when instrumentation ever was on before.

The reason was that the global (ever increasing) event counters where
not reset on toggling instrumentation state. The global counters
are used to calculate inclusive cost of a function by getting the
difference of the global counters at leaving minus their value at
enter time. When leaving a function which was not encountered
to be entered before (a stack underrun of the shadow stack), it is
assumed that this function was entered with instrumentation switched
off. Then, the absolute value of global counters is used to calculate
the inclusive cost. Thus, these global counters have to be zeroed
at instrumentation change to allow for senseable inclusive costs
of functions which were not observed to be entered.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10386

callgrind/threads.c

index ea363127af2827625b0874f52ad2f29184ae2c34..d08bb7234a24e99d77ecb5e5613b459240a495ba 100644 (file)
@@ -318,6 +318,7 @@ void CLG_(init_exec_state)(exec_state* es)
   es->jmps_passed = 0;
   es->bbcc = 0;
   es->nonskipped = 0;
+  CLG_(init_cost)( CLG_(sets).full, es->cost );
 }
 
 
@@ -330,7 +331,6 @@ static exec_state* new_exec_state(Int sigNum)
     /* allocate real cost space: needed as incremented by
      * simulation functions */
     es->cost       = CLG_(get_eventset_cost)(CLG_(sets).full);
-    CLG_(init_cost)( CLG_(sets).full, es->cost );
 
     CLG_(init_exec_state)(es);
     es->sig        = sigNum;