]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Callgrind: Fix printing of "Summary:" line in finish()
authorJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Tue, 11 Aug 2009 20:53:59 +0000 (20:53 +0000)
committerJosef Weidendorfer <Josef.Weidendorfer@gmx.de>
Tue, 11 Aug 2009 20:53:59 +0000 (20:53 +0000)
The global cost counters, which are used for printing the
summary line, where zeroed before in init_exec_state(), called
by unwind_thread().

Stack unwinding (i.e. unwind_thread) is also done at instrumentation
state changes, and there, we want the cost counters to be zeroed
(was fix for bug 150606). Do this explicitly now.

PS: The correct fix for bug 150606 is not to zero the cost counters
(we do not really want this at instrumentation state changes), but
to store the current counter values in a "last_instr_state_on_cost"
counter, and use this as the global cost counter on enter for functions
which are left but were not detected to be entered.

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

callgrind/main.c
callgrind/threads.c

index b1b5fe52a6b0a3873f32813c60dbe30a457b2ae4..fa6a90e937e2b9009f5b601f15757277fdce163d 100644 (file)
@@ -1033,6 +1033,12 @@ void unwind_thread(thread_info* t)
   CLG_(current_fn_stack).top = CLG_(current_fn_stack).bottom;
 }
 
+static
+void zero_state_cost(thread_info* t)
+{
+    CLG_(zero_cost)( CLG_(sets).full, CLG_(current_state).cost );
+}
+
 /* Ups, this can go wrong... */
 extern void VG_(discard_translations) ( Addr64 start, ULong range );
 
@@ -1051,9 +1057,8 @@ void CLG_(set_instrument_state)(Char* reason, Bool state)
 
   /* reset internal state: call stacks, simulator */
   CLG_(forall_threads)(unwind_thread);
+  CLG_(forall_threads)(zero_state_cost);
   (*CLG_(cachesim).clear)();
-  if (0)
-    CLG_(forall_threads)(zero_thread_cost);
 
   if (VG_(clo_verbosity) > 1)
     VG_(message)(Vg_DebugMsg, "%s: instrumentation switched %s\n",
index 196fb875fa9f1de287f425c4eb6983303b6ab146..9334667ea74d0f267ca4d7381d17478f0042901a 100644 (file)
@@ -210,7 +210,7 @@ void CLG_(pre_signal)(ThreadId tid, Int sigNum, Bool alt_stack)
 
     /* setup new cxtinfo struct for this signal handler */
     es = push_exec_state(sigNum);
-    // because of this, below call to init_exec_state will zero es->cost
+    CLG_(zero_cost)( CLG_(sets).full, es->cost );
     CLG_(current_state).cost = es->cost;
     es->call_stack_bottom = CLG_(current_call_stack).sp;
 
@@ -317,7 +317,6 @@ 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 +329,7 @@ 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_(zero_cost)( CLG_(sets).full, es->cost );
     CLG_(init_exec_state)(es);
     es->sig        = sigNum;
     es->call_stack_bottom  = 0;