Sunday, December 09, 2007

Valgrind callgrind tools Part 1: decompressing callgrind files

If you have ever used the Vallgrind tool callgrind you will find that it generates a file "". Looking inside of this file you will find a compressed version of the execution of the program. Here is a snippet from a callgrind file I generated last night:
fn=(43726) tst_QListView::indexAt()
463 4
+2 4
calls=1 148
* 3399
+1 1
+1 1
+2 4
calls=1 150
* 320655
+1 5

After reading the callgrind format specification you shouldn't have too much trouble being able to read it if you really want to. By default the callgrind files are compressed which make it harder to read then it has to be. So if you get a compressed callgrind file that you want to read I have written a tool to decompress the file into a more reasonable format. Here is the same code as before, but this time decompressed:
463 4
465 4
calls=1 148
465 3399
466 1
467 1
469 4
calls=1 150
469 320655
470 5

If you are going to be either extracting information out of a callgrind file or writing your own tool that generates a callgrind files like my QScript profiler having a decompresser comes in handy.

The source for callgrind decompress can be found in my callgrind tools git repository.

1 comment:

Matt said...

what's wrong with kcachegrind? It reads both cachegrind and callgrind files and gives you nice visual displays of the data, etc. It works just fine on KDE4 too, since I've been testing it with KDevelop. :)

Popular Posts