diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index 9e3ce85c2451299c92e25f54546606d0064b4f62..520378ea19550b60709a256d5e11ff0c753ad978 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -481,6 +481,11 @@ struct QDumper put(name).put('=').put('"').put(value).put('"'); } + void putItem(const char *name, const char *value, const char *setvalue) + { + if (!isEqual(value, setvalue)) + putItem(name, value); + } // convienience functions for writing typical properties. // roughly equivalent to // beginHash(); @@ -537,6 +542,9 @@ struct QDumper bool success; // are we finished? bool full; int pos; + + const char *currentChildType; + const char *currentChildNumChild; }; @@ -546,6 +554,8 @@ QDumper::QDumper() full = false; outBuffer[0] = 'f'; // marks output as 'wrong' pos = 1; + currentChildType = 0; + currentChildNumChild = 0; } QDumper::~QDumper() @@ -777,10 +787,14 @@ void QDumper::beginChildren(const char *mainInnerType) { if (mainInnerType) { putItem("childtype", mainInnerType); - if (isSimpleType(mainInnerType) || isStringType(mainInnerType)) + currentChildType = mainInnerType; + if (isSimpleType(mainInnerType) || isStringType(mainInnerType)) { putItem("childnumchild", "0"); - else if (isPointerType(mainInnerType)) + currentChildNumChild = "0"; + } else if (isPointerType(mainInnerType)) { putItem("childnumchild", "1"); + currentChildNumChild = "1"; + } } putCommaIfNeeded(); @@ -790,6 +804,8 @@ void QDumper::beginChildren(const char *mainInnerType) void QDumper::endChildren() { put(']'); + currentChildType = 0; + currentChildNumChild = 0; } // simple string property @@ -869,7 +885,7 @@ static void qDumpUnknown(QDumper &d, const char *why = 0) why = DUMPUNKNOWN_MESSAGE; d.putItem("value", why); d.putItem("type", d.outertype); - d.putItem("numchild", "0"); + d.putItem("numchild", "0", d.currentChildNumChild); d.disarm(); } @@ -880,7 +896,7 @@ static void qDumpStdStringValue(QDumper &d, const std::string &str) d.endItem(); d.putItem("valueencoded", "1"); d.putItem("type", "std::string"); - d.putItem("numchild", "0"); + d.putItem("numchild", "0", d.currentChildNumChild); } static void qDumpStdWStringValue(QDumper &d, const std::wstring &str) @@ -889,8 +905,8 @@ static void qDumpStdWStringValue(QDumper &d, const std::wstring &str) d.putBase64Encoded((const char *)str.c_str(), str.size() * sizeof(wchar_t)); d.endItem(); d.putItem("valueencoded", (sizeof(wchar_t) == 2 ? "2" : "3")); - d.putItem("type", "std::wstring"); - d.putItem("numchild", "0"); + d.putItem("type", "std::wstring", d.currentChildType); + d.putItem("numchild", "0", d.currentChildNumChild); } // Called by templates, so, not static. @@ -902,7 +918,7 @@ static void qDumpInnerQCharValue(QDumper &d, QChar c, const char *field) buf[1] = char(c.unicode()); d.putCommaIfNeeded(); d.putItem(field, buf); - d.putItem("numchild", 0); + d.putItem("numchild", "0", d.currentChildNumChild); } static void qDumpInnerCharValue(QDumper &d, char c, const char *field) @@ -913,7 +929,7 @@ static void qDumpInnerCharValue(QDumper &d, char c, const char *field) buf[1] = c; d.putCommaIfNeeded(); d.putItem(field, buf); - d.putItem("numchild", 0); + d.putItem("numchild", "0", d.currentChildNumChild); } void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr, @@ -1016,7 +1032,7 @@ void qDumpInnerValueHelper(QDumper &d, const char *type, const void *addr, static void qDumpInnerValue(QDumper &d, const char *type, const void *addr) { d.putItem("addr", addr); - d.putItem("type", type); + d.putItem("type", type, d.currentChildType); if (!type[0]) return; @@ -1031,7 +1047,7 @@ static void qDumpInnerValueOrPointer(QDumper &d, if (deref(addr)) { d.putItem("addr", deref(addr)); d.putItem("saddr", deref(addr)); - d.putItem("type", strippedtype); + d.putItem("type", strippedtype, d.currentChildType); qDumpInnerValueHelper(d, strippedtype, deref(addr)); } else { d.putItem("addr", addr); @@ -1041,7 +1057,7 @@ static void qDumpInnerValueOrPointer(QDumper &d, } } else { d.putItem("addr", addr); - d.putItem("type", type); + d.putItem("type", type, d.currentChildType); qDumpInnerValueHelper(d, type, addr); } } @@ -1186,7 +1202,6 @@ static void qDumpQByteArray(QDumper &d) unsigned char u = (isprint(c) && c != '\'' && c != '"') ? c : '?'; sprintf(buf, "%02x (%u '%c')", c, c, u); d.beginHash(); - d.putItem("name", i); d.putItem("value", buf); d.endHash(); } @@ -1474,7 +1489,6 @@ static void qDumpQHash(QDumper &d) d.beginChildren(); while (node != end) { d.beginHash(); - d.putItem("name", i); qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key"); qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset)); if (isSimpleKey && isSimpleValue) { @@ -1616,7 +1630,6 @@ static void qDumpQList(QDumper &d) d.beginChildren(n ? d.innertype : 0); for (int i = 0; i != n; ++i) { d.beginHash(); - d.putItem("name", i); if (innerTypeIsPointer) { void *p = ldata.d->array + i + pdata->begin; d.putItem("saddr", p); @@ -1675,7 +1688,6 @@ static void qDumpQLinkedList(QDumper &d) const void *p = deref(ldata); for (int i = 0; i != n; ++i) { d.beginHash(); - d.putItem("name", i); const void *addr = addOffset(p, 2 * sizeof(void*)); qDumpInnerValueOrPointer(d, d.innertype, stripped, addr); p = deref(p); @@ -1821,7 +1833,6 @@ static void qDumpQMap(QDumper &d) while (node != end) { d.beginHash(); - d.putItem("name", i); qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key"); qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset)); if (isSimpleKey && isSimpleValue) { @@ -2552,7 +2563,6 @@ static void qDumpQObjectChildList(QDumper &d) d.beginChildren(); for (int i = 0; i != size; ++i) { d.beginHash(); - d.putItem("name", i); qDumpInnerValueHelper(d, NS"QObject *", children.at(i)); d.endHash(); } @@ -2600,7 +2610,6 @@ static void qDumpQSet(QDumper &d) for (int bucket = 0; bucket != hd->numBuckets && i <= 10000; ++bucket) { for (node = hd->buckets[bucket]; node->next; node = node->next) { d.beginHash(); - d.putItem("name", i); d.putItem("type", d.innertype); d.beginItem("exp"); d.put("(('"NS"QHashNode<").put(d.innertype @@ -2705,7 +2714,6 @@ static void qDumpQStringList(QDumper &d) d.beginChildren(n ? NS"QString" : 0); for (int i = 0; i != n; ++i) { d.beginHash(); - d.putItem("name", i); d.putItem("value", list[i]); d.putItem("valueencoded", "2"); d.endHash(); @@ -2764,7 +2772,6 @@ static void qDumpQVector(QDumper &d) d.beginChildren(d.innertype); for (int i = 0; i != n; ++i) { d.beginHash(); - d.putItem("name", i); qDumpInnerValueOrPointer(d, d.innertype, stripped, addOffset(v, i * innersize + typeddatasize)); d.endHash(); @@ -2860,7 +2867,6 @@ static void qDumpStdList(QDumper &d) it = list.begin(); for (int i = 0; i < 1000 && it != cend; ++i, ++it) { d.beginHash(); - d.putItem("name", i); qDumpInnerValueOrPointer(d, d.innertype, stripped, it.operator->()); d.endHash(); } @@ -2928,7 +2934,6 @@ static void qDumpStdMapHelper(QDumper &d) for (int i = 0; i < 1000 && it != cend; ++i, ++it) { d.beginHash(); const void *node = it.operator->(); - d.putItem("name", i); qDumpInnerValueHelper(d, keyType, node, "key"); qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset)); if (isSimpleKey && isSimpleValue) { @@ -3023,7 +3028,6 @@ static void qDumpStdSetHelper(QDumper &d) for (int i = 0; i < 1000 && it != cend; ++i, ++it) { const void *node = it.operator->(); d.beginHash(); - d.putItem("name", i); qDumpInnerValueOrPointer(d, d.innertype, stripped, node); d.endHash(); } @@ -3127,7 +3131,6 @@ static void qDumpStdVector(QDumper &d) d.beginChildren(n ? d.innertype : 0); for (int i = 0; i != n; ++i) { d.beginHash(); - d.putItem("name", i); qDumpInnerValueOrPointer(d, d.innertype, stripped, addOffset(v->start, i * innersize)); d.endHash(); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index d60877b4dc44ebfa82fc2119312d4e92579e715d..91fffde641a05490828737d9d736b5e54f995027 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -3423,9 +3423,14 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record, setWatchDataChildCount(childtemplate, contents.findChild("childnumchild")); //qDebug() << "DATA:" << data.toString(); insertData(data); + int i = 0; foreach (GdbMi item, children.children()) { WatchData data1 = childtemplate; - data1.name = _(item.findChild("name").data()); + GdbMi name = item.findChild("name"); + if (name.isValid()) + data1.name = _(name.data()); + else + data1.name = QString::number(i); data1.iname = data.iname + _c('.') + data1.name; if (!data1.name.isEmpty() && data1.name.at(0).isDigit()) data1.name = _c('[') + data1.name + _c(']'); @@ -3454,6 +3459,7 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record, data1.setChildrenUnneeded(); //qDebug() << "HANDLE CUSTOM SUBCONTENTS:" << data1.toString(); insertData(data1); + ++i; } } diff --git a/tests/auto/debugger/main.cpp b/tests/auto/debugger/main.cpp index 522583a7047516c0d683e671e0b1964f1f9b6d3d..7e0b947220ef93abe2cd3241fc585072bd43d618 100644 --- a/tests/auto/debugger/main.cpp +++ b/tests/auto/debugger/main.cpp @@ -415,8 +415,8 @@ void tst_Debugger::dumpQList_int() ilist.append(2); testDumper("value='<2 items>',valuedisabled='true',numchild='2'," "internal='1',childtype='int',childnumchild='0',children=[" - "{name='0',addr='" + str(&ilist.at(0)) + "',value='1'}," - "{name='1',addr='" + str(&ilist.at(1)) + "',value='2'}]", + "{addr='" + str(&ilist.at(0)) + "',value='1'}," + "{addr='" + str(&ilist.at(1)) + "',value='2'}]", &ilist, NS"QList", true, "int"); } @@ -430,10 +430,8 @@ void tst_Debugger::dumpQList_char() clist.append('b'); testDumper("value='<2 items>',valuedisabled='true',numchild='2'," "internal='1',childtype='char',childnumchild='0',children=[" - "{name='0',addr='" + str(&clist.at(0)) + "'," - "value=''a', ascii=97',numchild='0'}," - "{name='1',addr='" + str(&clist.at(1)) + "'," - "value=''b', ascii=98',numchild='0'}]", + "{addr='" + str(&clist.at(0)) + "',value=''a', ascii=97'}," + "{addr='" + str(&clist.at(1)) + "',value=''b', ascii=98'}]", &clist, NS"QList", true, "char"); } @@ -447,10 +445,8 @@ void tst_Debugger::dumpQList_QString() slist.append("b"); testDumper("value='<2 items>',valuedisabled='true',numchild='2'," "internal='1',childtype='"NS"QString',childnumchild='0',children=[" - "{name='0',addr='" + str(&slist.at(0)) + "'," - "value='YQA=',valueencoded='2'}," - "{name='1',addr='" + str(&slist.at(1)) + "'," - "value='YgA=',valueencoded='2'}]", + "{addr='" + str(&slist.at(0)) + "',value='YQA=',valueencoded='2'}," + "{addr='" + str(&slist.at(1)) + "',value='YgA=',valueencoded='2'}]", &slist, NS"QList", true, NS"QString"); } @@ -464,8 +460,8 @@ void tst_Debugger::dumpQList_Int3() i3list.append(Int3()); testDumper("value='<2 items>',valuedisabled='true',numchild='2'," "internal='0',childtype='Int3',children=[" - "{name='0',addr='" + str(&i3list.at(0)) + "'}," - "{name='1',addr='" + str(&i3list.at(1)) + "'}]", + "{addr='" + str(&i3list.at(0)) + "'}," + "{addr='" + str(&i3list.at(1)) + "'}]", &i3list, NS"QList", true, "Int3"); } @@ -479,8 +475,8 @@ void tst_Debugger::dumpQList_QString3() s3list.append(QString3()); testDumper("value='<2 items>',valuedisabled='true',numchild='2'," "internal='0',childtype='QString3',children=[" - "{name='0',addr='" + str(&s3list.at(0)) + "'}," - "{name='1',addr='" + str(&s3list.at(1)) + "'}]", + "{addr='" + str(&s3list.at(0)) + "'}," + "{addr='" + str(&s3list.at(1)) + "'}]", &s3list, NS"QList", true, "QString3"); } @@ -597,16 +593,16 @@ void tst_Debugger::dumpStdVector() vector.push_back(new std::list<int>(list)); testDumper("value='<1 items>',valuedisabled='true',numchild='1'," "childtype='" + inner + "',childnumchild='1'," - "children=[{name='0',addr='" + str(deref(&vector[0])) + "'," + "children=[{addr='" + str(deref(&vector[0])) + "'," "saddr='" + str(deref(&vector[0])) + "',type='" + innerp + "'}]", &vector, "std::vector", true, inner, "", sizeof(std::list<int> *)); vector.push_back(0); list.push_back(45); testDumper("value='<2 items>',valuedisabled='true',numchild='2'," "childtype='" + inner + "',childnumchild='1'," - "children=[{name='0',addr='" + str(deref(&vector[0])) + "'," + "children=[{addr='" + str(deref(&vector[0])) + "'," "saddr='" + str(deref(&vector[0])) + "',type='" + innerp + "'}," - "{name='1',addr='" + str(&vector[1]) + "'," + "{addr='" + str(&vector[1]) + "'," "type='" + innerp + "',value='<null>',numchild='0'}]", &vector, "std::vector", true, inner, "", sizeof(std::list<int> *)); vector.push_back(new std::list<int>(list));