5
This document is still a work in progress.
7
Here are some very rough notes on how to set up Telegram for debugging.
9
Build the library in debug mode
10
===============================
11
Append to the cmake line in build.sh:
13
${SDK_PATH}/qtc_chroot_cmake ${CLICK_SDK_ARCH} ${CLICK_SDK_FRAMEWORK} $SERIES ../.. -DCMAKE_BUILD_TYPE=Debug
18
When stepping through a stack trace in gdb, it may be useful to have debug
19
symbols for the Qt libraries.
21
In Ubuntu, the debug symbol packages are built and hosted on a different
22
server from the standard source and binary packages. To get them:
24
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list
25
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 428D7C01
27
And then of course, issue ``sudo apt-get update``.
29
The next step is to install the symbol packages. The package names correspond
30
to the binary package names, with "-dbgsym" appended. For example, to get
31
the symbols for qtbase5-dev:
33
sudo apt-get install qtbase5-dev-dbgsym
35
Beware that the symbols can be quite large in terms of disk space, and it is
36
assumed you are debugging with gdb on your desktop, where storage is less of
37
an issue than a device.
39
Finally, understand that installing debug symbols only partially improves
40
the debugging experience in gdb. An additional nicety is to install the
41
actual library source, so that you can easily view source code from gdb
44
Here is one technique to do so. First, download the actual source for the
45
package you are interested in:
49
apt-get source qtbase5-dev
52
Next, you must start gdb properly so it knows how to find the new source
53
files. The key rune below is: ``find debug -type d -printf '-d %p'``
55
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:build/amd64/library/lib QML2_IMPORT_PATH=build/amd64/library/qmlplugin gdb qmlscene `find debug -type d -printf '-d %p '`
57
After starting gdb, just a few extra commands, and you are on your
63
Now, when you get a crash and inspect the stack trace, you can view the
67
#0 0x00007ffff5232117 in __GI_raise (sig=sig@entry=6)
68
at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
69
#1 0x00007ffff5233808 in __GI_abort () at abort.c:89
70
#2 0x00007ffff5273fd4 in __libc_message (do_abort=do_abort@entry=1,
71
fmt=fmt@entry=0x7ffff537dba8 "*** Error in `%s': %s: 0x%s ***\n")
72
at ../sysdeps/posix/libc_fatal.c:175
73
#3 0x00007ffff527b5e6 in malloc_printerr (ptr=<optimized out>,
74
str=0x7ffff537dc90 "double free or corruption (!prev)", action=1)
76
#4 _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)
78
#5 0x00007ffff5ec9608 in QObject::event (this=0xc32780, e=<optimized out>)
79
at kernel/qobject.cpp:1232
82
#5 0x00007ffff5ec9608 in QObject::event (this=0xc32780, e=<optimized out>)
83
at kernel/qobject.cpp:1232
84
1232 qDeleteInEventHandler(this);
86
1227 case QEvent::ChildRemoved:
87
1228 childEvent((QChildEvent*)e);
90
1231 case QEvent::DeferredDelete:
91
1232 qDeleteInEventHandler(this);
94
1235 case QEvent::MetaCall:
100
Valgrind is a suite of tools, one of which is memcheck, which can be used to
101
detect memory leaks. Running it can be a bit complex, but this rune should
104
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:build/amd64/library/lib QML2_IMPORT_PATH=build/amd64/library/qmlplugin G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --tool=memcheck --leak-check=full --num-callers=40 --log-file=valgrind.log --track-origins=yes --trace-children=yes qmlscene telegram.qml
106
If you find the log to be noisy, you may wish to suppress some of the
107
warnings. Google for "valgrind suppressions" for the details. In the above
108
rune, you can add ``--gen-suppressions=all`` to generate suppressions.
110
Check out the ``tools/extract_suppressions.sh`` script and go from there.