Make callgrind show all function calls in the kcachegrind callgraph

后端 未结 3 1275
一生所求
一生所求 2020-12-18 04:47

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

3条回答
  •  执念已碎
    2020-12-18 05:24

    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=PERCENTAGEto 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.

    Example

    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).

提交回复
热议问题