Setting up qt for xcode debugging
By default qt is built with debug and no debug library. This is my understanding. For instance,
% ls /Library/Frameworks/QtCore.framework/
Contents/ Headers@ QtCore@ QtCore.prl QtCore_debug@ QtCore_debug.dSYM/ QtCore_debug.prl Versions/
Also, my default version from the Qt 4.7 branch source build also has * _debug libraries.
Setting up for Xcode is cake, you just set up your project and
% qmake -spec macx-xcode
This -spec is standard for the official mac distribution, but if you build your own source, it defaults to macx-g ++ which creates the Makefile project.
This generates MyProject.xcodeproj, which is preconfigured to bundle all the required Qt frameworks, sets the paths and has the Release and Debug build target set to the same parameters as the official SDKs.
This all assumes you have a qt project file in case you need to generate it first from the source directory:
% qmake -project
Debugging works out of the box for these * .xcodeproj files. However, there is one small "hitch". Since Qt is filled with custom data types, Xcode doesn't know how to display its "values" in the debugger summary pane. So you can't see what value QString has, for example.
There is a method to input custom macros for display, but I found that they often (always?) Don't work for QObjects.
To get this working I started a project that uses the debugger xcode debugger callbacks (also mentioned in the above linked article, although their example doesn't even work oO). I call this Qt4DataFormatters .
I just started it and added types as needed. This mess is easy to create using existing functions as a template.
a source to share
I haven't tried this on Mac, but on Linux, you need to follow this process:
First, you need to configure Qt to have the debug symbols available to you:
./configure -debug-and-release separate-debug-info # other options
With debug symbols available, you should now be able to get valid stack traces.
When building an application using qmake, the flag debug
(or debug_and_release
) must be set in the project file :
CONFIG += debug
Once you've done that, you only need to tell the debugger where the Qt source is:
(gdb) dir /path/to/qt/src
After that list
should show you the actual Qt source code. You may need to add additional directories in the src directory for the debugger to select everything.
a source to share