| Home · All Classes · Grouped Classes · Annotated · Functions | ![]() |
This document describes useful techniques for debugging Qtopia and Qtopia applications. These techniques include:
This section provides instructions on how to debug desktop builds of Qtopia using gdb in a Linux environment.
To build an application with debug symbols:
CONFIG += debug
$ make clean
$ make
$ make install
The runqtopia script supports running Qtopia in several different debugging environments. To run Qtopia in using gdb:
runqtopia -runmode gdb
Once the gdb command prompt is displayed enter the following command to run Qtopia:
(gdb) run
Alternatively to debug an application outside of the Qtopia environment:
runqtopia -qpe theProgram -runmode gdb
Once the gdb command prompt is displayed enter the following command to run the application
(gdb) set args -qws
(gdb) run
If an application crashes, a core file is produced. Use the following commands to examine the core file contents:
$ runqtopia -qpe theProgram -runmode gdb
(gdb) core <core file>
(gdb) backtrace full
Note: If no core file is generated run: ulimit -c 64000.
Remote debugging using the GNU Debugger is possible between machines of the same or different architecture. In both instances the procedure is the same. However, when cross-debugging you must ensure that gdb finds and loads the correct shared libraries for the remote architecture.
On the remote machine run:
gdbserver :22222 qpe
On the host machine run:
ln -s /path/to/Qtopia/image /opt/Qtopia
$ /opt/toolchains/.../bin/gdb /opt/Qtopia/bin/qpe
(gdb) target remote REMOTE_IP_ADDRESS:22222
(gdb) handle SIG32 nostop noprint
(gdb) handle SIGTRAP nostop noprint
(gdb) handle SIGPIPE nostop noprint
(gdb) break main
(gdb) cont
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
For an example of a script that uses syslogd when starting Qtopia see <source>/devices/example/src/devtools/startup/qpe.sh
| Copyright © 2008 Nokia | Trademarks | Qtopia 4.3.3 |