forked from qt-creator/qt-creator
Fixes: debugger: work on hash and map dumper with simple keys or
values
This commit is contained in:
@@ -309,11 +309,7 @@ static bool isSimpleType(const char *type)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isShortKey(const char *type)
|
#if 0
|
||||||
{
|
|
||||||
return isSimpleType(type) || isEqual(type, NS"QString");
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isStringType(const char *type)
|
static bool isStringType(const char *type)
|
||||||
{
|
{
|
||||||
return isEqual(type, NS"QString")
|
return isEqual(type, NS"QString")
|
||||||
@@ -322,6 +318,7 @@ static bool isStringType(const char *type)
|
|||||||
|| isEqual(type, "std::wstring")
|
|| isEqual(type, "std::wstring")
|
||||||
|| isEqual(type, "wstring");
|
|| isEqual(type, "wstring");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool isMovableType(const char *type)
|
static bool isMovableType(const char *type)
|
||||||
{
|
{
|
||||||
@@ -1098,16 +1095,14 @@ static void qDumpQHash(QDumper &d)
|
|||||||
if (n > 1000)
|
if (n > 1000)
|
||||||
n = 1000;
|
n = 1000;
|
||||||
bool isSimpleKey = isSimpleType(keyType);
|
bool isSimpleKey = isSimpleType(keyType);
|
||||||
bool isStringKey = isStringType(keyType);
|
|
||||||
bool isSimpleValue = isSimpleType(valueType);
|
bool isSimpleValue = isSimpleType(valueType);
|
||||||
bool opt = isOptimizedIntKey(keyType);
|
bool opt = isOptimizedIntKey(keyType);
|
||||||
int keyOffset = hashOffset(opt, true, keySize, valueSize);
|
int keyOffset = hashOffset(opt, true, keySize, valueSize);
|
||||||
int valueOffset = hashOffset(opt, false, keySize, valueSize);
|
int valueOffset = hashOffset(opt, false, keySize, valueSize);
|
||||||
|
|
||||||
P(d, "extra", "isSimpleKey: " << isSimpleKey
|
P(d, "extra", "isSimpleKey: " << isSimpleKey
|
||||||
<< " isStringKey: " << isStringKey
|
|
||||||
<< " isSimpleValue: " << isSimpleValue
|
<< " isSimpleValue: " << isSimpleValue
|
||||||
<< " valueType: '" << valueType << "'"
|
<< " valueType: '" << isSimpleValue
|
||||||
<< " keySize: " << keyOffset << " valueOffset: " << valueOffset
|
<< " keySize: " << keyOffset << " valueOffset: " << valueOffset
|
||||||
<< " opt: " << opt);
|
<< " opt: " << opt);
|
||||||
|
|
||||||
@@ -1145,15 +1140,18 @@ static void qDumpQHashNode(QDumper &d)
|
|||||||
const char *keyType = d.templateParameters[0];
|
const char *keyType = d.templateParameters[0];
|
||||||
const char *valueType = d.templateParameters[1];
|
const char *valueType = d.templateParameters[1];
|
||||||
|
|
||||||
P(d, "value", "");
|
|
||||||
P(d, "numchild", 2);
|
|
||||||
if (d.dumpChildren) {
|
|
||||||
unsigned keySize = d.extraInt[0];
|
unsigned keySize = d.extraInt[0];
|
||||||
unsigned valueSize = d.extraInt[1];
|
unsigned valueSize = d.extraInt[1];
|
||||||
bool opt = isOptimizedIntKey(keyType);
|
bool opt = isOptimizedIntKey(keyType);
|
||||||
int keyOffset = hashOffset(opt, true, keySize, valueSize);
|
int keyOffset = hashOffset(opt, true, keySize, valueSize);
|
||||||
int valueOffset = hashOffset(opt, false, keySize, valueSize);
|
int valueOffset = hashOffset(opt, false, keySize, valueSize);
|
||||||
|
if (isSimpleType(valueType))
|
||||||
|
qDumpInnerValueHelper(d, valueType, addOffset(h, valueOffset));
|
||||||
|
else
|
||||||
|
P(d, "value", "");
|
||||||
|
|
||||||
|
P(d, "numchild", 2);
|
||||||
|
if (d.dumpChildren) {
|
||||||
// there is a hash specialization in cast the key are integers or shorts
|
// there is a hash specialization in cast the key are integers or shorts
|
||||||
d << ",children=[";
|
d << ",children=[";
|
||||||
d.beginHash();
|
d.beginHash();
|
||||||
@@ -1411,8 +1409,8 @@ static void qDumpQMap(QDumper &d)
|
|||||||
unsigned mapnodesize = d.extraInt[2];
|
unsigned mapnodesize = d.extraInt[2];
|
||||||
unsigned valueOff = d.extraInt[3];
|
unsigned valueOff = d.extraInt[3];
|
||||||
|
|
||||||
bool isSimpleKey = isShortKey(keyType);
|
bool isSimpleKey = isSimpleType(keyType);
|
||||||
bool isSimpleValue = isShortKey(valueType);
|
bool isSimpleValue = isSimpleType(valueType);
|
||||||
// both negative:
|
// both negative:
|
||||||
int keyOffset = 2 * sizeof(void*) - int(mapnodesize);
|
int keyOffset = 2 * sizeof(void*) - int(mapnodesize);
|
||||||
int valueOffset = 2 * sizeof(void*) - int(mapnodesize) + valueOff;
|
int valueOffset = 2 * sizeof(void*) - int(mapnodesize) + valueOff;
|
||||||
@@ -1429,12 +1427,9 @@ static void qDumpQMap(QDumper &d)
|
|||||||
while (node != end) {
|
while (node != end) {
|
||||||
d.beginHash();
|
d.beginHash();
|
||||||
P(d, "name", i);
|
P(d, "name", i);
|
||||||
if (isSimpleKey) {
|
|
||||||
P(d, "type", valueType);
|
|
||||||
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
|
qDumpInnerValueHelper(d, keyType, addOffset(node, keyOffset), "key");
|
||||||
if (isSimpleValue)
|
|
||||||
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
|
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
|
||||||
|
if (isSimpleKey && isSimpleValue) {
|
||||||
P(d, "type", valueType);
|
P(d, "type", valueType);
|
||||||
P(d, "addr", addOffset(node, valueOffset));
|
P(d, "addr", addOffset(node, valueOffset));
|
||||||
} else {
|
} else {
|
||||||
@@ -2208,39 +2203,36 @@ static void qDumpStdMap(QDumper &d)
|
|||||||
// (#4, "std::allocator<std::pair<key, value> >")
|
// (#4, "std::allocator<std::pair<key, value> >")
|
||||||
// as it is there, and, equally importantly, in an order that
|
// as it is there, and, equally importantly, in an order that
|
||||||
// gdb accepts when fed with it.
|
// gdb accepts when fed with it.
|
||||||
char *pairType = (char *)(d.templateParameters[3]) + 16;
|
char *pairType = (char *)(d.templateParameters[3]) + 15;
|
||||||
pairType[strlen(pairType) - 2] = 0;
|
pairType[strlen(pairType) - 2] = 0;
|
||||||
P(d, "pairtype", pairType);
|
P(d, "pairtype", pairType);
|
||||||
|
|
||||||
if (d.dumpChildren) {
|
if (d.dumpChildren) {
|
||||||
bool isSimpleKey = isSimpleType(keyType);
|
bool isSimpleKey = isSimpleType(keyType);
|
||||||
bool isStringKey = isStringType(keyType);
|
bool isSimpleValue = isSimpleType(valueType);
|
||||||
bool isSimpleValue = isShortKey(valueType);
|
|
||||||
int valueOffset = d.extraInt[2];
|
int valueOffset = d.extraInt[2];
|
||||||
|
|
||||||
|
P(d, "extra", "isSimpleKey: " << isSimpleKey
|
||||||
|
<< " isSimpleValue: " << isSimpleValue
|
||||||
|
<< " valueType: '" << valueType
|
||||||
|
<< " valueOffset: " << valueOffset);
|
||||||
|
|
||||||
d << ",children=[";
|
d << ",children=[";
|
||||||
it = map.begin();
|
it = map.begin();
|
||||||
for (int i = 0; i < 1000 && it != map.end(); ++i, ++it) {
|
for (int i = 0; i < 1000 && it != map.end(); ++i, ++it) {
|
||||||
|
d.beginHash();
|
||||||
const void *node = it.operator->();
|
const void *node = it.operator->();
|
||||||
if (isSimpleKey) {
|
|
||||||
d.beginHash();
|
|
||||||
P(d, "type", valueType);
|
|
||||||
P(d, "name", i);
|
P(d, "name", i);
|
||||||
qDumpInnerValueHelper(d, keyType, node, "key");
|
qDumpInnerValueHelper(d, keyType, node, "key");
|
||||||
P(d, "nameisindex", "1");
|
|
||||||
if (isSimpleValue)
|
|
||||||
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
|
qDumpInnerValueHelper(d, valueType, addOffset(node, valueOffset));
|
||||||
|
if (isSimpleKey && isSimpleValue) {
|
||||||
|
P(d, "type", valueType);
|
||||||
P(d, "addr", addOffset(node, valueOffset));
|
P(d, "addr", addOffset(node, valueOffset));
|
||||||
d.endHash();
|
|
||||||
} else {
|
} else {
|
||||||
d.beginHash();
|
P(d, "addr", node);
|
||||||
P(d, "name", i);
|
|
||||||
if (isStringKey)
|
|
||||||
qDumpInnerValueHelper(d, keyType, node, "key");
|
|
||||||
P(d, "addr", it.operator->());
|
|
||||||
P(d, "type", pairType);
|
P(d, "type", pairType);
|
||||||
d.endHash();
|
|
||||||
}
|
}
|
||||||
|
d.endHash();
|
||||||
}
|
}
|
||||||
if (it != map.end())
|
if (it != map.end())
|
||||||
d.putEllipsis();
|
d.putEllipsis();
|
||||||
|
|||||||
@@ -2854,7 +2854,7 @@ static bool extractTemplate(const QString &type, QString *tmplate, QString *inne
|
|||||||
*tmplate = tmplate->trimmed();
|
*tmplate = tmplate->trimmed();
|
||||||
*tmplate = tmplate->remove("<>");
|
*tmplate = tmplate->remove("<>");
|
||||||
*inner = inner->trimmed();
|
*inner = inner->trimmed();
|
||||||
//qDebug() << "EXTRACT TEMPLATE: " << *tmplate << *inner;
|
//qDebug() << "EXTRACT TEMPLATE: " << *tmplate << *inner << " FROM " << type;
|
||||||
return !inner->isEmpty();
|
return !inner->isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user