diff --git a/src/libs/qtcreatorcdbext/containers.cpp b/src/libs/qtcreatorcdbext/containers.cpp index 1e9d2147336..ed72cf946b9 100644 --- a/src/libs/qtcreatorcdbext/containers.cpp +++ b/src/libs/qtcreatorcdbext/containers.cpp @@ -81,7 +81,8 @@ static inline void dump64bitPointerArray(std::ostream &os, const void *a, int co static inline std::string fixInnerType(std::string type, const SymbolGroupValue &container) { - const std::string stripped = SymbolGroupValue::stripClassPrefixes(type); + const std::string stripped + = SymbolGroupValue::stripConst(SymbolGroupValue::stripClassPrefixes(type)); const KnownType kt = knownType(stripped, 0); // Resolve types unless they are POD or pointers to POD (that is, qualify 'Foo' and 'Foo*') const bool needResolve = kt == KT_Unknown || kt == KT_PointerType || !(kt & KT_POD_Type); diff --git a/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp b/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp index d0e354dd1a5..35f9e3a5712 100644 --- a/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp +++ b/src/libs/qtcreatorcdbext/qtcreatorcdbextension.cpp @@ -1065,9 +1065,11 @@ extern "C" HRESULT CALLBACK test(CIDebugClient *client, PCSTR argsIn) break; case TestType: { const KnownType kt = knownType(testType, 0); - str << testType << ' ' << kt << " ["; + const std::string fixed = SymbolGroupValue::stripConst(testType); + const unsigned size = SymbolGroupValue::sizeOf(fixed.c_str()); + str << '"' << testType << "\" (" << fixed << ") " << kt << " ["; formatKnownTypeFlags(str, kt); - str << ']'; + str << "] size=" << size; } break; case TestFixWatchExpression: diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp index 4f4e3cfade4..6c8a382d3af 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp +++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.cpp @@ -389,6 +389,31 @@ std::string SymbolGroupValue::stripClassPrefixes(const std::string &type) return rc; } +// Strip " const" from end of type ("XX const", "XX const *[*]" +std::string SymbolGroupValue::stripConst(const std::string &type) +{ + const std::string::size_type constPos = type.rfind(" const"); + if (constPos == std::string::npos) + return type; + // Strip 'const' only if it is at the end 'QString const' + // or of some pointer like 'foo ***' + std::string rc = type; + const std::string::size_type size = rc.size(); + std::string::size_type nextPos = constPos + 6; + if (nextPos == size) { // Ends with - easy. + rc.erase(constPos, nextPos - constPos); + return rc; + } + // Ensure it ends with ' ****'. + if (rc.at(nextPos) != ' ') + return rc; + for (std::string::size_type i = nextPos + 1; i < size; ++i) + if (rc.at(i) != '*') + return rc; + rc.erase(constPos, nextPos - constPos); + return rc; +} + std::string SymbolGroupValue::addPointerType(const std::string &t) { // 'char' -> 'char *' -> 'char **' diff --git a/src/libs/qtcreatorcdbext/symbolgroupvalue.h b/src/libs/qtcreatorcdbext/symbolgroupvalue.h index 6bb7cfbcf50..b9153249da6 100644 --- a/src/libs/qtcreatorcdbext/symbolgroupvalue.h +++ b/src/libs/qtcreatorcdbext/symbolgroupvalue.h @@ -105,6 +105,9 @@ public: static std::string stripPointerType(const std::string &); // Strip "class ", "struct " static std::string stripClassPrefixes(const std::string &); + // Strip " const" from "char const*", (map key), "QString const", etc. + // which otherwise causes GetTypeSize to fail. + static std::string stripConst(const std::string &type); static std::string addPointerType(const std::string &); static std::string stripArrayType(const std::string &); static std::string stripModuleFromType(const std::string &type);