| Home · All Classes · Grouped Classes · Annotated · Functions |
Qtopia provides GNU Debugger gdb to monitor program execution and to examine program status in the event of a crash and the qLog function to provide categorized logging of debug information. The following sections describe how to used gdb in a Linux environment and how to call implement the qLog function.
This section provides instructions on how to debug Qtopia applications using igdb in a Linux environment.
To build an application with debug symbols:
CONFIG += debug
$ make clean
$ make
$ make install
To run the debugging environmnent:
using the following commands:
$ qvfb &
$ qpe &
$ gdb theProgram
(gdb) r # run
Alternatively to debug an application outside of the Qtopia environment:
using the following commands:
$ qvfb &
$ gdb theProgram
(gdb) set args - qws # we need this to hook to the virtual frame buffer.
(gdb) list # if you want to list the main.cpp file
(gdb) b 6 # break at line six
(gdb) r # run
(gdb) s # step into
(gdb) r # continue
If an application built with debug crashes, a core file is produced. Use the following commands to examine the core file contents:
$ gdb theapplication core
(gdb) backtrace full
Remote debugging using the gdb debugger is available between machines of the same architecture. The process is as follows:
On the target machine run:
gdbserver 127.0.0.1:22222 qpe
On the host machine run:
Create symlink for /opt/Qtopia to image/Qtopia that was built for device
Run ddd and tell it the location od the cross built gdb:
ddd --debugger "/opt/toolchains/..../bin/gdb"
In ddd : file /opt/Qtopia/bin/qpe
In ddd : target remote deviceip:22222
In ddd : handle SIG32 nostop noprint
In ddd : handle SIGTRAP nostop noprint
In ddd : handle SIGPIPE nostop noprint
In ddd : break main
In ddd : cont
Note: If no core file is generated run: ulimit -c 64000.
Qtopia provides the qLog(CategoryIdentifier) function for categorized logging, built on top of the QDebug class in Qtopia Core.
The following is an example of using a log message in the source code:
#include <qtopialog.h>
qLog(Type) << "Test";
qLog(Type) << "string=" << str << ", int=" << i;
where Type is a category as defined in qtopialog-config.h.
The categories are declared by using one of the following macros:
The CategoryIdentifier has _QLog appended within the macros, so it can be any identifier you choose. The associated type name might be a useful choice:
qLog(QWidget) << "Created" << name;
For categories declared with QTOPIA_LOG_OPTION, the output of logging depends on the Log settings. As with all Qtopia settings files, the defaults are found in:
/opt/Qtopia/etc/default/Trolltech/Log.conf
and these are overridden by settings in:
$HOME/Settings/Trolltech/Log.conf
For example, the following enables logging messages related to the user interface:
[UI]
Enabled = 1
Name[] = User interface
Help[] = Anything to do with the user interface.
Note: Changes to the qLog only take effect when applications or the server restart.
To assist field testing, there is a Logging Settings application that uses the logread program to interface with the BusyBox syslogd output. To forward Qtopia's output to syslogd, use the logger program:
syslogd -C <buffersize>
For example, to start syslogd with a 512 byte circular buffer use:
syslogd -C 512
qpe 2>&1 | logger -t Qtopia
logread -f
| Copyright © 2007 Trolltech | Trademarks | Qtopia 4.3.0 |