PDA

View Full Version : Debugging QLIst with gdb



enno
1st June 2015, 08:56
gdb appears unable to understand the [] operator of a QList<T> object. I used the following program

#include <QList>
int main(int, char** ) {
QList<int> ints;
ints << 123 << 240;
printf("size %d ints[1] = %d\n", ints.size(), ints[1]);
return 0;
}
I am using SuSE 13.2 with
gcc version 4.8.3 20140627 [gcc-4_8-branch revision 212064] (SUSE Linux)

The following output shows that the program appears to run properly but gdb has a problem.

enno@linux:~/prog/trial> make -B
/usr/bin/qmake -o Makefile trial.pro
g++ -c -std=c++11 -g -Wall -W -D_REENTRANT -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/default -I. -I/usr/include/QtCore -I/usr/include -I. -I. -o trial.o trial.cpp
g++ -o trial trial.o -L/usr/lib64 -lQtCore -L/usr/lib64 -lpthread
{ test -n "" && DESTDIR="" || DESTDIR=.; } && gdb --nx --batch --quiet -ex 'set confirm off' -ex "save gdb-index $DESTDIR" -ex quit 'trial' && test -f trial.gdb-index && objcopy --add-section '.gdb_index=trial.gdb-index' --set-section-flags '.gdb_index=readonly' 'trial' 'trial' && rm -f trial.gdb-index || true
enno@linux:~/prog/trial> gdb
GNU gdb (GDB; openSUSE 13.2) 7.8
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-suse-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) show build-id-verbose
Verbosity level of the build-id locator is 2.
(gdb) file trial
Reading symbols from trial...done.
(gdb) b trial.cpp:6
Breakpoint 1 at 0x400c6b: file trial.cpp, line 6.
(gdb) r
Starting program: /home/enno/prog/trial/trial
Got object file from memory but can't read symbols: File truncated.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
size 2 ints[1] = 240

Breakpoint 1, main () at trial.cpp:6
6 return 0;
(gdb) p ints.size()
$1 = 2
(gdb) p ints[1]
Could not find operator[].
(gdb) q

When I do a similar test using the stdc++ vector class gdb has no problem,
so it appears to be a Qt problem. Is this a bug or do I forget something.

Appreciate any help.
Enno