I'm in an enterprise environment (which means there's no possibility a priori to add pretty printers or change software at any level) using GDB (gdbserver) to debug an app using Qt on a different device.
While I'm debugging, I usually need to check the values of a Qt structure like a QMap, which has a QString as key.
Guess I have a map like this one:
QVariantMap map;
Now, while debugging, that happens:
(gdb) p dataMap.value()
Too few arguments in function call.
(gdb) p dataMap.value("first")
Cannot resolve method QVariantMap::value to any overloaded instance
(gdb) p dataMap.value("first", QVariant(""))
A syntax error in expression, near `(""))'.
According to QMap documentation, both 2nd and 3rd options should work.
That's pretty annoying, since I'd love to be able to check map's values without modifying my code.
It seems to me that there's some kind of missunderstanding between GDB and Qt.
Any help would be appreciated.
EDIT:
As pointed out by Mohammed, gdb doesn't have to understand conversion from const char *
to QString
.
It doesn't make any difference however, since I get the same error when I use QString("")
than this one seen in the third command of the original part with QVariant("")
.
(gdb) p params.value(QString("deliveryLimit"))
A syntax error in expression, near `"deliveryLimit"))'
In this case, it is a QHash, but this shouldn't be important since I'm looking for a way to debug Qt's value-key containers in general.