Commit 14321e67 authored by hjk's avatar hjk
Browse files

debugger: add dumper for QWeakPointer

parent 3f735e44
......@@ -2187,6 +2187,44 @@ static void qDumpQVector(QDumper &d)
d.disarm();
}
static void qDumpQWeakPointer(QDumper &d)
{
const int v = sizeof(void *);
const void *value = deref(addOffset(d.data, v));
if (isSimpleType(d.innertype))
qDumpInnerValueHelper(d, d.innertype, value);
else
P(d, "value", "");
P(d, "valuedisabled", "true");
P(d, "numchild", 1);
if (d.dumpChildren) {
d << ",children=[";
d.beginHash();
P(d, "name", "data");
qDumpInnerValue(d, d.innertype, value);
d.endHash();
d.beginHash();
const void *weak = addOffset(deref(d.data), v);
P(d, "name", "weakref");
P(d, "value", *static_cast<const int *>(weak));
P(d, "type", "int");
P(d, "addr", weak);
P(d, "numchild", "0");
d.endHash();
d.beginHash();
const void *strong = addOffset(weak, sizeof(int));
P(d, "name", "strongref");
P(d, "value", *static_cast<const int *>(strong));
P(d, "type", "int");
P(d, "addr", strong);
P(d, "numchild", "0");
d.endHash();
d << "]";
}
d.disarm();
}
static void qDumpStdList(QDumper &d)
{
const std::list<int> &list = *reinterpret_cast<const std::list<int> *>(d.data);
......@@ -2559,16 +2597,6 @@ static void handleProtocolVersion2and3(QDumper & d)
else if (isEqual(type, "QStringList"))
qDumpQStringList(d);
break;
case 'T':
if (isEqual(type, "QTextCodec"))
qDumpQTextCodec(d);
break;
case 'V':
if (isEqual(type, "QVariant"))
qDumpQVariant(d);
else if (isEqual(type, "QVector"))
qDumpQVector(d);
break;
case 's':
if (isEqual(type, "wstring"))
qDumpStdWString(d);
......@@ -2589,6 +2617,19 @@ static void handleProtocolVersion2and3(QDumper & d)
else if (isEqual(type, "std::wstring"))
qDumpStdWString(d);
break;
case 'T':
if (isEqual(type, "QTextCodec"))
qDumpQTextCodec(d);
break;
case 'V':
if (isEqual(type, "QVariant"))
qDumpQVariant(d);
else if (isEqual(type, "QVector"))
qDumpQVector(d);
break;
case 'W':
if (isEqual(type, "QWeakPointer"))
qDumpQWeakPointer(d);
}
if (!d.success)
......@@ -2664,6 +2705,7 @@ void *qDumpObjectData440(
"\""NS"QTextCodec\","
"\""NS"QVariant\","
"\""NS"QVector\","
"\""NS"QWeakPointer\","
"\""NS"QWidget\","
#ifdef Q_OS_WIN
"\"basic_string\","
......
......@@ -3047,11 +3047,10 @@ void GdbEngine::runDebuggingHelper(const WatchData &data0, bool dumpChildren)
//int protocol = isDisplayedIName(data.iname) ? 3 : 2;
QString addr;
if (data.addr.startsWith(QLatin1String("0x"))) {
if (data.addr.startsWith(QLatin1String("0x")))
addr = QLatin1String("(void*)") + data.addr;
} else {
else
addr = QLatin1String("&(") + data.exp + QLatin1Char(')');
}
sendWatchParameters(params);
......
......@@ -549,9 +549,13 @@ void testQSharedPointer()
QSharedPointer<QString> ptr2 = ptr;
QSharedPointer<QString> ptr3 = ptr;
//QWeakPointer<QString> wptr(ptr);
//QWeakPointer<QString> wptr2 = wptr;
//QWeakPointer<QString> wptr3 = wptr;
QWeakPointer<int> wiptr(iptr);
QWeakPointer<int> wiptr2 = wiptr;
QWeakPointer<int> wiptr3 = wiptr;
QWeakPointer<QString> wptr(ptr);
QWeakPointer<QString> wptr2 = wptr;
QWeakPointer<QString> wptr3 = wptr;
}
void stringRefTest(const QString &refstring)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment