I need a dynamic call graph for my app. I run it with callgrind
tool (valgrind
suite) and got callgrind.out.xxxxx
file. Now, I want to make a graphical representation of this data. KCacheGrind
doesn't help me much because it draws a limited part of the graph (draws ~50 functions instead of ~1500 profiled and I don't know how to fix that). How can I get a graph image where all of the functions will be drawn?
2 Answers
Using the following command to generate graph.png using gprof2dot
$ ./gprof2dot.py --format=callgrind --output=out.dot /path/to/callgrind.out
$ dot -Tpng out.dot -o graph.png
Ok, I've found the way. The generated callgrind.out
file you can convert to dot
file using gprof2dot (yes, this tool can parse callgrind
files as well). And then you can get the graph image using dot -T<type> dotfile.dot -o graphfile.<type>
-
Interesting. Is the generated graph readable for 1500 functions? Commented Feb 15, 2012 at 11:22
-
The deal is that actually I need to compare two graphs from two different versions of software, so there is no aim to read/understand the whole graph, I need only some paths and I know where I should look for them. OTOH, generation
png
image takes about 5 minutes on myCore i7-2600 3.4GHz / 8 Gb DDR3
an resulting file's size is 23 MBytes. Not all image viewers can handle it fast and correctly (perfect stress-test IMO :) )– maverikCommented Feb 15, 2012 at 14:44 -
1are we supposed to actually type in the
-T<type>
? or do we replace<type>
with something?– nmz787Commented Oct 24, 2017 at 19:27 -
3@nmz787 yes you need to specify the type. e.g.
dot -Tsvg dotfile.dot -o graphfile.svg
. You can also use pdf or png amongst others.– WodinCommented Feb 24, 2018 at 7:55
KCacheGrind
draws only part of it. UPD: if I choose the function I want in the list of functions (placed in the left in defaultKCacheGrind
layout) then graph is redrawn to display this functions, but still missing others. I need the whole graph at once. Thanks in advance.