Bugs & Wishes

Project Page


Example 1

Suppose you want to profile the startup of Konqueror, splitting the trace into execution parts of 10 000 000 basic blocks. Even if you don't have konqueror compiled with debug info, we get profile data with function symbols. These are always available (at least for every shared library, as runtime linking needs it). In an empty directory, run

   valgrind --tool=callgrind -v --dump-every-bb=10000000 konqueror

With "-v", you get some output when shared libraries are loaded and when a profile trace dump is made. After the konqueror window pops up, simple close it again.

Now the files callgrind.out.pid, callgrind.out.pid.2, callgrind.out.pid.2, ... are created. KCachegrind by default loads these files, when found in the current working directory. So it should be enough to run "kcachegrind". When you have profile data files from more runs in one directory, they can still distinguished by the pid. To load the files for the run with process ID pid, start "kcachegrind cachegrind.out.pid".

Example 2

This time, you want to only dump profile data when choosing View/Reload in the Konqueror Menu. Do

   valgrind --tool=callgrind -v --dump-before=KonqMainWindow::slotReload konqueror

Again, -v shows when dumps are made. Choose View/Reload two times to get profile data (1) before first reload, (2) before second reload, and (3) at program termination. By starting kcachegrind and selecting only the 2nd output file, you see exactly the cost of a reload action. You can already browse a profile data file while the Callgrind profiling is running in the background. When a new profile data file is dumped, choose "File/Reload" to load the new generated data.

Example 3

This time, we first start KCachegrind with 'kcachegrind &' in the directory where the profile data files will end up in. Then, in the same directory (!), we start konqueror for interactive profiling without special options with

   valgrind --tool=callgrind konqueror

When the Konqueror window is shown, press the 'Force Dump' Toolbar button in KCachegrind. Now, when you move the mouse into the Konqueror window, you will see Konqueror freezing (no update) for a few seconds. And "magically", KCachegrind will load the first profile data file of the current konqueror run. For this to work, Callgrind can be controlled from the outside. This is also possible with the supplied script callgrind_control. E.g. to trigger dumping of any profile data up to now, run

   callgrind_control -d

When you list the contents of the directory, you can check that callgrind made a profile data dump. You have to press 'Reload' manually now in KCachegrind to get the new data. There is one issue for interactive control of a Callgrind run. Callgrind only reacts on commands when it is actively doing something. Thus, for konqueror to make "active", we needed to move the mouse into its window.