Debugging

INTRO

Debugging KDE applications can be done on different levels. Most applications "talk" invisibly through debug statements while they are running. Looking at this information mostly gives you enough info to find out what went wrong. This method will be discussed below in chapter ERROR MESSAGES

On a different level we have post-mortem debugging. This is used _after_ an application died, probably because of a programming error. The drkonqi dialog allows you to create a backtrace, and possibly find out where it went wrong.

There are debuggers like gdb which can do a lot more than just find out where it went wrong. You should read the man page of gdb to find out more, and possibly download 'kdbg', 'ddd', or 'inspire' which make gdb a lot simpler to use. This method will is discussed here.

ERROR MESSAGES

When you start a konsole and type the commands to start an application you will see all sorts of statements are printed in the konsole while the application is running. All applications print these messages, to look at them you have to know where to look. The application will have to be compiled with the debugging enabled. So using a RPM from a distribution will not give you this information. If you compiled the application yourself, make sure the configure option "--disable-debug" was not used.

In KDE all debugging text-output can be switched on or off based on so called 'sections'. One application can be one section. One part of the kde base libraries can be another section. Enable/disabling these sections from being printed can be done using the kdebugdialog application. For simple debugging selecting all sections is probably wise.

When you are debugging it is best to simply start a konsole and start the application from there. In a konsole you could simply type:

    kicker
and in the konsole kicker could return a message like:
    ERROR: kicker is already running!

When a lot of output is written to the konsole it might go out of view before you could read it, therefor it is easy to create a text file which contains all this information, to do so type the following:

    application 2>&1 | tee debug.log

where 'application' can be replaced with the application you are debugging. Afterwards you could open the file 'debug.log' to look at the messages again.

If you are NOT starting the application from a konsole the messages will be logged somewhere else, or they could have been discarded by the program that started your application.

If your application is started by clicking on an icon your best bet is to check the following log files. Beware; they contain logs for a lot of applications, not just the application you are debugging!

Case 1: You are using kdm, gdm or xdm (i.e. a graphical login screen)

On SuSE 6.x systems a file .X.err is created in your home-dir (that is with a leading dot '.' also watch the Capital)

On RedHat, Mandrake and Debian systems a file .xsession-errors is created in your home-dir (that is with a leading dot '.')

Case 2 : You are using startx : Use the following command to restart your session:

    startx 2>&1 | tee startx.log

so that all the debug messages of applications started at KDE's startup (and any application launched from the panel etc.) go to the file "startx.log"

Author: Thomas Zander (zander@kde.org)