Posts Tagged ‘Debugging’

Qt5 Pretty Printers for GDB

4th June 2014

If you’ve ever debugged a Qt program in GDB and been frustrated when attempting to print a QString gives you an unhelpful result like

$1 = {d = 0x6e7c40}

then kde-dev-scripts has some useful tools for you. For some time now, there has been the kde-devel-gdb script, which you can include in your ~/.gdbinit. This gives you commands like “printq4string” and “printq5string” which will dump the actual string contents of a QString.

However, GDB 7 has the ability to add pretty-printers written in Python. This means that you can control how a value is output when you use “print” and when backtraces are printed. So “print someQString” will actually write out the string for you.

The gdb directory of kde-dev-scripts now has some of these pretty-printers for Qt5. Currently, it covers most of the main value classes and collection classes in QtCore (QByteArray, QString, QStringList, QList, QMap, etc). QHash and QSet are the most notable ones that are missing.

To use these pretty-printers, you either need to source the “load-qt5printers.py” file in your GDB session, or use the “create-qt5-autoloaders.py” script to generate files that will allow GDB to auto-load the printers when it loads the Qt5 libraries.

I plan to eventually submit these to Qt, so that pretty-printing of Qt value classes will work out of the box. For now, do let me know if you run into any issues with them (don’t forget to compile your application with debugging symbols!), and feel free to extend what’s there, or use it as a template for some Qt4 pretty-printers.

Advertisements

/me hates my DVD drive

3rd October 2008

I’ve finally given up on my DVD drive.  For a long time, VLC has been the only thing that would countenance even trying to play DVDs on it, and even that occasionally claimed that there was an audio CD in the drive until it was removed and put in again.

Now, after upgrading libdvdcss and unplugging a harddrive from the IDE channel my DVD drive is on, trying to play dvds gets me:

export DVDCSS_VERBOSE=2 && vlc /dev/dvd

libdvdnav: Using dvdnav version 0.1.10 from http://dvd.sf.net
libdvdread: Using libdvdcss version 1.2.9 for DVD access
libdvdcss debug: opening target `/dev/dvd'
libdvdcss debug: using libc for access
libdvdcss debug: disc is scrambled
libdvdcss debug: requesting AGID
libdvdcss error: drive would not authenticate
libdvdread: Could not open /dev/dvd with libdvdcss.
libdvdread: Can't open /dev/dvd for reading
libdvdnav: vm: faild to open/read the DVD

Epic fail.  Other people have had this problem with AOpen drives, so I think it’s high time I got a new DVD rewriter.  Preferably one that can write double-layer DVDs (which mine currently can’t).

The main reason I’m posting this is because, after I googled for problems with DVD playback, I discovered that almost no-one knows about the DVDCSS_VERBOSE environment variable.  There’s a corresponding one (DVDREAD_VERBOSE) for libdvdread, although I couldn’t get that to do anything.  I only found out about these debug variables by looking through the source code trying to debug the problem (after libdvdread claimed it couldn’t open /dev/dvd, but dd if=/dev/dvd of=/dev/null count=200 had no problems).

Oh, and strace is really cool.  That was one of my debug steps, and one I’d never have thought of until I saw someone’s blog about it a few weeks ago.

Maybe I’ll finally be able to use Dragon player (which has a cool icon) when I get my new drive.

[edit] At Spanner‘s suggestion, I fixed it by setting the region with regionset.  Now Dragon Player works too! [/edit]