Debugger[CDB]: Fix CDB not showing QList<const char*>.

as it cannot determine the size of 'char const*' which it
reports as type.

Reviewed-by: hjk
Task-number: QTCREATORBUG-4253
This commit is contained in:
Friedemann Kleint
2011-03-29 09:56:40 +02:00
parent 325424d0d1
commit bfcdd9c700
4 changed files with 34 additions and 3 deletions

View File

@@ -81,7 +81,8 @@ static inline void dump64bitPointerArray(std::ostream &os, const void *a, int co
static inline std::string fixInnerType(std::string type, static inline std::string fixInnerType(std::string type,
const SymbolGroupValue &container) 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); const KnownType kt = knownType(stripped, 0);
// Resolve types unless they are POD or pointers to POD (that is, qualify 'Foo' and 'Foo*') // 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); const bool needResolve = kt == KT_Unknown || kt == KT_PointerType || !(kt & KT_POD_Type);

View File

@@ -1065,9 +1065,11 @@ extern "C" HRESULT CALLBACK test(CIDebugClient *client, PCSTR argsIn)
break; break;
case TestType: { case TestType: {
const KnownType kt = knownType(testType, 0); 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); formatKnownTypeFlags(str, kt);
str << ']'; str << "] size=" << size;
} }
break; break;
case TestFixWatchExpression: case TestFixWatchExpression:

View File

@@ -389,6 +389,31 @@ std::string SymbolGroupValue::stripClassPrefixes(const std::string &type)
return rc; 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) std::string SymbolGroupValue::addPointerType(const std::string &t)
{ {
// 'char' -> 'char *' -> 'char **' // 'char' -> 'char *' -> 'char **'

View File

@@ -105,6 +105,9 @@ public:
static std::string stripPointerType(const std::string &); static std::string stripPointerType(const std::string &);
// Strip "class ", "struct " // Strip "class ", "struct "
static std::string stripClassPrefixes(const std::string &); 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 addPointerType(const std::string &);
static std::string stripArrayType(const std::string &); static std::string stripArrayType(const std::string &);
static std::string stripModuleFromType(const std::string &type); static std::string stripModuleFromType(const std::string &type);