Debugger[New CDB]: Fix QMap.

Determine field offset of map node using GetFieldOffset.
Qualify with full module.
This commit is contained in:
Friedemann Kleint
2011-01-04 10:53:53 +01:00
parent 7c5d89ae8a
commit d9ec7dd0a6
3 changed files with 17 additions and 8 deletions

View File

@@ -549,7 +549,8 @@ static inline SymbolGroupValueVector
return SymbolGroupValueVector();
// MSVC2010: "class _Tree : public _Tree_val: public _Tree_nod".
// MSVC2008: Direct class
const bool isMSVC2010 = tree[unsigned(0)][unsigned(0)]["_Mysize"].intValue() == count;
const int size = tree[unsigned(0)][unsigned(0)]["_Mysize"].intValue();
const bool isMSVC2010 = size >= 0 && size <= count; // Count may be limited
if (isMSVC2010In)
*isMSVC2010In = isMSVC2010;
const SymbolGroupValue treeNode = isMSVC2010 ? tree[unsigned(0)][unsigned(0)] : tree;
@@ -904,17 +905,15 @@ static inline AbstractSymbolGroupNodePtrVector
const std::string mapNodeType = qHashNodeType(v, "Node");
const std::string mapPayloadNodeType = qHashNodeType(v, "PayloadNode");
// Calculate the offset needed (see QMap::concrete() used by the iterator).
const unsigned mapNodeSize = SymbolGroupValue::sizeOf(mapPayloadNodeType.c_str());
const unsigned payloadNodeSize = SymbolGroupValue::sizeOf(mapPayloadNodeType.c_str());
const unsigned pointerSize = SymbolGroupValue::pointerSize();
if (debugMap) {
DebugPrint() << v.type() << "," << mapNodeType << ':'
<< mapNodeSize << ',' << mapPayloadNodeType << ':' << payloadNodeSize
<< ", pointerSize=" << pointerSize;
<< mapPayloadNodeType << ':' << payloadNodeSize
<< ", pointerSize=" << SymbolGroupValue::pointerSize();
}
if (!payloadNodeSize || !mapNodeSize)
if (!payloadNodeSize)
return AbstractSymbolGroupNodePtrVector();
const ULONG64 payLoad = payloadNodeSize - pointerSize;
const ULONG64 payLoad = payloadNodeSize - SymbolGroupValue::pointerSize();
// Get the value offset. Manually determine the alignment to be able
// to retrieve key/value without having to deal with QMapNode<> (see below).
// Subtract the 2 trailing pointers of the node.
@@ -922,7 +921,7 @@ static inline AbstractSymbolGroupNodePtrVector
if (innerTypes.size() != 2u)
return AbstractSymbolGroupNodePtrVector();
const unsigned valueSize = SymbolGroupValue::sizeOf(innerTypes.at(1).c_str());
const unsigned valueOffset = mapNodeSize - valueSize - pointerSize;
const unsigned valueOffset = SymbolGroupValue::fieldOffset(mapNodeType.c_str(), "value");
if (debugMap)
DebugPrint() << "Payload=" << payLoad << ",valueOffset=" << valueOffset << ','
<< innerTypes.front() << ',' << innerTypes.back() << ':' << valueSize;

View File

@@ -267,6 +267,14 @@ unsigned SymbolGroupValue::intSize()
return is;
}
unsigned SymbolGroupValue::fieldOffset(const char *type, const char *field)
{
ULONG rc = 0;
if (GetFieldOffset(type, field, &rc))
return 0;
return rc;
}
std::string SymbolGroupValue::stripPointerType(const std::string &t)
{
return isPointerType(t) ? t.substr(0, t.size() - 2) : t;

View File

@@ -98,6 +98,8 @@ public:
// Some helpers for manipulating types.
static inline unsigned sizeOf(const char *type) { return GetTypeSize(type); }
// Offset of structure field: "!moduleQMapNode<K,T>", "value".
static unsigned fieldOffset(const char *type, const char *field);
static std::string stripPointerType(const std::string &);
static std::string addPointerType(const std::string &);
static std::string stripArrayType(const std::string &);