[go: up one dir, main page]

Skip to content

Python scripts for pretty printing Qt types by GDB and LLDB

License

Notifications You must be signed in to change notification settings

winseros/Qt6Renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QT6 Renderer

The set of scripts for pretty printing Qt by GDB and LLDB.

IDE plugins

Qt versions support

  • 6.x

Qt types support

You can use the example project for testsing.

Debuggers support

  • LLDB
  • GDB

Operating systems tested on

  • Windows
  • Linux

Architectures tested on

  • x64

Manual installation

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.

GDB

  1. Copy the qt6renderer folder somewhere at your system.
  2. Place the gdbinit in the any of the supported places at your system.
  3. 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

Requirements

Pretty printers need Debug information for Qt.

If you installed Qt with Qt Online Installer, ensure you have installed the Qt Debug Information Files:

Checkbox for QtDebug 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

Troubleshooting

Qt Types are not pretty printed

  1. Ensure you have satisfied requirements.

  2. 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 Code you need to call the gdb commands with the -exec prefix. 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
    
  1. Ensure the proper Qt files loaded at runtime.

    🔷 On Linux one might have Qt installed on the host system as a runtime libraries, for instance if the host system runs KDE. The debug target might load the Qt libraries from the host system, instead of the Qt development SDK.

    Run the command to check:

    GDB
    info sharedlibrary
    

    🔷 In the case of Visual Studio Code you need to call the gdb commands with the -exec prefix. 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.6
    
    LLDB
    target modules list
    

    Should 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
    
  2. Ensure the Qt version supports pretty printing.

    🔷 There are problematic Qt versions, e.g. 6.4.2, for which the debugger is unable to extract type metadata. Consider switching to another version of Qt.

    To check whether the Qt version has metadata, run:

    GDB
    python print(gdb.parse_and_eval('*(&qtHookData)'))
    

    🔷 In the case of Visual Studio Code you need to call the gdb commands with the -exec prefix. 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>
    

    GDB could extract Qt Metadata - Visual Studio Code

    GDB could extract Qt Metadata - CLion

    Otherwise:

    <data variable, no debug info>
    

    GDB could not extract Qt Metadata - CLion

    LLDB
    script print(lldb.target.FindFirstGlobalVariable('qtHookData').GetPointeeData(2, 1))
    

    If degugger could read the metadata, it will print something like:

    02 07 06 00 00 00 00 00
    

    LLDB could extract Qt Metadata - Visual Studio Code

    LLDB could extract Qt Metadata - CLion

About

Python scripts for pretty printing Qt types by GDB and LLDB

Topics

Resources

License

Stars

Watchers

Forks

Languages