debugger: reduce amount of data produced by the dumpers by removing

predicatable parts.
This commit is contained in:
hjk
2009-07-10 13:40:17 +02:00
parent ef786bf32e
commit 56b24aac36
3 changed files with 20 additions and 31 deletions

View File

@@ -1202,7 +1202,6 @@ static void qDumpQByteArray(QDumper &d)
unsigned char u = (isprint(c) && c != '\'' && c != '"') ? c : '?'; unsigned char u = (isprint(c) && c != '\'' && c != '"') ? c : '?';
sprintf(buf, "%02x (%u '%c')", c, c, u); sprintf(buf, "%02x (%u '%c')", c, c, u);
d.beginHash(); d.beginHash();
d.putItem("name", i);
d.putItem("value", buf); d.putItem("value", buf);
d.endHash(); d.endHash();
} }
@@ -1490,7 +1489,6 @@ static void qDumpQHash(QDumper &d)
d.beginChildren(); d.beginChildren();
while (node != end) { while (node != end) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key"); qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset)); qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
if (isSimpleKey && isSimpleValue) { if (isSimpleKey && isSimpleValue) {
@@ -1632,7 +1630,6 @@ static void qDumpQList(QDumper &d)
d.beginChildren(n ? d.innertype : 0); d.beginChildren(n ? d.innertype : 0);
for (int i = 0; i != n; ++i) { for (int i = 0; i != n; ++i) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
if (innerTypeIsPointer) { if (innerTypeIsPointer) {
void *p = ldata.d->array + i + pdata->begin; void *p = ldata.d->array + i + pdata->begin;
d.putItem("saddr", p); d.putItem("saddr", p);
@@ -1691,7 +1688,6 @@ static void qDumpQLinkedList(QDumper &d)
const void *p = deref(ldata); const void *p = deref(ldata);
for (int i = 0; i != n; ++i) { for (int i = 0; i != n; ++i) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
const void *addr = addOffset(p, 2 * sizeof(void*)); const void *addr = addOffset(p, 2 * sizeof(void*));
qDumpInnerValueOrPointer(d, d.innertype, stripped, addr); qDumpInnerValueOrPointer(d, d.innertype, stripped, addr);
p = deref(p); p = deref(p);
@@ -1837,7 +1833,6 @@ static void qDumpQMap(QDumper &d)
while (node != end) { while (node != end) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key"); qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset)); qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
if (isSimpleKey && isSimpleValue) { if (isSimpleKey && isSimpleValue) {
@@ -2568,7 +2563,6 @@ static void qDumpQObjectChildList(QDumper &d)
d.beginChildren(); d.beginChildren();
for (int i = 0; i != size; ++i) { for (int i = 0; i != size; ++i) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
qDumpInnerValueHelper(d, NS"QObject *", children.at(i)); qDumpInnerValueHelper(d, NS"QObject *", children.at(i));
d.endHash(); d.endHash();
} }
@@ -2616,7 +2610,6 @@ static void qDumpQSet(QDumper &d)
for (int bucket = 0; bucket != hd->numBuckets && i <= 10000; ++bucket) { for (int bucket = 0; bucket != hd->numBuckets && i <= 10000; ++bucket) {
for (node = hd->buckets[bucket]; node->next; node = node->next) { for (node = hd->buckets[bucket]; node->next; node = node->next) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
d.putItem("type", d.innertype); d.putItem("type", d.innertype);
d.beginItem("exp"); d.beginItem("exp");
d.put("(('"NS"QHashNode<").put(d.innertype d.put("(('"NS"QHashNode<").put(d.innertype
@@ -2721,7 +2714,6 @@ static void qDumpQStringList(QDumper &d)
d.beginChildren(n ? NS"QString" : 0); d.beginChildren(n ? NS"QString" : 0);
for (int i = 0; i != n; ++i) { for (int i = 0; i != n; ++i) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
d.putItem("value", list[i]); d.putItem("value", list[i]);
d.putItem("valueencoded", "2"); d.putItem("valueencoded", "2");
d.endHash(); d.endHash();
@@ -2780,7 +2772,6 @@ static void qDumpQVector(QDumper &d)
d.beginChildren(d.innertype); d.beginChildren(d.innertype);
for (int i = 0; i != n; ++i) { for (int i = 0; i != n; ++i) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
qDumpInnerValueOrPointer(d, d.innertype, stripped, qDumpInnerValueOrPointer(d, d.innertype, stripped,
addOffset(v, i * innersize + typeddatasize)); addOffset(v, i * innersize + typeddatasize));
d.endHash(); d.endHash();
@@ -2876,7 +2867,6 @@ static void qDumpStdList(QDumper &d)
it = list.begin(); it = list.begin();
for (int i = 0; i < 1000 && it != cend; ++i, ++it) { for (int i = 0; i < 1000 && it != cend; ++i, ++it) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
qDumpInnerValueOrPointer(d, d.innertype, stripped, it.operator->()); qDumpInnerValueOrPointer(d, d.innertype, stripped, it.operator->());
d.endHash(); d.endHash();
} }
@@ -2944,7 +2934,6 @@ static void qDumpStdMapHelper(QDumper &d)
for (int i = 0; i < 1000 && it != cend; ++i, ++it) { for (int i = 0; i < 1000 && it != cend; ++i, ++it) {
d.beginHash(); d.beginHash();
const void *node = it.operator->(); const void *node = it.operator->();
d.putItem("name", i);
qDumpInnerValueHelper(d, keyType, node, "key"); qDumpInnerValueHelper(d, keyType, node, "key");
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset)); qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
if (isSimpleKey && isSimpleValue) { if (isSimpleKey && isSimpleValue) {
@@ -3039,7 +3028,6 @@ static void qDumpStdSetHelper(QDumper &d)
for (int i = 0; i < 1000 && it != cend; ++i, ++it) { for (int i = 0; i < 1000 && it != cend; ++i, ++it) {
const void *node = it.operator->(); const void *node = it.operator->();
d.beginHash(); d.beginHash();
d.putItem("name", i);
qDumpInnerValueOrPointer(d, d.innertype, stripped, node); qDumpInnerValueOrPointer(d, d.innertype, stripped, node);
d.endHash(); d.endHash();
} }
@@ -3143,7 +3131,6 @@ static void qDumpStdVector(QDumper &d)
d.beginChildren(n ? d.innertype : 0); d.beginChildren(n ? d.innertype : 0);
for (int i = 0; i != n; ++i) { for (int i = 0; i != n; ++i) {
d.beginHash(); d.beginHash();
d.putItem("name", i);
qDumpInnerValueOrPointer(d, d.innertype, stripped, qDumpInnerValueOrPointer(d, d.innertype, stripped,
addOffset(v->start, i * innersize)); addOffset(v->start, i * innersize));
d.endHash(); d.endHash();

View File

@@ -3419,9 +3419,14 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record,
setWatchDataChildCount(childtemplate, contents.findChild("childnumchild")); setWatchDataChildCount(childtemplate, contents.findChild("childnumchild"));
//qDebug() << "DATA:" << data.toString(); //qDebug() << "DATA:" << data.toString();
insertData(data); insertData(data);
int i = 0;
foreach (GdbMi item, children.children()) { foreach (GdbMi item, children.children()) {
WatchData data1 = childtemplate; 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; data1.iname = data.iname + _c('.') + data1.name;
if (!data1.name.isEmpty() && data1.name.at(0).isDigit()) if (!data1.name.isEmpty() && data1.name.at(0).isDigit())
data1.name = _c('[') + data1.name + _c(']'); data1.name = _c('[') + data1.name + _c(']');
@@ -3450,6 +3455,7 @@ void GdbEngine::handleDebuggingHelperValue2(const GdbResultRecord &record,
data1.setChildrenUnneeded(); data1.setChildrenUnneeded();
//qDebug() << "HANDLE CUSTOM SUBCONTENTS:" << data1.toString(); //qDebug() << "HANDLE CUSTOM SUBCONTENTS:" << data1.toString();
insertData(data1); insertData(data1);
++i;
} }
} }

View File

@@ -415,8 +415,8 @@ void tst_Debugger::dumpQList_int()
ilist.append(2); ilist.append(2);
testDumper("value='<2 items>',valuedisabled='true',numchild='2'," testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
"internal='1',childtype='int',childnumchild='0',children=[" "internal='1',childtype='int',childnumchild='0',children=["
"{name='0',addr='" + str(&ilist.at(0)) + "',value='1'}," "{addr='" + str(&ilist.at(0)) + "',value='1'},"
"{name='1',addr='" + str(&ilist.at(1)) + "',value='2'}]", "{addr='" + str(&ilist.at(1)) + "',value='2'}]",
&ilist, NS"QList", true, "int"); &ilist, NS"QList", true, "int");
} }
@@ -430,10 +430,8 @@ void tst_Debugger::dumpQList_char()
clist.append('b'); clist.append('b');
testDumper("value='<2 items>',valuedisabled='true',numchild='2'," testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
"internal='1',childtype='char',childnumchild='0',children=[" "internal='1',childtype='char',childnumchild='0',children=["
"{name='0',addr='" + str(&clist.at(0)) + "'," "{addr='" + str(&clist.at(0)) + "',value=''a', ascii=97'},"
"value=''a', ascii=97'}," "{addr='" + str(&clist.at(1)) + "',value=''b', ascii=98'}]",
"{name='1',addr='" + str(&clist.at(1)) + "',"
"value=''b', ascii=98'}]",
&clist, NS"QList", true, "char"); &clist, NS"QList", true, "char");
} }
@@ -447,10 +445,8 @@ void tst_Debugger::dumpQList_QString()
slist.append("b"); slist.append("b");
testDumper("value='<2 items>',valuedisabled='true',numchild='2'," testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
"internal='1',childtype='"NS"QString',childnumchild='0',children=[" "internal='1',childtype='"NS"QString',childnumchild='0',children=["
"{name='0',addr='" + str(&slist.at(0)) + "'," "{addr='" + str(&slist.at(0)) + "',value='YQA=',valueencoded='2'},"
"value='YQA=',valueencoded='2'}," "{addr='" + str(&slist.at(1)) + "',value='YgA=',valueencoded='2'}]",
"{name='1',addr='" + str(&slist.at(1)) + "',"
"value='YgA=',valueencoded='2'}]",
&slist, NS"QList", true, NS"QString"); &slist, NS"QList", true, NS"QString");
} }
@@ -464,8 +460,8 @@ void tst_Debugger::dumpQList_Int3()
i3list.append(Int3()); i3list.append(Int3());
testDumper("value='<2 items>',valuedisabled='true',numchild='2'," testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
"internal='0',childtype='Int3',children=[" "internal='0',childtype='Int3',children=["
"{name='0',addr='" + str(&i3list.at(0)) + "'}," "{addr='" + str(&i3list.at(0)) + "'},"
"{name='1',addr='" + str(&i3list.at(1)) + "'}]", "{addr='" + str(&i3list.at(1)) + "'}]",
&i3list, NS"QList", true, "Int3"); &i3list, NS"QList", true, "Int3");
} }
@@ -479,8 +475,8 @@ void tst_Debugger::dumpQList_QString3()
s3list.append(QString3()); s3list.append(QString3());
testDumper("value='<2 items>',valuedisabled='true',numchild='2'," testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
"internal='0',childtype='QString3',children=[" "internal='0',childtype='QString3',children=["
"{name='0',addr='" + str(&s3list.at(0)) + "'}," "{addr='" + str(&s3list.at(0)) + "'},"
"{name='1',addr='" + str(&s3list.at(1)) + "'}]", "{addr='" + str(&s3list.at(1)) + "'}]",
&s3list, NS"QList", true, "QString3"); &s3list, NS"QList", true, "QString3");
} }
@@ -597,16 +593,16 @@ void tst_Debugger::dumpStdVector()
vector.push_back(new std::list<int>(list)); vector.push_back(new std::list<int>(list));
testDumper("value='<1 items>',valuedisabled='true',numchild='1'," testDumper("value='<1 items>',valuedisabled='true',numchild='1',"
"childtype='" + inner + "',childnumchild='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 + "'}]", "saddr='" + str(deref(&vector[0])) + "',type='" + innerp + "'}]",
&vector, "std::vector", true, inner, "", sizeof(std::list<int> *)); &vector, "std::vector", true, inner, "", sizeof(std::list<int> *));
vector.push_back(0); vector.push_back(0);
list.push_back(45); list.push_back(45);
testDumper("value='<2 items>',valuedisabled='true',numchild='2'," testDumper("value='<2 items>',valuedisabled='true',numchild='2',"
"childtype='" + inner + "',childnumchild='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 + "'}," "saddr='" + str(deref(&vector[0])) + "',type='" + innerp + "'},"
"{name='1',addr='" + str(&vector[1]) + "'," "{addr='" + str(&vector[1]) + "',"
"type='" + innerp + "',value='<null>',numchild='0'}]", "type='" + innerp + "',value='<null>',numchild='0'}]",
&vector, "std::vector", true, inner, "", sizeof(std::list<int> *)); &vector, "std::vector", true, inner, "", sizeof(std::list<int> *));
vector.push_back(new std::list<int>(list)); vector.push_back(new std::list<int>(list));