Basically it's the same as QtCreator supports, however with a few differences:
- also works in plain gdb on commandline
- no compiled debug-helper library needed
- a gdb-only solution

Of course everything can be combined, as seen here:

Currently supported classes are: QString, QByteArray, QList, QMap, QDate, QTime, QDateTime
The code can be found in KDevelop git (gdb plugin uses them by default). For using in cli you need the following in ~/.gdbinit:
python
import sys
sys.path.insert(0, '/home/niko/kdesvn/kde-git/kdevelop/debuggers/gdb/printers')
from qt4 import register_qt4_printers
register_qt4_printers (None)
end
set print pretty 1
import sys
sys.path.insert(0, '/home/niko/kdesvn/kde-git/kdevelop/debuggers/gdb/printers')
from qt4 import register_qt4_printers
register_qt4_printers (None)
end
set print pretty 1
Gdb also supports autoloading the pretty printers - they could be included in -dev packages. The merge request that would add it to qt is still pending.
And now I'm off watching an episode of dexter :D
I've added support for KTExtEditor::Cursor & Range in the meantime. You'll have to use this as .gdbinit:
ReplyDelete~~~~~~~~
python
import sys
sys.path.insert(0, '/home/niko/kdesvn/kde-git/kdevelop/debuggers/gdb/printers')
from qt4 import register_qt4_printers
register_qt4_printers (None)
from kde4 import register_kde4_printers
register_kde4_printers (None)
end
set print pretty 1
~~~~~~~~
Of course, don't forget to get kde4.py from svn.
OOOOOO nice job ;). Too bad I never use GDB other than getting backtraces because I usually find my issues through there. Any syntax highlighting? ;þ And thank you guys. I love you <3
ReplyDeleteQt Creator uses python dumpers for a while now (basically since that feature became first available in GDB). Are you sharing code there or did you reimplement the whole thing?
ReplyDelete@Anonymous:
ReplyDeletecreator works completely different. They also don't work in plain gdb on the commandline.
No codesharing happened, as creators are very different. Maybe nowadays it could be possible to borrow stuff...
Hmmm... creator works fine with my gdb from ubuntu, so it does not seem to need a customized GDB. The binary debugging helpers are no longer required either, so it seems to be all python now.
ReplyDelete@Anonymous: You are right. Qt Creator always worked with the normal "machine interface" of gdb (FSF gdb on Linux and Window, Apple's branch on Mac). Until gdb's python scripting became available with gdb 6.8.50, a kind of "pretty printing" was available using the "compiled dumpers" Niko mentioned. This is nowadays replaced by a normal (gdb) python script on all platforms that have a python-enabled gdb (i.e. Linux, Windows, Symbian, but not on Mac which still has to use the compiled version).
ReplyDelete