From bf5f14a4e1941965019fc378cd2dc312231940b1 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 12 Sep 2014 13:31:12 +0200 Subject: Debugger: Fix QHash display of "compact" keys Add make std::string usable as "compact" key. Change-Id: Idbfcf9d299e2dde392025166a20c3d0ab60239a6 (cherry picked from commit 2776536a7efd6758de1d6720b2c05a9fe0bc65a5) Reviewed-by: Christian Stenger --- share/qtcreator/debugger/dumper.py | 70 +++++++++++++++++++++------------- share/qtcreator/debugger/gdbbridge.py | 12 +++--- share/qtcreator/debugger/lldbbridge.py | 2 +- share/qtcreator/debugger/pdumper.py | 2 +- share/qtcreator/debugger/qttypes.py | 6 ++- tests/auto/debugger/tst_dumpers.cpp | 6 +-- 6 files changed, 59 insertions(+), 39 deletions(-) diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index c610acb371..3cd1b33f96 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -190,18 +190,6 @@ def showException(msg, exType, exValue, exTraceback): pass -def stripClassTag(typeName): - if typeName.startswith("class "): - return typeName[6:] - if typeName.startswith("struct "): - return typeName[7:] - if typeName.startswith("const "): - return typeName[6:] - if typeName.startswith("volatile "): - return typeName[9:] - return typeName - - class Children: def __init__(self, d, numChild = 1, childType = None, childNumChild = None, maxNumChild = None, addrBase = None, addrStep = None): @@ -215,7 +203,7 @@ class Children: if childType is None: self.childType = None else: - self.childType = stripClassTag(str(childType)) + self.childType = d.stripClassTag(str(childType)) if not self.d.isCli: self.d.put('childtype="%s",' % self.childType) if childNumChild is None: @@ -271,8 +259,11 @@ class PairedChildrenData: self.isCompact = d.isMapCompact(self.keyType, self.valueType) self.childType = valueType if self.isCompact else pairType ns = d.qtNamespace() - self.keyIsQString = str(self.keyType) == ns + "QString" - self.keyIsQByteArray = str(self.keyType) == ns + "QByteArray" + keyTypeName = d.stripClassTag(str(self.keyType)) + self.keyIsQString = keyTypeName == ns + "QString" + self.keyIsQByteArray = keyTypeName == ns + "QByteArray" + self.keyIsStdString = keyTypeName == "std::string" \ + or keyTypeName.startswith("std::basic_string") try: if self.currentType.value: - typeName = stripClassTag(self.currentType.value) + typeName = self.stripClassTag(self.currentType.value) if len(typeName) > 0 and typeName != self.currentChildType: self.put('type="%s",' % typeName) # str(type.unqualified()) ? @@ -583,7 +583,7 @@ class Dumper(DumperBase): arg += a #warn("CALL: %s -> %s(%s)" % (value, func, arg)) - typeName = stripClassTag(str(value.type)) + typeName = self.stripClassTag(str(value.type)) if typeName.find(":") >= 0: typeName = "'" + typeName + "'" # 'class' is needed, see http://sourceware.org/bugzilla/show_bug.cgi?id=11912 @@ -604,7 +604,7 @@ class Dumper(DumperBase): return None def makeValue(self, type, init): - type = "::" + stripClassTag(str(type)); + type = "::" + self.stripClassTag(str(type)); # Avoid malloc symbol clash with QVector. gdb.execute("set $d = (%s*)calloc(sizeof(%s), 1)" % (type, type)) gdb.execute("set *$d = {%s}" % init) @@ -615,7 +615,7 @@ class Dumper(DumperBase): return value def makeExpression(self, value): - type = "::" + stripClassTag(str(value.type)) + type = "::" + self.stripClassTag(str(value.type)) #warn(" TYPE: %s" % type) #exp = "(*(%s*)(&%s))" % (type, value.address) exp = "(*(%s*)(%s))" % (type, value.address) @@ -917,7 +917,7 @@ class Dumper(DumperBase): self.lookupType("unsigned long")), None, -1) def stripNamespaceFromType(self, typeName): - type = stripClassTag(typeName) + type = self.stripClassTag(typeName) ns = self.qtNamespace() if len(ns) > 0 and type.startswith(ns): type = type[len(ns):] @@ -1727,7 +1727,7 @@ class CliDumper(Dumper): self.putValue("") try: if self.currentType.value: - typeName = stripClassTag(self.currentType.value) + typeName = self.stripClassTag(self.currentType.value) self.put('<%s> = {' % typeName) if self.currentValue.value is None: diff --git a/share/qtcreator/debugger/lldbbridge.py b/share/qtcreator/debugger/lldbbridge.py index bb38de3388..73e5b35493 100644 --- a/share/qtcreator/debugger/lldbbridge.py +++ b/share/qtcreator/debugger/lldbbridge.py @@ -882,7 +882,7 @@ class Dumper(DumperBase): return self.target.FindFirstGlobalVariable(symbolName) def stripNamespaceFromType(self, typeName): - #type = stripClassTag(typeName) + #type = self.stripClassTag(typeName) type = typeName ns = self.qtNamespace() if len(ns) > 0 and type.startswith(ns): diff --git a/share/qtcreator/debugger/pdumper.py b/share/qtcreator/debugger/pdumper.py index e0144490ab..32de9c002e 100644 --- a/share/qtcreator/debugger/pdumper.py +++ b/share/qtcreator/debugger/pdumper.py @@ -78,7 +78,7 @@ def qdebug(options = None, def itemFormat(self, item): format = self.formats.get(str(cleanAddress(item.value.address))) if format is None: - format = self.typeformats.get(stripClassTag(str(item.value.type))) + format = self.typeformats.get(self.stripClassTag(str(item.value.type))) return format def dumpFrame(self, frame): diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py index 8333ccfe63..3729fd04b3 100644 --- a/share/qtcreator/debugger/qttypes.py +++ b/share/qtcreator/debugger/qttypes.py @@ -618,6 +618,7 @@ def qdump__QHash(d, value): isCompact = d.isMapCompact(keyType, valueType) childType = valueType if isCompact else innerType with Children(d, size, maxNumChild=1000, childType=childType): + j = 0 for i in d.childRange(): if i == 0: node = hashDataFirstNode(d_ptr, numBuckets) @@ -631,9 +632,10 @@ def qdump__QHash(d, value): # LLDB can't access directly since it's in anonymous union # for Qt4 optimized int keytype key = it[1]["key"] - d.putMapName(key) + d.putMapName(key, j) d.putItem(it["value"]) d.putType(valueType) + j += 1 else: d.putItem(it) @@ -1231,7 +1233,7 @@ def _qdump__QObject(d, value): d.putFields(value) # Parent and children. - if stripClassTag(str(value.type)) == ns + "QObject": + if d.stripClassTag(str(value.type)) == ns + "QObject": d.putSubItem("parent", d_ptr["parent"]) d.putSubItem("children", d_ptr["children"]) diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index 412656a7fc..96737a42b5 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -1658,8 +1658,8 @@ void tst_Dumpers::dumper_data() + Check("h1.2.value.1", "[1]", "2", "int") + Check("h2", "<2 items>", "@QHash") - + Check("h2.22", "[22]", "22", "float") - + Check("h2.11", "[11]", "11", "float") + + Check("h2.0", "[0] 22", "22", "float") + + Check("h2.1", "[1] 11", "11", "float") + Check("h3", "<9 items>", "@QHash<@QString, int>") + Check("h3.0", "[0]", "", "@QHashNode<@QString, int>") @@ -1713,7 +1713,7 @@ void tst_Dumpers::dumper_data() + CheckType("h7.2.value", "@QPointer<@QObject>") + Check("h8", "<3 items>", "Hash") - + Check("h8.11", "[11]", "11", "float") + + Check("h8.0", "[0] 22", "22", "float") + Check("it1.key", "22", "int") + Check("it1.value", "22", "float") + Check("it3.key", "33", "int") -- cgit v1.2.1