Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save volkan/1042050 to your computer and use it in GitHub Desktop.
Save volkan/1042050 to your computer and use it in GitHub Desktop.
How to install qcachegrind (kcachegrind) on OSX Snow Leopard
SUMMARY
I like to use kcachegrind for doing profiling on my ruby code. Most of my development
is done on OSX, and while you can install kcachegrind via macports, it takes forever
because it has to build KDE, as well. Much to my surprise, the fine folks who
wrote kcachegrind also made a QT version, qcachegrind. I was able to build this on
OSX without too much effort, only having to install QT and GraphViz. Yippie!
I'm running OSX 10.6.7, with Xcode 4. My default gcc/g++ version is 4.2. I'm sure
it will build just fine on earlier versions of Xcode, but I haven't tested it.
### Download and install QT
# I installed 4.7.3 on for 10.5/10.6 from here:
# http://qt.nokia.com/downloads/qt-for-open-source-cpp-development-on-mac-os-x/
#or
#brew install qt
### Download and install Graphviz
# If you don't already have graphiviz (specifically the 'dot' binary), then
# install it. This is so that you can see the pretty call graphs that
# qcachegrind likes to draw.
# http://www.graphviz.org/Download_macos.php
#or
#brew install graphviz
# By default, Graphviz installs dot to /usr/local/bin/dot, which qcachgrind.app
# might not find since /usr/local/bin isn't in PATH by default (I think). In order
# to ensure that my graphs render, I created a symlink from /usr/bin/dot to /usr/local/bin/dot:
sudo ln -s /usr/local/bin/dot /usr/bin/dot
### Building qcachegrind
svn co svn://anonsvn.kde.org/home/kde/trunk/KDE/kdesdk/kcachegrind kcachegrind
cd kcachegrind/qcachegrind
# qcachegrind will only let you open up files named "callgrind.out*". Since
# I'm an adult, I created a patch that allows me to open up any file.
# You can grab the patch from this gist.
wget https://gist.github.com/raw/1029580/e93011546fa5d562fa2a4d80b2d96479276b790e/qcachegrind_filename_filter.patch
patch -p0 < qcachegrind_filename_filter.patch
# By default, qmake wanted to build an xcode project on my box. I pointed
# it at spec profile that builds using g++, and things seemed to work fine.
# You can see all the profiles available in this directory: /usr/local/Qt4.7/mkspecs
# This also managed to spit out a whole bunch of errors and warnings, yet
# everything seemed to build properly.
qmake -spec 'macx-g++'
make
# It should have generated 'qcachegrind.app'. You can put this in
# /Applications, or you can just open it directly.
open qcachegrind.app
--- qcgtoplevel.cpp (revision 1237008)
+++ qcgtoplevel.cpp (working copy)
@@ -795,7 +795,7 @@
file = QFileDialog::getOpenFileName(this,
tr("Open Callgrind Data"),
_lastFile,
- tr("Callgrind Files (callgrind.*)"));
+ tr("Callgrind Files (*)"));
loadTrace(file);
}
@@ -842,7 +842,7 @@
file = QFileDialog::getOpenFileName(this,
tr("Add Callgrind Data"),
_lastFile,
- tr("Callgrind Files (callgrind.*)"));
+ tr("Callgrind Files (*)"));
addTrace(file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment