Horst Walter
Horst Walter

Reputation: 14081

Setup of Qt Creator to debug into Qt classes

I want to setup Qt Creator (3.0) in a way, that I can debug into the Qt classes. So I download the corresponding src code (http://gitorious.org/qt/qt5) and install it in a directory (e.g. c:\Qt5\src).

Then I have my own project. Where do I need to set the source code path of Qt (c:\Qt5\src), so I can debug my code, but also into a Qt class where necessary.

-- Edit:Pavel's comment --

Pavel has given a good hint: But I am using a precompiled version of Qt/Qt Creator. So I am basically looking for a solution which does not require me to compile from source. Nevertheless a useful hint. Thanks.

Upvotes: 25

Views: 16695

Answers (6)

Ashark
Ashark

Reputation: 843

In Arch Linux, if using official packages, you can install debug packages, which has source code and debug symbols. See here. For example:

pacman -S qt6-base-debug

Here are some of the files from package (pacman -Ql qt6-base-debug):

/usr/lib/debug/.build-id/01/cbf19297a6d39a5de67b4f79e485eb46002659
/usr/lib/debug/.build-id/01/cbf19297a6d39a5de67b4f79e485eb46002659.debug
/usr/lib/debug/usr/lib/libQt6Concurrent.so.6.5.2.debug
/usr/src/debug/qt6-base/build/src/corelib/Core_autogen/include/moc_qabstractanimation.cpp
/usr/src/debug/qt6-base/qtbase-everywhere-src-6.5.2/src/dbus/qdbusabstractadaptor.cpp
/usr/src/debug/qt6-base/qtbase-everywhere-src-6.5.2/src/dbus/qdbusabstractadaptor.h

Upvotes: 1

JLM
JLM

Reputation: 244

If you are using a prebuilt version just remap the source code location as described in Mapping Source Paths:

Mapping Source Paths

To enable the debugger to step into the code and display the source code when using a copy of the source tree at a location different from the one at which the libraries where built, map the source paths to target paths:

  • Select Edit > Preferences > Debugger > General.
  • In the Source path field, specify the source path in the debug information of the executable as reported by the debugger.
  • In the Target path field, specify the actual location of the source tree on the local machine.

To get "the source path in the debug information of the executable as reported by the debugger", you can activate the "Use Tooltips in Stack-View when Debugging" option by right-clicking in the Stack View and move the mouse over a specific function call.

Upvotes: 22

Adriel Jr
Adriel Jr

Reputation: 2681

Follow the instructions from Qt here:

"In the run configuration, select Use debug version of frameworks."

Upvotes: 1

David Osipyan
David Osipyan

Reputation: 65

In recent Qt creator (v 4.11) press button "Add Qt Sources" in Tools > Options > Debugger > General and select Qt sources file. Qt5 should be installed by online installer with checked "Qt Debug Information files".

Upvotes: 3

prewett
prewett

Reputation: 1647

With Xcode, before you step into the Qt library the first time, enter the following command in the LLDB window:

settings set target.source-map /Users/qt/work/qt /path/to/Qt/5.10.1/Src

(Obviously you'll want to change the version number, as relevant).

But suppose Trolltech changes its build directory, what to do then? (Or, how did the community wiki that gave the /Users/qt/work/qt path find it?) You can guess what the path needs to be by editing /path/to/Qt/5.10.1/clang_64/lib/QtCore.framework.dSYM/Contents/Resources/DWARF/QtCore_debug (or any other Qt library) and searching for some paths. "/Users" seems like a good guess. About 2% into the library you'll start seeing sections with a lot of paths like:

../../include/QtCore/../../src/corelib/kernel^@../../include/QtCore       
/../../src/corelib/tools^@global^@/Users/qt/work/qt/qtbase/src/corelib
/../../include/QtCore/../../src/corelib/arch^@/Applications/Xcode.app
/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/<etc>

Look for an absolute path that looks like it could be writable. (/Applications/... would not be a likely build path, for example)

Upvotes: 4

user962247
user962247

Reputation:

If you look into the tooltips, you will see references to /Users/qt/work, the Mac deployed debug symbols are pointing there. Of course, this is not documented, as these folks want you to buy enterprise.

If you create the /Users/qt/work directory (as root), then make a soft link to your source directory named qt, everything will work. No need to build anything from source (under Mac that would result in tens of gigs wasted). Same considerations about plugins

Example:

sudo -s
mkdir /Users/qt
cd /Users/qt
mkdir work
cd work
ln -s /Users/your_user_name/Qt/your_qt_release/Src qt

Everything will work. Any source mapping failed here, so leave those alone. Hope this helps

Upvotes: 8

Related Questions