Debugging

How to debug Telepathy problems.

Connection managers

In general, debugging involves running the connection manager in an interactive shell. When you do this, it will connect to the D-Bus session bus, just as it would normally. A terminal emulator inside an X session will generally have access to the session bus.

Connection manager executables might not be in your $PATH, so you might need to provide the full path to invoke them.

Obtaining logs

Logs are very useful for debugging problems. Connection managers generally don't create logs by default, but allow enabling logging through environment variables. Since these variables won't be set when the connection manager is launched by the D-Bus daemon, the connection manager needs to be run manually for log collection.

The two standard variables used are X_DEBUG and X_LOGFILE, where X is the name of the connection manager. For instance, for Gabble the variables are GABBLE_DEBUG and GABBLE_LOGFILE.

Usually you will want to set the _DEBUG variable to "all".

There is also a X_PERSIST variable, which, when set, tells the connection manager not to exit when it has no connections.

Example command line:

FOO_PERSIST=1 FOO_DEBUG=all telepathy-foo 2>&1 | tee foo.log

This will print out the log messages as they appear, and also save them to foo.log.

If the connection manager complains about "name already or use" or similar, quit your Telepathy client (Empathy etc.) and try again.

Gabble

When debugging Gabble, it's usually a good idea to set LM_DEBUG=net so that the XML stanzas are also captured in the logfile.

Stream Engine

Debugging Stream Engine is similar to debugging a connection manager.

STREAM_ENGINE_PERSIST=1 telepathy-stream-engine 2>&1 | tee s-e.log

Debugging crashes

General

If you are experiencing crashes, it's a good idea to install any Telepathy debug packages provided by your distribution.

On Debian-like systems, debugging packages include:

GDB

You might be able to obtain debug information using gdb (for connection managers, you probably also want to use the X_PERSIST variable for this):

$ GABBLE_PERSIST=1 gdb telepathy-gabble
GNU gdb 6.7.1-debian
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
Using host libthread_db library "/lib/i686/cmov/libthread_db.so.1".
(gdb) r
Starting program: /usr/bin/telepathy-gabble 
** (telepathy-gabble:17666): DEBUG: started version 0.6.0 (telepathy-glib version 0.7.0)

If the program crashes while running under gdb, use the "bt" command to obtain a backtrace.

Valgrind

Valgrind can find many bugs.

Electric Fence

Electric Fence can find some memory allocation bugs.

To use it, run Programs with LD_PRELOAD=/usr/lib/libefence.so.0.0.