Commit b72b4142 authored by hjk's avatar hjk
Browse files

debugger: code cosmetics

parent 0ce788a4
...@@ -166,8 +166,10 @@ bool isPointerType(const QString &type) ...@@ -166,8 +166,10 @@ bool isPointerType(const QString &type)
bool isAccessSpecifier(const QString &str) bool isAccessSpecifier(const QString &str)
{ {
static const QStringList items = static const QStringList items = QStringList()
QStringList() << QLatin1String("private") << QLatin1String("protected") << QLatin1String("public"); << QLatin1String("private")
<< QLatin1String("protected")
<< QLatin1String("public");
return items.contains(str); return items.contains(str);
} }
...@@ -326,28 +328,28 @@ static QString quoteUnprintableLatin1(const QByteArray &ba) ...@@ -326,28 +328,28 @@ static QString quoteUnprintableLatin1(const QByteArray &ba)
return res; return res;
} }
QString decodeData(const QByteArray &baIn, int encoding) QString decodeData(const QByteArray &ba, int encoding)
{ {
switch (encoding) { switch (encoding) {
case 0: // unencoded 8 bit data case 0: // unencoded 8 bit data
return quoteUnprintableLatin1(baIn); return quoteUnprintableLatin1(ba);
case 1: { // base64 encoded 8 bit data, used for QByteArray case 1: { // base64 encoded 8 bit data, used for QByteArray
const QChar doubleQuote(QLatin1Char('"')); const QChar doubleQuote(QLatin1Char('"'));
QString rc = doubleQuote; QString rc = doubleQuote;
rc += quoteUnprintableLatin1(QByteArray::fromBase64(baIn)); rc += quoteUnprintableLatin1(QByteArray::fromBase64(ba));
rc += doubleQuote; rc += doubleQuote;
return rc; return rc;
} }
case 2: { // base64 encoded 16 bit data, used for QString case 2: { // base64 encoded 16 bit data, used for QString
const QChar doubleQuote(QLatin1Char('"')); const QChar doubleQuote(QLatin1Char('"'));
const QByteArray ba = QByteArray::fromBase64(baIn); const QByteArray ba = QByteArray::fromBase64(ba);
QString rc = doubleQuote; QString rc = doubleQuote;
rc += QString::fromUtf16(reinterpret_cast<const ushort *>(ba.data()), ba.size() / 2); rc += QString::fromUtf16(reinterpret_cast<const ushort *>(ba.data()), ba.size() / 2);
rc += doubleQuote; rc += doubleQuote;
return rc; return rc;
} }
case 3: { // base64 encoded 32 bit data case 3: { // base64 encoded 32 bit data
const QByteArray ba = QByteArray::fromBase64(baIn); const QByteArray ba = QByteArray::fromBase64(ba);
const QChar doubleQuote(QLatin1Char('"')); const QChar doubleQuote(QLatin1Char('"'));
QString rc = doubleQuote; QString rc = doubleQuote;
rc += QString::fromUcs4(reinterpret_cast<const uint *>(ba.data()), ba.size() / 4); rc += QString::fromUcs4(reinterpret_cast<const uint *>(ba.data()), ba.size() / 4);
...@@ -355,7 +357,7 @@ QString decodeData(const QByteArray &baIn, int encoding) ...@@ -355,7 +357,7 @@ QString decodeData(const QByteArray &baIn, int encoding)
return rc; return rc;
} }
case 4: { // base64 encoded 16 bit data, without quotes (see 2) case 4: { // base64 encoded 16 bit data, without quotes (see 2)
const QByteArray ba = QByteArray::fromBase64(baIn); const QByteArray ba = QByteArray::fromBase64(ba);
return QString::fromUtf16(reinterpret_cast<const ushort *>(ba.data()), ba.size() / 2); return QString::fromUtf16(reinterpret_cast<const ushort *>(ba.data()), ba.size() / 2);
} }
} }
...@@ -374,7 +376,6 @@ QtDumperResult::QtDumperResult() : ...@@ -374,7 +376,6 @@ QtDumperResult::QtDumperResult() :
valuedisabled(false), valuedisabled(false),
childCount(0), childCount(0),
internal(false) internal(false)
{ {
} }
...@@ -598,7 +599,6 @@ QtDumperHelper::Type QtDumperHelper::specialType(QString s) ...@@ -598,7 +599,6 @@ QtDumperHelper::Type QtDumperHelper::specialType(QString s)
return UnknownType; return UnknownType;
} }
bool QtDumperHelper::needsExpressionSyntax(Type t) bool QtDumperHelper::needsExpressionSyntax(Type t)
{ {
switch (t) { switch (t) {
...@@ -614,7 +614,7 @@ bool QtDumperHelper::needsExpressionSyntax(Type t) ...@@ -614,7 +614,7 @@ bool QtDumperHelper::needsExpressionSyntax(Type t)
return true; return true;
default: default:
break; break;
} }
return false; return false;
} }
...@@ -652,9 +652,8 @@ void QtDumperHelper::parseQueryTypes(const QStringList &l, Debugger debugger) ...@@ -652,9 +652,8 @@ void QtDumperHelper::parseQueryTypes(const QStringList &l, Debugger debugger)
const Type t = specialType(l.at(i)); const Type t = specialType(l.at(i));
if (t != UnknownType) { if (t != UnknownType) {
// Exclude types that require expression syntax for CDB // Exclude types that require expression syntax for CDB
if (debugger == GdbDebugger || !needsExpressionSyntax(t)) { if (debugger == GdbDebugger || !needsExpressionSyntax(t))
m_nameTypeMap.insert(l.at(i), t); m_nameTypeMap.insert(l.at(i), t);
}
} else { } else {
m_nameTypeMap.insert(l.at(i), SupportedType); m_nameTypeMap.insert(l.at(i), SupportedType);
} }
...@@ -668,7 +667,8 @@ void QtDumperHelper::parseQueryTypes(const QStringList &l, Debugger debugger) ...@@ -668,7 +667,8 @@ void QtDumperHelper::parseQueryTypes(const QStringList &l, Debugger debugger)
* value="dABoAHIAZQBlAA==",valueencoded="2"}]" * value="dABoAHIAZQBlAA==",valueencoded="2"}]"
* Default implementation can be used for debugging purposes. */ * Default implementation can be used for debugging purposes. */
class DumperParser { class DumperParser
{
public: public:
explicit DumperParser(const char *s) : m_s(s) {} explicit DumperParser(const char *s) : m_s(s) {}
bool run(); bool run();
...@@ -1182,11 +1182,13 @@ void QtDumperHelper::evaluationParameters(const WatchData &data, ...@@ -1182,11 +1182,13 @@ void QtDumperHelper::evaluationParameters(const WatchData &data,
/* Parse value: /* Parse value:
* "iname="local.sl",addr="0x0012BA84",value="<3 items>",valuedisabled="true", * "iname="local.sl",addr="0x0012BA84",value="<3 items>",valuedisabled="true",
* numchild="3",childtype="QString",childnumchild="0",children=[{name="0",value="<binhex>", * numchild="3",childtype="QString",childnumchild="0",
* valueencoded="2"},{name="1",value="dAB3AG8A",valueencoded="2"},{name="2", * children=[{name="0",value="<binhex>",valueencoded="2"},
* value="dABoAHIAZQBlAA==",valueencoded="2"}]" */ * {name="1",value="dAB3AG8A",valueencoded="2"},
* {name="2",value="dABoAHIAZQBlAA==",valueencoded="2"}]" */
class ValueDumperParser : public DumperParser { class ValueDumperParser : public DumperParser
{
public: public:
explicit ValueDumperParser(const char *s); explicit ValueDumperParser(const char *s);
......
...@@ -114,7 +114,8 @@ QDebug operator<<(QDebug in, const QtDumperResult &d); ...@@ -114,7 +114,8 @@ QDebug operator<<(QDebug in, const QtDumperResult &d);
* 2) Evaluate symbol, taking address and some additional parameters * 2) Evaluate symbol, taking address and some additional parameters
* depending on type. */ * depending on type. */
class QtDumperHelper { class QtDumperHelper
{
public: public:
enum Debugger { enum Debugger {
GdbDebugger, // Can evalulate expressions in function calls GdbDebugger, // Can evalulate expressions in function calls
...@@ -127,7 +128,7 @@ public: ...@@ -127,7 +128,7 @@ public:
// Below types require special handling // Below types require special handling
QObjectType, QWidgetType, QObjectSlotType, QObjectSignalType, QObjectType, QWidgetType, QObjectSlotType, QObjectSignalType,
QVectorType, QMapType, QMultiMapType, QMapNodeType, QVectorType, QMapType, QMultiMapType, QMapNodeType,
StdVectorType, StdDequeType, StdSetType,StdMapType, StdStackType, StdVectorType, StdDequeType, StdSetType, StdMapType, StdStackType,
StdStringType StdStringType
}; };
...@@ -203,6 +204,7 @@ private: ...@@ -203,6 +204,7 @@ private:
}; };
QDebug operator<<(QDebug in, const QtDumperHelper::TypeData &d); QDebug operator<<(QDebug in, const QtDumperHelper::TypeData &d);
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment