From 81045dedcfc755a11d2e4f174acbb54c8415cba5 Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Mon, 29 Jun 2009 21:00:33 +0000 Subject: [PATCH] Fix statistics with multiple changes of instrumentation state 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/callgrind/threads.c b/callgrind/threads.c index ea363127af..d08bb7234a 100644 --- a/callgrind/threads.c +++ b/callgrind/threads.c @@ -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; -- 2.47.3