diff --git a/src/libs/qtcreatorcdbext/knowntype.h b/src/libs/qtcreatorcdbext/knowntype.h index 8ac8c19d75d8d8ca174d18c24b660ed9eb9427d3..c947dd1c219a5c1ade0ed81a4f540cbb485e5854 100644 --- a/src/libs/qtcreatorcdbext/knowntype.h +++ b/src/libs/qtcreatorcdbext/knowntype.h @@ -79,6 +79,7 @@ enum KnownType KT_QWidget = KT_Qt_Type + KT_HasSimpleDumper + KT_HasComplexDumper + 22, KT_QSharedPointer = KT_Qt_Type + KT_HasSimpleDumper + KT_HasComplexDumper + 23, KT_QRegion = KT_Qt_Type + KT_HasSimpleDumper + KT_HasComplexDumper + 24, + KT_QWeakPointer = KT_Qt_Type + KT_HasSimpleDumper + KT_HasComplexDumper + 25, // Types: Various QT movable types KT_QPen = KT_Qt_Type + KT_Qt_MovableType + 30, KT_QUrl = KT_Qt_Type + KT_Qt_MovableType + 31 + KT_HasSimpleDumper, diff --git a/src/libs/qtcreatorcdbext/symbolgroupnode.h b/src/libs/qtcreatorcdbext/symbolgroupnode.h index 4cfb4523a218a9c43debdfb1017d941ba205a92d..4b7609c2092c50e33dcb5b8d523c6897c8da75ec 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupnode.h +++ b/src/libs/qtcreatorcdbext/symbolgroupnode.h @@ -264,6 +264,7 @@ public: std::wstring symbolGroupFixedValue() const; bool assign(const std::string &value, std::string *errorMessage = 0); + std::wstring simpleDumpValue(const SymbolGroupValueContext &ctx, int *encoding); // A quick check if symbol is valid by checking for inaccessible value bool isMemoryAccessible() const; @@ -306,7 +307,6 @@ private: // Notify about expansion/collapsing of a node, shift indexes bool notifyIndexesMoved(ULONG index, bool inserted, ULONG offset); bool runSimpleDumpers(const SymbolGroupValueContext &ctx); - std::wstring simpleDumpValue(const SymbolGroupValueContext &ctx, int *encoding); ULONG nextSymbolIndex() const; SymbolGroup *const m_symbolGroup; diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp index a0bccf5b9ad642fb3ce43d3d04b859c2fe8f0996..d9a37551355cdb1d4ee0857090f504768fb90731 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp @@ -1177,6 +1177,10 @@ static KnownType knownClassTypeHelper(const std::string &type, if (!type.compare(qPos, 11, "QLinkedList")) return KT_QLinkedList; break; + case 12: + if (!type.compare(qPos, 12, "QWeakPointer")) + return KT_QWeakPointer; + break; case 14: if (!type.compare(qPos, 14, "QSharedPointer")) return KT_QSharedPointer; @@ -2817,28 +2821,47 @@ static bool dumpQVariant(const SymbolGroupValue &v, std::wostream &str, int *enc return true; } -// Dump a qsharedpointer (just list reference counts) -static inline bool dumpQSharedPointer(const SymbolGroupValue &v, std::wostream &str, void **specialInfoIn = 0) +static inline bool dumpQSharedPointer(const SymbolGroupValue &v, std::wostream &str, int *encoding, void **specialInfoIn = 0) { const SymbolGroupValue externalRefCountV = v[unsigned(0)]; - if (!externalRefCountV) - return false; - const SymbolGroupValue dV = externalRefCountV["d"]; - if (!dV) - return false; - // Get value element from base and store in special info. - const SymbolGroupValue valueV = externalRefCountV[unsigned(0)]["value"]; - if (!valueV) - return false; - // Format references. - const int strongRef = dV["strongref"]["_q_value"].intValue(); - const int weakRef = dV["weakref"]["_q_value"].intValue(); - if (strongRef < 0 || weakRef < 0) - return false; - str << L"References: " << strongRef << '/' << weakRef; - if (specialInfoIn) - *specialInfoIn = valueV.node(); - return true; + const QtInfo qtInfo = QtInfo::get(v.context()); + if (qtInfo.version < 5) { + if (!externalRefCountV) + return false; + const SymbolGroupValue dV = externalRefCountV["d"]; + if (!dV) + return false; + // Get value element from base and store in special info. + const SymbolGroupValue valueV = externalRefCountV[unsigned(0)]["value"]; + if (!valueV) + return false; + // Format references. + const int strongRef = dV["strongref"]["_q_value"].intValue(); + const int weakRef = dV["weakref"]["_q_value"].intValue(); + if (strongRef < 0 || weakRef < 0) + return false; + str << L"References: " << strongRef << '/' << weakRef; + if (specialInfoIn) + *specialInfoIn = valueV.node(); + return true; + } else { // Qt 5 + SymbolGroupValue value = v["value"]; + if (value.pointerValue(0) == 0) { + str << L"(null)"; + return true; + } + std::ostringstream namestr; + namestr << "*(" << SymbolGroupValue::stripClassPrefixes(value.type()) << ")(" + << std::showbase << std::hex << value.pointerValue() << ')'; + DebugPrint() << namestr.str().c_str(); + SymbolGroupNode *valueNode + = v.node()->symbolGroup()->addSymbol(v.module(), namestr.str(), std::string(), &std::string()); + if (!valueNode) + return false; + + str << valueNode->simpleDumpValue(v.context(), encoding); + return true; + } } // Dump builtin simple types using SymbolGroupValue expressions. @@ -2992,7 +3015,8 @@ unsigned dumpSimpleType(SymbolGroupNode *n, const SymbolGroupValueContext &ctx, rc = dumpQWindow(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed; break; case KT_QSharedPointer: - rc = dumpQSharedPointer(v, str, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed; + case KT_QWeakPointer: + rc = dumpQSharedPointer(v, str, encoding, specialInfoIn) ? SymbolGroupNode::SimpleDumperOk : SymbolGroupNode::SimpleDumperFailed; break; case KT_StdString: case KT_StdWString: @@ -3416,6 +3440,7 @@ std::vector<AbstractSymbolGroupNode *> SymbolGroupNode *containerNode = reinterpret_cast<SymbolGroupNode *>(specialInfo); rc.push_back(new ReferenceSymbolGroupNode("children", "children", containerNode)); } + case KT_QWeakPointer: case KT_QSharedPointer: // Special info by simple dumper is the value if (specialInfo) { SymbolGroupNode *valueNode = reinterpret_cast<SymbolGroupNode *>(specialInfo);