|
From: <sv...@va...> - 2009-08-11 20:54:15
|
Author: weidendo
Date: 2009-08-11 21:53:59 +0100 (Tue, 11 Aug 2009)
New Revision: 10782
Log:
Callgrind: Fix printing of "Summary:" line in finish()
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.
Modified:
trunk/callgrind/main.c
trunk/callgrind/threads.c
Modified: trunk/callgrind/main.c
===================================================================
--- trunk/callgrind/main.c 2009-08-11 20:53:57 UTC (rev 10781)
+++ trunk/callgrind/main.c 2009-08-11 20:53:59 UTC (rev 10782)
@@ -1033,6 +1033,12 @@
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 @@
/* 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",
Modified: trunk/callgrind/threads.c
===================================================================
--- trunk/callgrind/threads.c 2009-08-11 20:53:57 UTC (rev 10781)
+++ trunk/callgrind/threads.c 2009-08-11 20:53:59 UTC (rev 10782)
@@ -210,7 +210,7 @@
/* 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 @@
es->jmps_passed = 0;
es->bbcc = 0;
es->nonskipped = 0;
- CLG_(init_cost)( CLG_(sets).full, es->cost );
}
@@ -330,7 +329,7 @@
/* 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;
|