From 09d07a0b62fa4fb9a30f605da8282830c374f189 Mon Sep 17 00:00:00 2001 From: Josef Weidendorfer Date: Tue, 11 Aug 2009 20:53:59 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10782 --- callgrind/main.c | 9 +++++++-- callgrind/threads.c | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/callgrind/main.c b/callgrind/main.c index b1b5fe52a6..fa6a90e937 100644 --- a/callgrind/main.c +++ b/callgrind/main.c @@ -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", diff --git a/callgrind/threads.c b/callgrind/threads.c index 196fb875fa..9334667ea7 100644 --- a/callgrind/threads.c +++ b/callgrind/threads.c @@ -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; -- 2.47.3