Interactive Debugging KDE Apps with QtCreator

Recently I began using QtCreator to try and do some development on Amarok. During my day job as a Java developer I get to work with tools like Intellij, which is a great IDE when you can put aside the problems of Java GUI apps on Linux. For a long time I’ve been using vim for my KDE development which has been more than sufficient, but lately I’m craving some of that productivity win that a fully fledged IDE can give.

Today I’ll show you how you can set up your KDE application in Qt Creator and use it’s interactive debugging to enhance your development speed. I’ll assume that you have an existing KDE project and you’re using Qt Creator 1.1, and I’m not going to do any whining about bugs and that rubbish.

Firstly, you’ll need to open a project. It’s as easy as File > Open and then find your CMakeLists.txt file. Your project should be parsed and opened. While we’re at it, let’s make sure that our compilation is optimised to use all of our computational power. Visit the Projects tab, select Amarok and under Build Steps add -j5 (or similar) to the additional arguments input.

QtCreator project

Now let’s get straight to the debugging. Back in the Projects tab, find the Run Settings panel and add –nofork as an argument. This tells the application to run without forking so we can attach to the process without worrying about magic foo computer stuff. I’d also recommend enabling the debugging helper which can be turned on in the settings window (under debugging).

Press F5 to start the debugging the application. Either before or during, or after the application has started up, set breakpoints in the application by clicking on a margin in a source file. You’ll see a little red icon display.

Debugging

When you hit a breakpoint, the application will stop as it waits for the debugger. Here’s where using the interactive debugger wins over using gdb directly. You can easily see objects in the stack and navigate between callers. You can easily switch between thread dumps, and view local variables. You can set watches and not have to worry about remembering all the fiddly commands and what you are and aren’t watching. Stepping over and into functions is a breeze with the keyboard shortcuts (F10 and F11 to step over and into respectively).

This quick guide should hopefully be applicable to any KDE app, not just Amarok. I’ll let you discover the intricacies of using gdb as a debugging tool from within the IDE.

Posted in tech | Tagged , , , , , | 5 Comments

Amarok 2.1: Mini Update

A few weeks ago I started working on improving a few little niggling problems that I’ve been having with Amarok recently. Here’s a brief overview of what I’ve done.

Prettier Collection Browser
A image is really the best way to show this:
Collection browser improvements

You can see that each collection uses more space to make it easier to find and select/expand, a descriptive icon and the number of tracks in each collection.

Better Compilation Support
Various artist handling has been poor through Amarok 2, but we’re looking at remedies. Thanks to Michael Quinn, we have a patch that already vastly improves the detection of compilations during a collections can. You can see these albums in the screenshot above, too.

Improved iPodding
This mainly involves artwork support – writing and reading artwork to and from an iPod works nicely now. So, if you use your iPod as your main collection, you’ll be able to see your artwork now. There’s still no way to do a batch artwork update, but that’s certainly on the cards.

I don’t like to tease too much — so to save you asking, Amarok 2.1 beta 1 should be available for widespread testing within a fortnight. Lap it up when it arrives!

Posted in tech | 25 Comments

GdkPixbuf woes

For the last four days I’ve been trying to implement cover art support for iPods in Amarok 2.1. I’ve reached desperate measures here, appealing to the wider public for any hints that might be available.

Here’s the problem. Any returned GdkPixbuf objects from libgpod when called from within Amarok are invalid — they’re either garbled junk, null, glib asserts, or libgpod throws an assertion claiming something or other:

(process:26875): GdkPixbuf-CRITICAL **: gdk_pixbuf_scale_simple: assertion `src != NULL' failed
(process:26875): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(process:16782): CRITICAL **: unpack_UYVY: assertion `width * height * 2 == bytes_len' failed

The most bizarre part of it is that the exact same code works perfectly when called from within one of libgpod’s unit tests, and artwork retrieval works fine in gtkpod.

A few things I know for sure:

  1. There is only one version of libgpod installed (0.7.0), self compiled with gdkpixbuf support
  2. Gtkpod was also self compiled against libgpod 0.7.0
  3. The libgpod guys have been very involved but can’t provide any answers
  4. Both gtkpod and Amarok link to the same versions of libgpod and gdk:
    $> ldd /usr/lib/kde4/libamarok_collection-ipodcollection.so
    libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0
    libgpod.so.4 => /usr/lib/libgpod.so.4
    $> ldd `which gtkpod`
    libgdk_pixbuf-2.0.so.0 => /usr/lib/libgdk_pixbuf-2.0.so.0
    libgpod.so.4 => /usr/lib/libgpod.so.4
  5. Could it be a race condition somewhere? Perhaps, but as I see it, the code is only ever called from the Qt GUI thread.

Here’s the snippet of code: http://pastie.org/415144

Can anyone provide any insight to this problem? I’m going bananas trying to solve it.

Update: Problem solved folks! Turned out to be a misuse of the libgpod api – calling itdb_device_read_sysinfo() kills the artwork structs which have been already initialised. The blame game lies equally on Amarok (for incorrect usage) and libgpod (for poor documentation and unexpected results). Good news is that the grand folks upstream at libgpod have been notified and they’ll be improving their API and docs.

Posted in tech | Tagged , , , , , , | 11 Comments

World of Goo

A community service announcement:

World of Goo has been released for Linux.

It’s a wonderfully enjoyable puzzle game which has been awarded multiple awards across for the PC, Mac and Wii versions – and it has recently become available for Linux. It’s cheap, DRM & region free, and if you buy it you’ll not only be supporting indie game developers but also the gaming linux environment.

Why not try the demo?

Posted in tech | Tagged , , , | 8 Comments

Amarok on Twitter

Most of the Amarok crew are on Twitter – it’s been said before.

But if you’re a little more excited about developments in Amarok as opposed to the lives of the developers, you should checkout the official Amarok twitterer. You’ll be able to follow announcements, updates, cool tips, links, and we might throw in a few early announcements there ;) .

Posted in tech | 4 Comments