Commit a598aa12 authored by hjk's avatar hjk
Browse files

add dumper for QMultiMap

parent 16b2c83d
......@@ -1123,8 +1123,8 @@ static void qDumpQHash(QDumper &d)
while (node != end) {
d.beginHash();
if (simpleKey) {
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "name");
P(d, "nameisindex", "1");
P(d, "name", "[" << i << "]");
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
if (simpleValue)
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
P(d, "type", valueType);
......@@ -1310,6 +1310,42 @@ static void qDumpQLocale(QDumper &d)
d.disarm();
}
static void qDumpQMapNode(QDumper &d)
{
const QMapData *h = reinterpret_cast<const QMapData *>(d.data);
const char *keyType = d.templateParameters[0];
const char *valueType = d.templateParameters[1];
qCheckAccess(h->backward);
qCheckAccess(h->forward[0]);
P(d, "value", "");
P(d, "numchild", 2);
if (d.dumpChildren) {
//unsigned keySize = d.extraInt[0];
//unsigned valueSize = d.extraInt[1];
unsigned mapnodesize = d.extraInt[2];
unsigned valueOff = d.extraInt[3];
unsigned keyOffset = 2 * sizeof(void*) - mapnodesize;
unsigned valueOffset = 2 * sizeof(void*) - mapnodesize + valueOff;
d << ",children=[";
d.beginHash();
P(d, "name", "key");
qDumpInnerValue(d, keyType, addOffset(h, keyOffset));
d.endHash();
d.beginHash();
P(d, "name", "value");
qDumpInnerValue(d, valueType, addOffset(h, valueOffset));
d.endHash();
d << "]";
}
d.disarm();
}
static void qDumpQMap(QDumper &d)
{
QMapData *h = *reinterpret_cast<QMapData *const*>(d.data);
......@@ -1355,18 +1391,16 @@ static void qDumpQMap(QDumper &d)
while (node != end) {
d.beginHash();
P(d, "name", "[" << i << "]");
if (simpleKey) {
P(d, "type", valueType);
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "name");
P(d, "nameisindex", "1");
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
if (simpleValue)
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
P(d, "type", valueType);
P(d, "addr", addOffset(node, valueOffset));
} else {
P(d, "name", "[" << i << "]");
#if QT_VERSION >= 0x040500
// actually, any type (even 'char') will do...
P(d, "type", NS"QMapNode<"
......@@ -1395,6 +1429,11 @@ static void qDumpQMap(QDumper &d)
d.disarm();
}
static void qDumpQMultiMap(QDumper &d)
{
qDumpQMap(d);
}
static void qDumpQModelIndex(QDumper &d)
{
const QModelIndex *mi = reinterpret_cast<const QModelIndex *>(d.data);
......@@ -1439,42 +1478,6 @@ static void qDumpQModelIndex(QDumper &d)
d.disarm();
}
static void qDumpQMapNode(QDumper &d)
{
const QMapData *h = reinterpret_cast<const QMapData *>(d.data);
const char *keyType = d.templateParameters[0];
const char *valueType = d.templateParameters[1];
qCheckAccess(h->backward);
qCheckAccess(h->forward[0]);
P(d, "value", "");
P(d, "numchild", 2);
if (d.dumpChildren) {
//unsigned keySize = d.extraInt[0];
//unsigned valueSize = d.extraInt[1];
unsigned mapnodesize = d.extraInt[2];
unsigned valueOff = d.extraInt[3];
unsigned keyOffset = 2 * sizeof(void*) - mapnodesize;
unsigned valueOffset = 2 * sizeof(void*) - mapnodesize + valueOff;
d << ",children=[";
d.beginHash();
P(d, "name", "key");
qDumpInnerValue(d, keyType, addOffset(h, keyOffset));
d.endHash();
d.beginHash();
P(d, "name", "value");
qDumpInnerValue(d, valueType, addOffset(h, valueOffset));
d.endHash();
d << "]";
}
d.disarm();
}
static void qDumpQObject(QDumper &d)
{
const QObject *ob = reinterpret_cast<const QObject *>(d.data);
......@@ -2363,6 +2366,8 @@ static void handleProtocolVersion2and3(QDumper & d)
qDumpQMapNode(d);
else if (isEqual(type, "QModelIndex"))
qDumpQModelIndex(d);
else if (isEqual(type, "QMultiMap"))
qDumpQMap(d);
break;
case 'O':
if (isEqual(type, "QObject"))
......@@ -2465,6 +2470,9 @@ void qDumpObjectData440(
"\""NS"QMap\","
"\""NS"QMapNode\","
"\""NS"QModelIndex\","
#if QT_VERSION >= 0x040500
"\""NS"QMultiMap\","
#endif
"\""NS"QObject\","
"\""NS"QObjectMethodList\"," // hack to get nested properties display
"\""NS"QObjectPropertyList\","
......
......@@ -2977,11 +2977,11 @@ void GdbEngine::runCustomDumper(const WatchData & data0, bool dumpChildren)
if (lastOpened != -1 && lastClosed != -1)
slotNumber = data.iname.mid(lastOpened + 1, lastClosed - lastOpened - 1);
extraArgs[0] = slotNumber;
} else if (outertype == m_namespace + "QMap") {
} else if (outertype == m_namespace + "QMap" || outertype == m_namespace + "QMultiMap") {
QString nodetype;
if (m_qtVersion >= (4 << 16) + (5 << 8) + 0) {
nodetype = m_namespace + "QMapNode";
nodetype += data.type.mid(m_namespace.size() + 4);
nodetype += data.type.mid(outertype.size());
} else {
nodetype = data.type + "::Node";
}
......@@ -3552,8 +3552,9 @@ void GdbEngine::handleDumpCustomValue2(const GdbResultRecord &record,
// << item.findChild("nameencoded").data()[1];
if (item.findChild("nameencoded").data()[0] == '1')
data1.name = QByteArray::fromBase64(data1.name.toUtf8());
if (item.findChild("nameisindex").data()[0] == '1')
data1.name = '[' + data1.name + ']';
QString key = item.findChild("key").data();
if (!key.isEmpty())
data1.name += " (" + key + ")";
setWatchDataType(data1, item.findChild("type"));
setWatchDataExpression(data1, item.findChild("exp"));
setWatchDataChildCount(data1, item.findChild("numchild"));
......
......@@ -295,7 +295,10 @@ void testQMultiMap()
gg0.insert(11, 11.0);
gg0.insert(22, 22.0);
gg0.insert(22, 33.0);
gg0.insert(22, 34.0);
gg0.insert(22, 35.0);
gg0.insert(22, 36.0);
#if 1
QMultiMap<QString, float> gg1;
gg1.insert("22.0", 22.0);
......@@ -313,6 +316,7 @@ void testQMultiMap()
map.insert("Welt", QPointer<QObject>(&ob));
map.insert(".", QPointer<QObject>(&ob));
map.insert(".", QPointer<QObject>(&ob));
#endif
}
void testQObject(int &argc, char *argv[])
......
Supports Markdown
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