Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/winseros/qt6renderer
Python scripts for pretty printing Qt types by GDB and LLDB
https://github.com/winseros/qt6renderer
gdb lldb pretty-print pretty-printing qt qt6
Last synced: 2 months ago
JSON representation
Python scripts for pretty printing Qt types by GDB and LLDB
- Host: GitHub
- URL: https://github.com/winseros/qt6renderer
- Owner: winseros
- License: gpl-3.0
- Created: 2022-05-27T18:24:16.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-29T20:15:52.000Z (5 months ago)
- Last Synced: 2024-08-30T08:37:40.526Z (5 months ago)
- Topics: gdb, lldb, pretty-print, pretty-printing, qt, qt6
- Language: Python
- Homepage:
- Size: 460 KB
- Stars: 16
- Watchers: 3
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# QT6 Renderer
The set of scripts for pretty printing [Qt][qt] by [GDB][gdb] and [LLDB][lldb].
## IDE plugins
* [CLion][qt6renderer_intlj]
* [Visual Studio Code][qt6renderer_vsc]## Qt versions support
* 6.x## Qt types support
* [See here for GDB](./python/gdb)
* [See here for LLDB](./python/lldb)You can use the [example project][qt6renderer_exmpl] 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](./python/gdb/qt6renderer/) folder somewhere at your system.
2. Place the [gdbinit][gdbinit] in the any of the supported places at your system.
3. Add the following content to the `gdbinit`:
```python
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](images/qt_debug_information_files_checkbox.png)
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](https://wiki.archlinux.org/title/Debugging/Getting_traces#Installing_debug_packages).```
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](#requirements).
2. GDB only. Ensure there is nothing in your [gdbinit][gdbinit], what might disrupt pretty printing. Disable your `gdbinit`.
Run the command to check```
info pretty-printer
```> :large_blue_diamond: In the case of `Visual Studio Code` [you need][vscode_exec] 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
```
3. Ensure the proper `Qt` files loaded at runtime.> :large_blue_diamond: 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
```> :large_blue_diamond: In the case of `Visual Studio Code` [you need][vscode_exec] 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
```
4. Ensure the `Qt` version supports pretty printing.> :large_blue_diamond: 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)'))
```> :large_blue_diamond: In the case of `Visual Studio Code` [you need][vscode_exec] 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
```![GDB could extract Qt Metadata - Visual Studio Code](images/gdb_qt_meta_available_vsc.png)
![GDB could extract Qt Metadata - CLion](images/gdb_qt_meta_available_jb.png)
Otherwise:
```
```![GDB could not extract Qt Metadata - CLion](images/gdb_qt_meta_unavailable_jb.png)
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](images/lldb_qt_meta_available_vsc.png)
![LLDB could extract Qt Metadata - CLion](images/lldb_qt_meta_available_jb.png)
[qt]: https://www.qt.io/
[gdb]: https://sourceware.org/gdb/
[lldb]: https://lldb.llvm.org/
[qt6renderer_exmpl]: https://github.com/winseros/Qt6RendererExmpl
[qt6renderer_intlj]: https://github.com/winseros/Qt6RendererIntlj
[qt6renderer_vsc]: https://github.com/winseros/Qt6RendererVsc
[gdbinit]: https://man7.org/linux/man-pages/man5/gdbinit.5.html
[vscode_exec]: https://github.com/Microsoft/vscode-cpptools/issues/106