Interpreting callgrind data
Asked Answered
E

2

29

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?

Elkins answered 14/2, 2012 at 15:0 Comment(2)
Does the callgrind.out contain data that's missing in the graph? Also, if you sort by "self", is there relevant time/instructions left that's spent in functions not listed? I can't remember a case where relevant parts were left out.Medick
Yes, callgrind.out contains all the data I need (including functions missing in the graph) and most of the functions that aren't listed in the graph have relevant time/instructions spent. Don't know why KCacheGrind draws only part of it. UPD: if I choose the function I want in the list of functions (placed in the left in default KCacheGrind layout) then graph is redrawn to display this functions, but still missing others. I need the whole graph at once. Thanks in advance.Elkins
E
32

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>

Elkins answered 15/2, 2012 at 9:29 Comment(4)
Interesting. Is the generated graph readable for 1500 functions?Medick
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 my Core 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 :) )Elkins
are we supposed to actually type in the -T<type> ? or do we replace <type> with something?Saum
@Saum 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.Brasilein
F
40

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
Facile answered 18/2, 2013 at 14:27 Comment(0)
E
32

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>

Elkins answered 15/2, 2012 at 9:29 Comment(4)
Interesting. Is the generated graph readable for 1500 functions?Medick
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 my Core 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 :) )Elkins
are we supposed to actually type in the -T<type> ? or do we replace <type> with something?Saum
@Saum 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.Brasilein

© 2022 - 2024 — McMap. All rights reserved.