Bug 392449 - callgrind not clearing the number of calls properly
Summary: callgrind not clearing the number of calls properly
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: callgrind (show other bugs)
Version: 3.13.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Josef Weidendorfer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-28 12:24 UTC by JeromeM
Modified: 2018-05-15 18:30 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
use to reproduce (513 bytes, text/plain)
2018-03-28 12:24 UTC, JeromeM
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JeromeM 2018-03-28 12:24:24 UTC
Created attachment 111701 [details]
use to reproduce

Hi,
I want to get some Callgrind dumps during a specific period of my process.
To clear datas, I use command:
exec callgrind_control --zero $PID

But I can see, after this command, some resilient calls.

I have attached a simple test case to reproduce (tutu.c)
main() -> f1() -> f() -> g()
Clear datas with callgrind_control
       -> f2() -> f() -> g()
end

I expect to get in the callgrind dump only one call to g() but I see two calls to g().

Is it an expected behavior?

Thanks,
Jerome
Comment 1 Philippe Waroquiers 2018-04-02 17:02:58 UTC
The below patch seems to solve the problem.
As I do not know much about callgrind, it would be nice
if Jozef could give his opinion about the patch before push.
Thanks


diff --git a/callgrind/bbcc.c b/callgrind/bbcc.c
index 5716b07a7..91018ebd7 100644
--- a/callgrind/bbcc.c
+++ b/callgrind/bbcc.c
@@ -100,8 +100,10 @@ void CLG_(zero_bbcc)(BBCC* bbcc)
     bbcc->cost[i] = 0;
   for(i=0;i <= bbcc->bb->cjmp_count;i++) {
     bbcc->jmp[i].ecounter = 0;
-    for(jcc=bbcc->jmp[i].jcc_list; jcc; jcc=jcc->next_from)
+    for(jcc=bbcc->jmp[i].jcc_list; jcc; jcc=jcc->next_from) {
        CLG_(init_cost)( CLG_(sets).full, jcc->cost );
+        jcc->call_counter = 0;
+    }
   }
   bbcc->ecounter_sum = 0;
   bbcc->ret_counter = 0;
Comment 2 Josef Weidendorfer 2018-05-15 18:30:45 UTC
Fixed in commit d48686.

Thanks to Philippe for the patch!