forked from qt-creator/qt-creator
debugger: code cosmetics
This commit is contained in:
@@ -489,7 +489,7 @@ bool CdbDumperHelper::initKnownTypes(QString *errorMessage)
|
|||||||
if (callDumper(callCmd, QByteArray(), &outData, false, errorMessage) != CallOk) {
|
if (callDumper(callCmd, QByteArray(), &outData, false, errorMessage) != CallOk) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!m_helper.parseQuery(outData, QtDumperHelper::CdbDebugger)) {
|
if (!m_helper.parseQuery(outData)) {
|
||||||
*errorMessage = QString::fromLatin1("Unable to parse the dumper output: '%1'").arg(QString::fromAscii(output));
|
*errorMessage = QString::fromLatin1("Unable to parse the dumper output: '%1'").arg(QString::fromAscii(output));
|
||||||
}
|
}
|
||||||
if (m_helper.dumperVersion() < dumperVersionRequired) {
|
if (m_helper.dumperVersion() < dumperVersionRequired) {
|
||||||
|
|||||||
@@ -713,7 +713,7 @@ void GdbEngine::handleQueryDebuggingHelperClassic(const GdbResponse &response)
|
|||||||
|
|
||||||
GdbMi contents;
|
GdbMi contents;
|
||||||
QTC_ASSERT(parseConsoleStream(response, &contents), qDebug() << response.toString());
|
QTC_ASSERT(parseConsoleStream(response, &contents), qDebug() << response.toString());
|
||||||
const bool ok = m_dumperHelper.parseQuery(contents, QtDumperHelper::GdbDebugger)
|
const bool ok = m_dumperHelper.parseQuery(contents)
|
||||||
&& m_dumperHelper.typeCount();
|
&& m_dumperHelper.typeCount();
|
||||||
if (ok) {
|
if (ok) {
|
||||||
// Get version and sizes from dumpers. Expression cache
|
// Get version and sizes from dumpers. Expression cache
|
||||||
|
|||||||
@@ -838,7 +838,8 @@ QString QtDumperHelper::toString(bool debug) const
|
|||||||
str << " " << it.key() << ' ' << it.value() << '\n';
|
str << " " << it.key() << ' ' << it.value() << '\n';
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
const QString nameSpace = m_qtNamespace.isEmpty() ? QCoreApplication::translate("QtDumperHelper", "<none>") : m_qtNamespace;
|
const QString nameSpace = m_qtNamespace.isEmpty()
|
||||||
|
? QCoreApplication::translate("QtDumperHelper", "<none>") : m_qtNamespace;
|
||||||
return QCoreApplication::translate("QtDumperHelper",
|
return QCoreApplication::translate("QtDumperHelper",
|
||||||
"%n known types, Qt version: %1, Qt namespace: %2 Dumper version: %3",
|
"%n known types, Qt version: %1, Qt namespace: %2 Dumper version: %3",
|
||||||
0, QCoreApplication::CodecForTr,
|
0, QCoreApplication::CodecForTr,
|
||||||
@@ -866,60 +867,62 @@ int QtDumperHelper::typeCount() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Look up unnamespaced 'std' types.
|
// Look up unnamespaced 'std' types.
|
||||||
static inline QtDumperHelper::Type stdType(const QString &s)
|
static QtDumperHelper::Type stdType(const QByteArray &type)
|
||||||
{
|
{
|
||||||
if (s == QLatin1String("vector"))
|
if (type == "vector")
|
||||||
return QtDumperHelper::StdVectorType;
|
return QtDumperHelper::StdVectorType;
|
||||||
if (s == QLatin1String("deque"))
|
if (type == "deque")
|
||||||
return QtDumperHelper::StdDequeType;
|
return QtDumperHelper::StdDequeType;
|
||||||
if (s == QLatin1String("set"))
|
if (type == "set")
|
||||||
return QtDumperHelper::StdSetType;
|
return QtDumperHelper::StdSetType;
|
||||||
if (s == QLatin1String("stack"))
|
if (type == "stack")
|
||||||
return QtDumperHelper::StdStackType;
|
return QtDumperHelper::StdStackType;
|
||||||
if (s == QLatin1String("map"))
|
if (type == "map")
|
||||||
return QtDumperHelper::StdMapType;
|
return QtDumperHelper::StdMapType;
|
||||||
if (s == QLatin1String("basic_string"))
|
if (type == "basic_string")
|
||||||
return QtDumperHelper::StdStringType;
|
return QtDumperHelper::StdStringType;
|
||||||
return QtDumperHelper::UnknownType;
|
return QtDumperHelper::UnknownType;
|
||||||
}
|
}
|
||||||
|
|
||||||
QtDumperHelper::Type QtDumperHelper::specialType(QString s)
|
static QtDumperHelper::Type specialType(QByteArray type)
|
||||||
{
|
{
|
||||||
// Std classes.
|
// Std classes.
|
||||||
if (s.startsWith(QLatin1String("std::")))
|
if (type.startsWith("std::"))
|
||||||
return stdType(s.mid(5));
|
return stdType(type.mid(5));
|
||||||
|
|
||||||
// Strip namespace
|
// Strip namespace
|
||||||
// FIXME: that's not a good idea as it makes all namespaces equal.
|
// FIXME: that's not a good idea as it makes all namespaces equal.
|
||||||
const int namespaceIndex = s.lastIndexOf(QLatin1String("::"));
|
const int namespaceIndex = type.lastIndexOf("::");
|
||||||
if (namespaceIndex == -1) {
|
if (namespaceIndex == -1) {
|
||||||
// None ... check for std..
|
// None ... check for std..
|
||||||
const Type sType = stdType(s);
|
const QtDumperHelper::Type sType = stdType(type);
|
||||||
if (sType != UnknownType)
|
if (sType != QtDumperHelper::UnknownType)
|
||||||
return sType;
|
return sType;
|
||||||
} else {
|
} else {
|
||||||
s = s.mid(namespaceIndex + 2);
|
type = type.mid(namespaceIndex + 2);
|
||||||
}
|
}
|
||||||
if (s == QLatin1String("QAbstractItem"))
|
|
||||||
return QAbstractItemType;
|
if (type == "QAbstractItem")
|
||||||
if (s == QLatin1String("QMap"))
|
return QtDumperHelper::QAbstractItemType;
|
||||||
return QMapType;
|
if (type == "QMap")
|
||||||
if (s == QLatin1String("QMapNode"))
|
return QtDumperHelper::QMapType;
|
||||||
return QMapNodeType;
|
if (type == "QMapNode")
|
||||||
if (s == QLatin1String("QMultiMap"))
|
return QtDumperHelper::QMapNodeType;
|
||||||
return QMultiMapType;
|
if (type == "QMultiMap")
|
||||||
if (s == QLatin1String("QObject"))
|
return QtDumperHelper::QMultiMapType;
|
||||||
return QObjectType;
|
if (type == "QObject")
|
||||||
if (s == QLatin1String("QObjectSignal"))
|
return QtDumperHelper::QObjectType;
|
||||||
return QObjectSignalType;
|
if (type == "QObjectSignal")
|
||||||
if (s == QLatin1String("QObjectSlot"))
|
return QtDumperHelper::QObjectSignalType;
|
||||||
return QObjectSlotType;
|
if (type == "QObjectSlot")
|
||||||
if (s == QLatin1String("QStack"))
|
return QtDumperHelper::QObjectSlotType;
|
||||||
return QStackType;
|
if (type == "QStack")
|
||||||
if (s == QLatin1String("QVector"))
|
return QtDumperHelper::QStackType;
|
||||||
return QVectorType;
|
if (type == "QVector")
|
||||||
if (s == QLatin1String("QWidget"))
|
return QtDumperHelper::QVectorType;
|
||||||
return QWidgetType;
|
if (type == "QWidget")
|
||||||
return UnknownType;
|
return QtDumperHelper::QWidgetType;
|
||||||
|
return QtDumperHelper::UnknownType;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QtDumperHelper::qtVersionString() const
|
QString QtDumperHelper::qtVersionString() const
|
||||||
@@ -931,15 +934,7 @@ QString QtDumperHelper::qtVersionString() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse a list of types.
|
// Parse a list of types.
|
||||||
void QtDumperHelper::parseQueryTypes(const QStringList &l, Debugger /* debugger */)
|
typedef QList<QByteArray> QByteArrayList;
|
||||||
{
|
|
||||||
m_nameTypeMap.clear();
|
|
||||||
const int count = l.count();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
const Type t = specialType(l.at(i));
|
|
||||||
m_nameTypeMap.insert(l.at(i), t != UnknownType ? t : SupportedType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline QString qClassName(const QString &qtNamespace, const char *className)
|
static inline QString qClassName(const QString &qtNamespace, const char *className)
|
||||||
{
|
{
|
||||||
@@ -976,7 +971,7 @@ static inline double getDumperVersion(const GdbMi &contents)
|
|||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtDumperHelper::parseQuery(const GdbMi &contents, Debugger debugger)
|
bool QtDumperHelper::parseQuery(const GdbMi &contents)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
if (debug > 1)
|
if (debug > 1)
|
||||||
@@ -993,10 +988,17 @@ bool QtDumperHelper::parseQuery(const GdbMi &contents, Debugger debugger)
|
|||||||
}
|
}
|
||||||
m_qtVersion = qtv;
|
m_qtVersion = qtv;
|
||||||
// Get list of helpers
|
// Get list of helpers
|
||||||
QStringList availableSimpleDebuggingHelpers;
|
QByteArrayList availableSimpleDebuggingHelpers;
|
||||||
foreach (const GdbMi &item, contents.findChild("dumpers").children())
|
foreach (const GdbMi &item, contents.findChild("dumpers").children())
|
||||||
availableSimpleDebuggingHelpers.append(QLatin1String(item.data()));
|
availableSimpleDebuggingHelpers.append(item.data());
|
||||||
parseQueryTypes(availableSimpleDebuggingHelpers, debugger);
|
|
||||||
|
// Parse types
|
||||||
|
m_nameTypeMap.clear();
|
||||||
|
foreach (const QByteArray &type, availableSimpleDebuggingHelpers) {
|
||||||
|
const Type t = specialType(type);
|
||||||
|
m_nameTypeMap.insert(type, t != UnknownType ? t : SupportedType);
|
||||||
|
}
|
||||||
|
|
||||||
m_dumperVersion = getDumperVersion(contents);
|
m_dumperVersion = getDumperVersion(contents);
|
||||||
// Parse sizes
|
// Parse sizes
|
||||||
foreach (const GdbMi &sizesList, contents.findChild("sizes").children()) {
|
foreach (const GdbMi &sizesList, contents.findChild("sizes").children()) {
|
||||||
@@ -1016,13 +1018,13 @@ bool QtDumperHelper::parseQuery(const GdbMi &contents, Debugger debugger)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse a query
|
// parse a query
|
||||||
bool QtDumperHelper::parseQuery(const char *data, Debugger debugger)
|
bool QtDumperHelper::parseQuery(const char *data)
|
||||||
{
|
{
|
||||||
GdbMi root;
|
GdbMi root;
|
||||||
root.fromStringMultiple(QByteArray(data));
|
root.fromStringMultiple(QByteArray(data));
|
||||||
if (!root.isValid())
|
if (!root.isValid())
|
||||||
return false;
|
return false;
|
||||||
return parseQuery(root, debugger);
|
return parseQuery(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtDumperHelper::addSize(const QString &name, int size)
|
void QtDumperHelper::addSize(const QString &name, int size)
|
||||||
|
|||||||
@@ -166,8 +166,8 @@ public:
|
|||||||
|
|
||||||
// Complete parse of "query" (protocol 1) response from debuggee buffer.
|
// Complete parse of "query" (protocol 1) response from debuggee buffer.
|
||||||
// 'data' excludes the leading indicator character.
|
// 'data' excludes the leading indicator character.
|
||||||
bool parseQuery(const char *data, Debugger debugger);
|
bool parseQuery(const char *data);
|
||||||
bool parseQuery(const GdbMi &data, Debugger debugger);
|
bool parseQuery(const GdbMi &data);
|
||||||
// Sizes can be added as the debugger determines them
|
// Sizes can be added as the debugger determines them
|
||||||
void addSize(const QString &name, int size);
|
void addSize(const QString &name, int size);
|
||||||
|
|
||||||
@@ -191,14 +191,12 @@ private:
|
|||||||
typedef QMap<QString, int> SizeCache;
|
typedef QMap<QString, int> SizeCache;
|
||||||
|
|
||||||
// Look up a simple (namespace) type
|
// Look up a simple (namespace) type
|
||||||
static Type specialType(QString s);
|
|
||||||
QString evaluationSizeofTypeExpression(const QString &typeName, Debugger d) const;
|
QString evaluationSizeofTypeExpression(const QString &typeName, Debugger d) const;
|
||||||
void parseQueryTypes(const QStringList &l, Debugger debugger);
|
|
||||||
QString qMapNodeValueOffsetExpression(const QString &type,
|
QString qMapNodeValueOffsetExpression(const QString &type,
|
||||||
const QString &addressIn,
|
const QString &addressIn,
|
||||||
Debugger debugger) const;
|
Debugger debugger) const;
|
||||||
|
|
||||||
inline QString lookupCdbDummyAddressExpression(const QString &expr, const QString &address) const;
|
QString lookupCdbDummyAddressExpression(const QString &expr, const QString &address) const;
|
||||||
|
|
||||||
NameTypeMap m_nameTypeMap;
|
NameTypeMap m_nameTypeMap;
|
||||||
SizeCache m_sizeCache;
|
SizeCache m_sizeCache;
|
||||||
|
|||||||
Reference in New Issue
Block a user