The set of scripts for pretty printing Qt by GDB and LLDB.
- 6.x
You can use the example project for testsing.
- LLDB
- GDB
- Windows
- Linux
- macOS
- x64
- arm64
Note
Manual installation is an option if you prefer to run GDB executable without an IDE. Or if there is no plugin for your IDE. Or in any other situation when you know what you're doing.
You do not need to install manually, if you use an IDE plugin.
- Copy the qt6renderer folder somewhere at your system.
- Place the gdbinit in the any of the supported places at your system.
- Add the following content to the
gdbinit:python sys.path.append('/where/the/qt6renderer/folder/is/at/your/system') # i.e. if the qt6renderer is at '~/gdb/scripts/qt6renderer' # then you add '~/gdb/scripts' python import qt6renderer python gdb.pretty_printers.append(qt6renderer.qt6_lookup) set print pretty on
- Copy the qt6renderer lldb folder somewhere at your system
- If you don't already have one, create a .lldbinit file in an appropriate place for your OS (on macOS this will be ~/.lldbinit)
- Add the following line to your
.lldbinit(replacing /full/path/to... with the actual full path to register.py):
command script import "/full/path/to/qt6renderer/lldb/register.py"
Pretty printers need Debug information for Qt.
If you installed Qt with Qt Online Installer, ensure you have installed
the Qt Debug Information Files:
If you are using Arch Linux
Then you might wish to install qt6-base-debug package.
You can install manually (by specifying the url), or by enabling global repo. See wiki.
pacman -U https://geo.mirror.pkgbuild.com/extra-debug/os/x86_64/qt6-base-debug-6.7.2-1-x86_64.pkg.tar.zst
-
Ensure you have satisfied requirements.
-
GDB only. Ensure there is nothing in your gdbinit, what might disrupt pretty printing. Disable your
gdbinit.Run the command to check
info pretty-printer🔷 In the case of
Visual Studio Codeyou need to call the gdb commands with the-execprefix. I.e.-exec info pretty-printer.Should print something like:
global pretty-printers: builtin mpx_bound128 qt6_lookup objfile /usr/lib/libstdc++.so.6 pretty-printers: libstdc++-v6
-
Ensure the proper
Qtfiles loaded at runtime.🔷 On Linux one might have
Qtinstalled on the host system as a runtime libraries, for instance if the host system runs KDE. The debug target might load theQtlibraries from the host system, instead of theQtdevelopment SDK.Run the command to check:
GDB
info sharedlibrary🔷 In the case of
Visual Studio Codeyou need to call the gdb commands with the-execprefix. I.e.-exec info sharedlibrary.Should print something like:
0x00007ffff7e63940 0x00007ffff7f58b1a Yes /home/user/Qt/6.6.1/gcc_64/lib/libQt6Network.so.6 0x00007ffff751f300 0x00007ffff7c0abe2 Yes /home/user/Qt/6.6.1/gcc_64/lib/libQt6Gui.so.6 0x00007ffff6cb75e0 0x00007ffff70848eb Yes /home/user/Qt/6.6.1/gcc_64/lib/libQt6Core.so.6LLDB
target modules listShould print something like:
[ 3] 0B3D90D4-3A24-26F8-2D28-E6FD902D2E1C-B1957B9C 0x00007ffff7e16000 /home/user/Qt/6.6.1/gcc_64/lib/libQt6Network.so.6 /home/user/Qt/6.6.1/gcc_64/lib/Qt6Network.debug [ 4] 8D17CAB4-3968-A65B-FA7A-452CBB959B12-FE3D941E 0x00007ffff7400000 /home/user/Qt/6.6.1/gcc_64/lib/libQt6Gui.so.6 /home/user/Qt/6.6.1/gcc_64/lib/Qt6Gui.debug [ 5] 70B3E481-9AFD-557A-D568-DB9065A3D74A-503165F0 0x00007ffff6c00000 /home/user/Qt/6.6.1/gcc_64/lib/libQt6Core.so.6 /home/user/Qt/6.6.1/gcc_64/lib/Qt6Core.debug -
Ensure the
Qtversion supports pretty printing.🔷 There are problematic
Qtversions, e.g.6.4.2, for which the debugger is unable to extract type metadata. Consider switching to another version ofQt.To check whether the
Qtversion has metadata, run:GDB
python print(gdb.parse_and_eval('*(&qtHookData)'))🔷 In the case of
Visual Studio Codeyou need to call the gdb commands with the-execprefix. I.e.-exec python print(...).If degugger could read the metadata, it will print something like:
{3, 7, 394754, 0, 0, 0, 22}or
0x7ffff729bd00 <qtHookData>Otherwise:
<data variable, no debug info>





