forked from qt-creator/qt-creator
debugger: add display variants for assosiative containers
Change-Id: I8ce5449bf2717e7989e401482f9dbf39fafdd7d0 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -1223,6 +1223,16 @@ class Dumper:
|
|||||||
def putName(self, name):
|
def putName(self, name):
|
||||||
self.put('name="%s",' % name)
|
self.put('name="%s",' % name)
|
||||||
|
|
||||||
|
def putMapName(self, value):
|
||||||
|
if str(value.type) == qqNs + "QString":
|
||||||
|
self.put('key="%s",' % encodeString(value))
|
||||||
|
self.put('keyencoded="%s",' % Hex4EncodedLittleEndian)
|
||||||
|
elif str(value.type) == qqNs + "QByteArray":
|
||||||
|
self.put('key="%s",' % encodeByteArray(value))
|
||||||
|
self.put('keyencoded="%s",' % Hex2EncodedLatin1)
|
||||||
|
else:
|
||||||
|
self.put('name="%s",' % value)
|
||||||
|
|
||||||
def isExpanded(self):
|
def isExpanded(self):
|
||||||
#warn("IS EXPANDED: %s in %s: %s" % (self.currentIName,
|
#warn("IS EXPANDED: %s in %s: %s" % (self.currentIName,
|
||||||
# self.expandedINames, self.currentIName in self.expandedINames))
|
# self.expandedINames, self.currentIName in self.expandedINames))
|
||||||
@@ -1268,7 +1278,12 @@ class Dumper:
|
|||||||
def currentItemFormat(self):
|
def currentItemFormat(self):
|
||||||
format = self.formats.get(self.currentIName)
|
format = self.formats.get(self.currentIName)
|
||||||
if format is None:
|
if format is None:
|
||||||
format = self.typeformats.get(stripClassTag(str(self.currentType)))
|
type = stripClassTag(str(self.currentType))
|
||||||
|
pos = type.find('<')
|
||||||
|
if pos == -1:
|
||||||
|
format = self.typeformats.get(type)
|
||||||
|
else:
|
||||||
|
format = self.typeformats.get(type[0:pos])
|
||||||
return format
|
return format
|
||||||
|
|
||||||
def putSubItem(self, component, value):
|
def putSubItem(self, component, value):
|
||||||
|
@@ -7,6 +7,16 @@
|
|||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
|
|
||||||
|
|
||||||
|
def mapForms():
|
||||||
|
return "Normal,Compact"
|
||||||
|
|
||||||
|
def mapCompact(format, keyType, valueType):
|
||||||
|
if format == 2:
|
||||||
|
return True # Compact.
|
||||||
|
return isSimpleType(keyType) and isSimpleType(valueType)
|
||||||
|
|
||||||
|
|
||||||
def qdump__QAtomicInt(d, value):
|
def qdump__QAtomicInt(d, value):
|
||||||
d.putValue(value["_q_value"])
|
d.putValue(value["_q_value"])
|
||||||
d.putNumChild(0)
|
d.putNumChild(0)
|
||||||
@@ -337,6 +347,9 @@ def qdump__QFlags(d, value):
|
|||||||
d.putNumChild(0)
|
d.putNumChild(0)
|
||||||
|
|
||||||
|
|
||||||
|
def qform__QHash():
|
||||||
|
return mapForms()
|
||||||
|
|
||||||
def qdump__QHash(d, value):
|
def qdump__QHash(d, value):
|
||||||
|
|
||||||
def hashDataFirstNode(value):
|
def hashDataFirstNode(value):
|
||||||
@@ -382,22 +395,19 @@ def qdump__QHash(d, value):
|
|||||||
d.putItemCount(size)
|
d.putItemCount(size)
|
||||||
d.putNumChild(size)
|
d.putNumChild(size)
|
||||||
if d.isExpanded():
|
if d.isExpanded():
|
||||||
isSimpleKey = isSimpleType(keyType)
|
isCompact = mapCompact(d.currentItemFormat(), keyType, valueType)
|
||||||
isSimpleValue = isSimpleType(valueType)
|
|
||||||
node = hashDataFirstNode(value)
|
node = hashDataFirstNode(value)
|
||||||
innerType = e_ptr.dereference().type
|
innerType = e_ptr.dereference().type
|
||||||
childType = innerType
|
childType = innerType
|
||||||
if isSimpleKey and isSimpleValue:
|
if isCompact:
|
||||||
childType = valueType
|
childType = valueType
|
||||||
with Children(d, size, maxNumChild=1000, childType=childType):
|
with Children(d, size, maxNumChild=1000, childType=childType):
|
||||||
for i in d.childRange():
|
for i in d.childRange():
|
||||||
it = node.dereference().cast(innerType)
|
it = node.dereference().cast(innerType)
|
||||||
with SubItem(d, i):
|
with SubItem(d, i):
|
||||||
key = it["key"]
|
if isCompact:
|
||||||
val = it["value"]
|
d.putMapName(it["key"])
|
||||||
if isSimpleKey and isSimpleValue:
|
d.putItem(it["value"])
|
||||||
d.putName(key)
|
|
||||||
d.putItem(val)
|
|
||||||
d.putType(valueType)
|
d.putType(valueType)
|
||||||
else:
|
else:
|
||||||
d.putItem(it)
|
d.putItem(it)
|
||||||
@@ -410,11 +420,11 @@ def qdump__QHashNode(d, value):
|
|||||||
key = value["key"]
|
key = value["key"]
|
||||||
val = value["value"]
|
val = value["value"]
|
||||||
|
|
||||||
if isSimpleType(keyType) and isSimpleType(valueType):
|
#if isSimpleType(keyType) and isSimpleType(valueType):
|
||||||
d.putName(key)
|
# d.putName(key)
|
||||||
d.putValue(val)
|
# d.putValue(val)
|
||||||
else:
|
#else:
|
||||||
d.putValue(" ")
|
d.putValue(" ")
|
||||||
|
|
||||||
d.putNumChild(2)
|
d.putNumChild(2)
|
||||||
if d.isExpanded():
|
if d.isExpanded():
|
||||||
@@ -616,9 +626,7 @@ def qdumpHelper__QMap(d, value, forceLong):
|
|||||||
|
|
||||||
keyType = templateArgument(value.type, 0)
|
keyType = templateArgument(value.type, 0)
|
||||||
valueType = templateArgument(value.type, 1)
|
valueType = templateArgument(value.type, 1)
|
||||||
|
isCompact = mapCompact(d.currentItemFormat(), keyType, valueType)
|
||||||
isSimpleKey = isSimpleType(keyType)
|
|
||||||
isSimpleValue = isSimpleType(valueType)
|
|
||||||
|
|
||||||
it = e_ptr["forward"].dereference()
|
it = e_ptr["forward"].dereference()
|
||||||
|
|
||||||
@@ -629,7 +637,7 @@ def qdumpHelper__QMap(d, value, forceLong):
|
|||||||
payloadSize = nodeType.sizeof - 2 * lookupType("void").pointer().sizeof
|
payloadSize = nodeType.sizeof - 2 * lookupType("void").pointer().sizeof
|
||||||
charPtr = lookupType("char").pointer()
|
charPtr = lookupType("char").pointer()
|
||||||
|
|
||||||
if isSimpleKey and isSimpleValue:
|
if isCompact:
|
||||||
innerType = valueType
|
innerType = valueType
|
||||||
else:
|
else:
|
||||||
innerType = nodeType
|
innerType = nodeType
|
||||||
@@ -640,25 +648,27 @@ def qdumpHelper__QMap(d, value, forceLong):
|
|||||||
base = it.cast(charPtr) - payloadSize
|
base = it.cast(charPtr) - payloadSize
|
||||||
node = base.cast(nodeType.pointer()).dereference()
|
node = base.cast(nodeType.pointer()).dereference()
|
||||||
with SubItem(d, i):
|
with SubItem(d, i):
|
||||||
key = node["key"]
|
if isCompact:
|
||||||
val = node["value"]
|
|
||||||
#if isSimpleType(value.type):
|
|
||||||
# or isStringType(d, value.type):
|
|
||||||
if isSimpleKey and isSimpleValue:
|
|
||||||
#d.putType(valueType)
|
#d.putType(valueType)
|
||||||
if forceLong:
|
if forceLong:
|
||||||
d.putName("[%s] %s" % (i, key))
|
d.putName("[%s] %s" % (i, node["key"]))
|
||||||
else:
|
else:
|
||||||
d.putName(key)
|
d.putMapName(node["key"])
|
||||||
d.putItem(val)
|
d.putItem(node["value"])
|
||||||
else:
|
else:
|
||||||
d.putItem(node)
|
d.putItem(node)
|
||||||
it = it.dereference()["forward"].dereference()
|
it = it.dereference()["forward"].dereference()
|
||||||
|
|
||||||
|
|
||||||
|
def qform__QMap():
|
||||||
|
return mapForms()
|
||||||
|
|
||||||
def qdump__QMap(d, value):
|
def qdump__QMap(d, value):
|
||||||
qdumpHelper__QMap(d, value, False)
|
qdumpHelper__QMap(d, value, False)
|
||||||
|
|
||||||
|
def qform__QMultiMap():
|
||||||
|
return mapForms()
|
||||||
|
|
||||||
def qdump__QMultiMap(d, value):
|
def qdump__QMultiMap(d, value):
|
||||||
qdumpHelper__QMap(d, value, True)
|
qdumpHelper__QMap(d, value, True)
|
||||||
|
|
||||||
@@ -1745,6 +1755,9 @@ def qdump__std__list(d, value):
|
|||||||
p = p["_M_next"]
|
p = p["_M_next"]
|
||||||
|
|
||||||
|
|
||||||
|
def qform__std__map():
|
||||||
|
return mapForms()
|
||||||
|
|
||||||
def qdump__std__map(d, value):
|
def qdump__std__map(d, value):
|
||||||
impl = value["_M_t"]["_M_impl"]
|
impl = value["_M_t"]["_M_impl"]
|
||||||
size = impl["_M_node_count"]
|
size = impl["_M_node_count"]
|
||||||
@@ -1760,10 +1773,9 @@ def qdump__std__map(d, value):
|
|||||||
# pairType = templateArgument(templateArgument(value.type, 3), 0)
|
# pairType = templateArgument(templateArgument(value.type, 3), 0)
|
||||||
# So use this as workaround:
|
# So use this as workaround:
|
||||||
pairType = templateArgument(impl.type, 1)
|
pairType = templateArgument(impl.type, 1)
|
||||||
isSimpleKey = isSimpleType(keyType)
|
isCompact = mapCompact(d.currentItemFormat(), keyType, valueType)
|
||||||
isSimpleValue = isSimpleType(valueType)
|
|
||||||
innerType = pairType
|
innerType = pairType
|
||||||
if isSimpleKey and isSimpleValue:
|
if isCompact:
|
||||||
innerType = valueType
|
innerType = valueType
|
||||||
pairPointer = pairType.pointer()
|
pairPointer = pairType.pointer()
|
||||||
node = impl["_M_header"]["_M_left"]
|
node = impl["_M_header"]["_M_left"]
|
||||||
@@ -1771,15 +1783,15 @@ def qdump__std__map(d, value):
|
|||||||
if size == 0:
|
if size == 0:
|
||||||
childType = pairType
|
childType = pairType
|
||||||
childNumChild = 2
|
childNumChild = 2
|
||||||
if isSimpleKey and isSimpleValue:
|
if isCompact:
|
||||||
childNumChild = None
|
childNumChild = None
|
||||||
with Children(d, size, maxNumChild=1000,
|
with Children(d, size, maxNumChild=1000,
|
||||||
childType=childType, childNumChild=childNumChild):
|
childType=childType, childNumChild=childNumChild):
|
||||||
for i in d.childRange():
|
for i in d.childRange():
|
||||||
with SubItem(d, i):
|
with SubItem(d, i):
|
||||||
pair = (node + 1).cast(pairPointer).dereference()
|
pair = (node + 1).cast(pairPointer).dereference()
|
||||||
if isSimpleKey and isSimpleValue:
|
if isCompact:
|
||||||
d.putName(pair["first"])
|
d.putMapName(pair["first"])
|
||||||
d.putItem(pair["second"])
|
d.putItem(pair["second"])
|
||||||
else:
|
else:
|
||||||
d.putValue(" ")
|
d.putValue(" ")
|
||||||
|
Reference in New Issue
Block a user