forked from qt-creator/qt-creator
debugger: potential fix for cases where the std:: namespace is not
reported properly
This commit is contained in:
@@ -2396,6 +2396,10 @@ static void handleProtocolVersion2and3(QDumper & d)
|
|||||||
const char *type = stripNamespace(d.outertype);
|
const char *type = stripNamespace(d.outertype);
|
||||||
// type[0] is usally 'Q', so don't use it
|
// type[0] is usally 'Q', so don't use it
|
||||||
switch (type[1]) {
|
switch (type[1]) {
|
||||||
|
case 'a':
|
||||||
|
if (isEqual(type, "map"))
|
||||||
|
qDumpStdMap(d);
|
||||||
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
if (isEqual(type, "QByteArray"))
|
if (isEqual(type, "QByteArray"))
|
||||||
qDumpQByteArray(d);
|
qDumpQByteArray(d);
|
||||||
@@ -2406,6 +2410,12 @@ static void handleProtocolVersion2and3(QDumper & d)
|
|||||||
else if (isEqual(type, "QDir"))
|
else if (isEqual(type, "QDir"))
|
||||||
qDumpQDir(d);
|
qDumpQDir(d);
|
||||||
break;
|
break;
|
||||||
|
case 'e':
|
||||||
|
if (isEqual(type, "vector"))
|
||||||
|
qDumpStdVector(d);
|
||||||
|
else if (isEqual(type, "set"))
|
||||||
|
qDumpStdSet(d);
|
||||||
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
if (isEqual(type, "QFile"))
|
if (isEqual(type, "QFile"))
|
||||||
qDumpQFile(d);
|
qDumpQFile(d);
|
||||||
@@ -2418,6 +2428,10 @@ static void handleProtocolVersion2and3(QDumper & d)
|
|||||||
else if (isEqual(type, "QHashNode"))
|
else if (isEqual(type, "QHashNode"))
|
||||||
qDumpQHashNode(d);
|
qDumpQHashNode(d);
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
if (isEqual(type, "list"))
|
||||||
|
qDumpStdList(d);
|
||||||
|
break;
|
||||||
case 'I':
|
case 'I':
|
||||||
if (isEqual(type, "QImage"))
|
if (isEqual(type, "QImage"))
|
||||||
qDumpQImage(d);
|
qDumpQImage(d);
|
||||||
@@ -2545,18 +2559,18 @@ void qDumpObjectData440(
|
|||||||
"\""NS"QMap\","
|
"\""NS"QMap\","
|
||||||
"\""NS"QMapNode\","
|
"\""NS"QMapNode\","
|
||||||
"\""NS"QModelIndex\","
|
"\""NS"QModelIndex\","
|
||||||
#if QT_VERSION >= 0x040500
|
#if QT_VERSION >= 0x040500
|
||||||
"\""NS"QMultiMap\","
|
"\""NS"QMultiMap\","
|
||||||
#endif
|
#endif
|
||||||
"\""NS"QObject\","
|
"\""NS"QObject\","
|
||||||
"\""NS"QObjectMethodList\"," // hack to get nested properties display
|
"\""NS"QObjectMethodList\"," // hack to get nested properties display
|
||||||
"\""NS"QObjectPropertyList\","
|
"\""NS"QObjectPropertyList\","
|
||||||
#if PRIVATE_OBJECT_ALLOWED
|
#if PRIVATE_OBJECT_ALLOWED
|
||||||
"\""NS"QObjectSignal\","
|
"\""NS"QObjectSignal\","
|
||||||
"\""NS"QObjectSignalList\","
|
"\""NS"QObjectSignalList\","
|
||||||
"\""NS"QObjectSlot\","
|
"\""NS"QObjectSlot\","
|
||||||
"\""NS"QObjectSlotList\","
|
"\""NS"QObjectSlotList\","
|
||||||
#endif // PRIVATE_OBJECT_ALLOWED
|
#endif // PRIVATE_OBJECT_ALLOWED
|
||||||
// << "\""NS"QRegion\","
|
// << "\""NS"QRegion\","
|
||||||
"\""NS"QSet\","
|
"\""NS"QSet\","
|
||||||
"\""NS"QString\","
|
"\""NS"QString\","
|
||||||
@@ -2565,8 +2579,15 @@ void qDumpObjectData440(
|
|||||||
"\""NS"QVariant\","
|
"\""NS"QVariant\","
|
||||||
"\""NS"QVector\","
|
"\""NS"QVector\","
|
||||||
"\""NS"QWidget\","
|
"\""NS"QWidget\","
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
"\"basic_string\","
|
||||||
|
"\"list\","
|
||||||
|
"\"map\","
|
||||||
|
"\"set\","
|
||||||
"\"string\","
|
"\"string\","
|
||||||
|
"\"vector\","
|
||||||
"\"wstring\","
|
"\"wstring\","
|
||||||
|
#endif
|
||||||
"\"std::basic_string\","
|
"\"std::basic_string\","
|
||||||
"\"std::list\","
|
"\"std::list\","
|
||||||
"\"std::map\","
|
"\"std::map\","
|
||||||
|
@@ -3027,7 +3027,7 @@ void GdbEngine::runDebuggingHelper(const WatchData &data0, bool dumpChildren)
|
|||||||
} else if (outertype == m_namespace + "QMapNode") {
|
} else if (outertype == m_namespace + "QMapNode") {
|
||||||
extraArgs[2] = sizeofTypeExpression(data.type);
|
extraArgs[2] = sizeofTypeExpression(data.type);
|
||||||
extraArgs[3] = "(size_t)&(('" + data.type + "'*)0)->value";
|
extraArgs[3] = "(size_t)&(('" + data.type + "'*)0)->value";
|
||||||
} else if (outertype == "std::vector") {
|
} else if (outertype == "std::vector" || outertype == "vector") {
|
||||||
//qDebug() << "EXTRACT TEMPLATE: " << outertype << inners;
|
//qDebug() << "EXTRACT TEMPLATE: " << outertype << inners;
|
||||||
if (inners.at(0) == "bool") {
|
if (inners.at(0) == "bool") {
|
||||||
outertype = "std::vector::bool";
|
outertype = "std::vector::bool";
|
||||||
@@ -3035,18 +3035,18 @@ void GdbEngine::runDebuggingHelper(const WatchData &data0, bool dumpChildren)
|
|||||||
//extraArgs[extraArgCount++] = sizeofTypeExpression(data.type);
|
//extraArgs[extraArgCount++] = sizeofTypeExpression(data.type);
|
||||||
//extraArgs[extraArgCount++] = "(size_t)&(('" + data.type + "'*)0)->value";
|
//extraArgs[extraArgCount++] = "(size_t)&(('" + data.type + "'*)0)->value";
|
||||||
}
|
}
|
||||||
} else if (outertype == "std::deque") {
|
} else if (outertype == "std::deque" || outertype == "deque") {
|
||||||
// remove 'std::allocator<...>':
|
// remove 'std::allocator<...>':
|
||||||
extraArgs[1] = "0";
|
extraArgs[1] = "0";
|
||||||
} else if (outertype == "std::stack") {
|
} else if (outertype == "std::stack" || outertype == "stack") {
|
||||||
// remove 'std::allocator<...>':
|
// remove 'std::allocator<...>':
|
||||||
extraArgs[1] = "0";
|
extraArgs[1] = "0";
|
||||||
} else if (outertype == "std::set") {
|
} else if (outertype == "std::set" || outertype == "set") {
|
||||||
// remove 'std::less<...>':
|
// remove 'std::less<...>':
|
||||||
extraArgs[1] = "0";
|
extraArgs[1] = "0";
|
||||||
// remove 'std::allocator<...>':
|
// remove 'std::allocator<...>':
|
||||||
extraArgs[2] = "0";
|
extraArgs[2] = "0";
|
||||||
} else if (outertype == "std::map") {
|
} else if (outertype == "std::map" || outertype == "map") {
|
||||||
// We don't want the comparator and the allocator confuse gdb.
|
// We don't want the comparator and the allocator confuse gdb.
|
||||||
// But we need the offset of the second item in the value pair.
|
// But we need the offset of the second item in the value pair.
|
||||||
// We read the type of the pair from the allocator argument because
|
// We read the type of the pair from the allocator argument because
|
||||||
@@ -3057,7 +3057,7 @@ void GdbEngine::runDebuggingHelper(const WatchData &data0, bool dumpChildren)
|
|||||||
pairType = pairType.mid(15, pairType.size() - 15 - 2);
|
pairType = pairType.mid(15, pairType.size() - 15 - 2);
|
||||||
extraArgs[2] = "(size_t)&(('" + pairType + "'*)0)->second";
|
extraArgs[2] = "(size_t)&(('" + pairType + "'*)0)->second";
|
||||||
extraArgs[3] = "0";
|
extraArgs[3] = "0";
|
||||||
} else if (outertype == "std::basic_string") {
|
} else if (outertype == "std::basic_string" || outertype == "basic_string") {
|
||||||
//qDebug() << "EXTRACT TEMPLATE: " << outertype << inners;
|
//qDebug() << "EXTRACT TEMPLATE: " << outertype << inners;
|
||||||
if (inners.at(0) == "char") {
|
if (inners.at(0) == "char") {
|
||||||
outertype = "std::string";
|
outertype = "std::string";
|
||||||
|
@@ -356,54 +356,101 @@ WatchHandler::WatchHandler()
|
|||||||
SIGNAL(triggered()), this, SLOT(collapseChildren()));
|
SIGNAL(triggered()), this, SLOT(collapseChildren()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QString chopConst(QString type)
|
||||||
|
{
|
||||||
|
while (1) {
|
||||||
|
if (type.startsWith("const"))
|
||||||
|
type = type.mid(5);
|
||||||
|
else if (type.startsWith(' '))
|
||||||
|
type = type.mid(1);
|
||||||
|
else if (type.endsWith("const"))
|
||||||
|
type.chop(5);
|
||||||
|
else if (type.endsWith(' '))
|
||||||
|
type.chop(1);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
static QString niceType(QString type)
|
static QString niceType(QString type)
|
||||||
{
|
{
|
||||||
if (type.contains(QLatin1String("std::"))) {
|
if (type.contains(QLatin1String("std::"))) {
|
||||||
// std::string
|
// std::string
|
||||||
type.replace(QLatin1String("std::basic_string<char, std::char_traits<char>, "
|
type.replace(QLatin1String("basic_string<char, std::char_traits<char>, "
|
||||||
"std::allocator<char> >"), QLatin1String("std::string"));
|
"std::allocator<char> >"), QLatin1String("string"));
|
||||||
|
|
||||||
// std::wstring
|
// std::wstring
|
||||||
type.replace(QLatin1String("std::basic_string<wchar_t, std::char_traits<wchar_t>, "
|
type.replace(QLatin1String("basic_string<wchar_t, std::char_traits<wchar_t>, "
|
||||||
"std::allocator<wchar_t> >"), QLatin1String("std::wstring"));
|
"std::allocator<wchar_t> >"), QLatin1String("wstring"));
|
||||||
|
|
||||||
// std::vector
|
// std::vector
|
||||||
static QRegExp re1(QLatin1String("std::vector<(.*), std::allocator<(.*)>\\s*>"));
|
static QRegExp re1(QLatin1String("vector<(.*), std::allocator<(.*)>\\s*>"));
|
||||||
re1.setMinimal(true);
|
re1.setMinimal(true);
|
||||||
for (int i = 0; i != 10; ++i) {
|
for (int i = 0; i != 10; ++i) {
|
||||||
if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2))
|
if (re1.indexIn(type) == -1 || re1.cap(1) != re1.cap(2))
|
||||||
break;
|
break;
|
||||||
type.replace(re1.cap(0), QLatin1String("std::vector<") + re1.cap(1) + QLatin1Char('>'));
|
type.replace(re1.cap(0), QLatin1String("vector<") + re1.cap(1) + QLatin1Char('>'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// std::deque
|
||||||
|
static QRegExp re5(QLatin1String("deque<(.*), std::allocator<(.*)>\\s*>"));
|
||||||
|
re5.setMinimal(true);
|
||||||
|
for (int i = 0; i != 10; ++i) {
|
||||||
|
if (re5.indexIn(type) == -1 || re5.cap(1) != re5.cap(2))
|
||||||
|
break;
|
||||||
|
type.replace(re5.cap(0), QLatin1String("deque<") + re5.cap(1) + QLatin1Char('>'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// std::stack
|
||||||
|
static QRegExp re6(QLatin1String("stack<(.*), std::deque<(.*), std::allocator<(.*)>\\s*> >"));
|
||||||
|
re6.setMinimal(true);
|
||||||
|
for (int i = 0; i != 10; ++i) {
|
||||||
|
if (re6.indexIn(type) == -1 || re6.cap(1) != re6.cap(2)
|
||||||
|
|| re6.cap(1) != re6.cap(2))
|
||||||
|
break;
|
||||||
|
type.replace(re6.cap(0), QLatin1String("stack<") + re6.cap(1) + QLatin1Char('>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::list
|
// std::list
|
||||||
static QRegExp re2(QLatin1String("std::list<(.*), std::allocator<(.*)>\\s*>"));
|
static QRegExp re2(QLatin1String("list<(.*), std::allocator<(.*)>\\s*>"));
|
||||||
re2.setMinimal(true);
|
re2.setMinimal(true);
|
||||||
for (int i = 0; i != 10; ++i) {
|
for (int i = 0; i != 10; ++i) {
|
||||||
if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2))
|
if (re2.indexIn(type) == -1 || re2.cap(1) != re2.cap(2))
|
||||||
break;
|
break;
|
||||||
type.replace(re2.cap(0), QLatin1String("std::list<") + re2.cap(1) + QLatin1Char('>'));
|
type.replace(re2.cap(0), QLatin1String("list<") + re2.cap(1) + QLatin1Char('>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::map
|
// std::map
|
||||||
static QRegExp re3(QLatin1String("std::map<(.*), (.*), std::less<(.*)\\s*>, "
|
{
|
||||||
"std::allocator<std::pair<const (.*), (.*)\\s*> > >"));
|
static QRegExp re(QLatin1String("map<(.*), (.*), std::less<(.*)>, "
|
||||||
re3.setMinimal(true);
|
"std::allocator<std::pair<(.*), (.*)> > >"));
|
||||||
for (int i = 0; i != 10; ++i) {
|
re.setMinimal(true);
|
||||||
if (re3.indexIn(type) == -1 || re3.cap(1) != re3.cap(3)
|
for (int i = 0; i != 10; ++i) {
|
||||||
|| re3.cap(1) != re3.cap(4) || re3.cap(2) != re3.cap(5))
|
if (re.indexIn(type) == -1)
|
||||||
break;
|
break;
|
||||||
type.replace(re3.cap(0), QLatin1String("std::map<") + re3.cap(1) + QLatin1String(", ") + re3.cap(2) + QLatin1Char('>'));
|
QString key = chopConst(re.cap(1));
|
||||||
|
QString value = chopConst(re.cap(2));
|
||||||
|
QString key1 = chopConst(re.cap(3));
|
||||||
|
QString key2 = chopConst(re.cap(4));
|
||||||
|
QString value2 = chopConst(re.cap(5));
|
||||||
|
if (value != value2 || key != key1 || key != key2) {
|
||||||
|
qDebug() << key << key1 << key2 << value << value2
|
||||||
|
<< (key == key1) << (key == key2) << (value == value2);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
type.replace(re.cap(0), QString("map<%1, %2>").arg(key).arg(value));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::set
|
// std::set
|
||||||
static QRegExp re4(QLatin1String("std::set<(.*), std::less<(.*)>, std::allocator<(.*)>\\s*>"));
|
static QRegExp re4(QLatin1String("set<(.*), std::less<(.*)>, std::allocator<(.*)>\\s*>"));
|
||||||
re1.setMinimal(true);
|
re1.setMinimal(true);
|
||||||
for (int i = 0; i != 10; ++i) {
|
for (int i = 0; i != 10; ++i) {
|
||||||
if (re4.indexIn(type) == -1 || re4.cap(1) != re4.cap(2)
|
if (re4.indexIn(type) == -1 || re4.cap(1) != re4.cap(2)
|
||||||
|| re4.cap(1) != re4.cap(3))
|
|| re4.cap(1) != re4.cap(3))
|
||||||
break;
|
break;
|
||||||
type.replace(re4.cap(0), QLatin1String("std::set<") + re4.cap(1) + QLatin1Char('>'));
|
type.replace(re4.cap(0), QLatin1String("set<") + re4.cap(1) + QLatin1Char('>'));
|
||||||
}
|
}
|
||||||
|
|
||||||
type.replace(QLatin1String(" >"), QString(QLatin1Char('>')));
|
type.replace(QLatin1String(" >"), QString(QLatin1Char('>')));
|
||||||
|
Reference in New Issue
Block a user