Debugging Desktop applets

Introduction

Debugging desktop (home or statusbar) applets is actually quite easy. While the default installation makes it quite hard, there are ways to make it almost as easy as for any other app. For the brave of heart running sardine, this document applies just as well, just replace maemo_af_desktop with hildon-desktop where applicable.

Launcher

The maemo-af-desktop uses maemo-launcher to reduce startup time. This makes using gdb or valgrind rather hard, if not impossible, as the maemo_af_desktop -command only calls an invoker, which, in turn, is not the one crashing. The real desktop binary is a shared object, and you cannot launch it directly. So what we need to do, is run it with maemo-summoner or make desktop not use launcher. Launcher README

Desktop with maemo-summoner

Running with maemo-summoner requires no recompilation, just different commands. This is the preferred method, as it is a lot easier.

Launcherless desktop

Building maemo-af-desktop to be debugger friendly is rather straightforward, here are the steps:

apt-get source maemo-af-desktop
fakeroot apt-get build-dep maemo-af-desktop
cd maemo-af-desktop-*
DEB_BUILD_OPTIONS=nostrip,noopt dpkg-buildpackage -rfakeroot

The build process shouldn't take too long on any modern computer, and within 5 minutes, you should have maemo-af-desktop_<version>_i386.deb in the directory you typed apt-get source in, if you plan to debug on the device, the package is _armel.deb. Just dpkg -i this package (with fakeroot in sbox or as root on device) and you're good to go. The binary should also contain debugging symbols, which should help a lot.

Compiling your own program

Obviously, as the desktop contains debugging symbols, so should your applet. For most packages using the DEB_BUILD_OPTIONS=nostrip,noopt should be enough; but if you're doing some greater magic, you might have to add -g somewhere to be included in CFLAGS.

Debugging

Now that you've installed the launcherless desktop, debugging is straightforward; start the framework, kill desktop and start it again with gdb or valgrind; for example like this with maemo-summoner:

# af-sb-init.sh start
# killall maemo_af_desktop
# run-standalone.sh gdb /usr/bin/maemo-summoner
gdb> run /usr/bin/maemo_af_desktop.launch

or like this, if desktop built without launcher:

# af-sb-init.sh start
# killall maemo_af_desktop
# run-standalone.sh gdb /usr/bin/maemo_af_desktop
gdb> run

Now you have desktop being run in gdb session - yay. Note, that if debugging on the device, memory may be scarce, so using a swap file is recommended.