Is it possible to use callgrind to produce the output like one given by gcov/lcov ? I'm reading their docs unable to find the exact option for callgrind_annotate
It is not possible but callgrind_annotate nor kcachegrind should implement it. However with kcachegrind you have the call's count of each functions/methods.
Column Calls in Cost/All callers tab or Count in Callers tab should be relevant.
Yes, you can. Using callgrind --collect-jumps=yes, and the tools described at the link below, you can get much the same information as gcov. It's not as pretty as lcov, but the time savings might just be worth it.
http://benjamin-meyer.blogspot.com/2007/12/valgrind-callgrind-tools-part-3-code.html
Note that this works pretty well even with optimized binaries, so you'll save a bunch of time in your build/test cycle by not having to recompile with --coverage.
You can also merge multiple test runs before using Benjamin's script using cg_merge.
来源:https://stackoverflow.com/questions/2818503/callgrind-how-to-check-whether-a-line-executed-or-not