I was using valgrind tool - callgrind and kcachegrind for profiling a large project and was wondering if there is a way that callgrind reports the stats from all the functio
I'm going to complete rengar's answer with information that will allow you to generate the complete call graph, as well as give an example of the full process.
You can use the gprof2dot to show all functions in a callgraph. The script can convert the output of callgrind to dot, which can be visualized as graph. The script has two relevant parameters:
-n PERCENTAGE
, --node-thres=PERCENTAGE
to eliminate nodes below this threshold [default: 0.5
]. In order to visualize all nodes in the graph you should set this parameter to -n0
-e PERCENTAGE
, --edge-thres=PERCENTAGE
to eliminate edges below this threshold [default: 0.1
]. In order to visualize all edges in the graph you should set this parameter to -e0
In order to generate the complete call graph you would use both of the options: -n0
and -e0
.
Let's say that you have a callgrind output file called callgrind.out.1992
. To generate a complete call graph you would use:
gprof2dot -n0 -e0 ./callgrind.out.1992 -f callgrind
To generate a PNG output image of the graph, you could run the following commands:
gprof2dot -n0 -e0 ./callgrind.out.1992 -f callgrind > out.dot
dot -Tpng out.dot -o out.png
Now you have an out.png
image with the full graph.
Note the usage of the -f
parameter to specify the profile format (callgrind
in our case).