GSOC - Provide Qt pretty printer for command line gdb

Ralf Habacker ralf.habacker at freenet.de
Wed Jun 2 14:15:35 BST 2021


Am 31.05.21 um 16:22 schrieb Ralf Habacker:
Hi Ebuka,

> As we stated together, the first goal is to provide QtCore - pretty
> printers for gdb on the command line to debug the console program
> klauncher5 I presented yesterday on Windows with Qt5 information.

I want to give you a real world example about what I'm taking about:

I downloaded a portable kmymoney package from
https://kmymoney.org/snapshots.php and unpacked it.

Then I got gdb for Windows and downloaded it.

I entered the kmymoney bin dir e.g.

cd <unpacked-dir>\bin

and did run

<gdb-install-root>\bin\gdb klauncher5.exe
r

In the explorer then I started kmymoney.exe, opened a kmymoney file (if
not present a new file needs to be created and saved). Then I closed
kmymoney.

After a few minutes gdb received a Segmentation fault as reported at
https://bugs.kde.org/show_bug.cgi?id=426387.

Then I showed the backtrace

(gdb)bt
Thread 1 received signal SIGSEGV, Segmentation fault.
QWeakPointer<QObject>::data (this=0x28b8620, this=0x28b8620)
    at
/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore/qsharedpointer_impl.h:569
569     in
/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore/qsharedpointer_impl.h
(gdb) bt
#0  QWeakPointer<QObject>::data (this=0x28b8620, this=0x28b8620)
    at
/usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore/qsharedpointer_impl.h:569
#1  QPointer<KIO::IdleSlave>::data (this=0x28b8620)
    at /usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore/qpointer.h:86
#2  QPointer<KIO::IdleSlave>::operator KIO::IdleSlave* (this=0x28b8620)
    at /usr/i686-w64-mingw32/sys-root/mingw/include/qt5/QtCore/qpointer.h:92
#3  KLauncher::idleTimeout (this=this at entry=0x28b71d8)
    at
/home/abuild/rpmbuild/BUILD/kinit-5.65.0/src/klauncher/klauncher.cpp:1142
#4  0x0040a37a in KLauncher::qt_static_metacall (_o=_o at entry=0x28b71d8,
_id=_id at entry=7, _a=_a at entry=0x61db28,
    _c=QMetaObject::InvokeMetaMethod)
...

Inspecting the current object:

(gdb) p this
$1 = (const QWeakPointer<QObject> * const) 0x28b8620
(gdb) p *this
$2 = {d = 0xfeeefeee, value = 0xfeeefeee}

shows that the private object, the QWeakpointer instance contains, has
been free'd for unknown reasons. Access to the private object raised the
crash.

More information were available from showing frame 3

(gdb) frame 3
#3  KLauncher::idleTimeout (this=this at entry=0x28b71d8)
    at
/home/abuild/rpmbuild/BUILD/kinit-5.65.0/src/klauncher/klauncher.cpp:1142
1142        for (IdleSlave *slave : qAsConst(mSlaveList)) {

Now I wanted to inspect mSlaveList

(gdb) p mSlaveList
$4 = {{wp = {d = 0x28e4b40, value = 0x28c82f8}}, {wp = {d = 0x28e66f8,
value = 0x28dc628}}}

(gdb) p *mSlaveList->d
$5 = {ref = {atomic = {_q_value = {<std::__atomic_base<int>> = {static
_S_alignment = 4,
          _M_i = 1}, <No data fields>}}}, alloc = 12, begin = 0, end =
2, array = {0x28e9a50}}

but I did not see anything useful because of the missing qt5 printers.

Regards
Ralf




More information about the Kde-finance-apps mailing list