diff options
Diffstat (limited to 'share')
-rw-r--r-- | share/qtcreator/debugger/dumper.py | 70 | ||||
-rw-r--r-- | share/qtcreator/debugger/gdbbridge.py | 12 | ||||
-rw-r--r-- | share/qtcreator/debugger/lldbbridge.py | 2 | ||||
-rw-r--r-- | share/qtcreator/debugger/pdumper.py | 2 | ||||
-rw-r--r-- | share/qtcreator/debugger/qttypes.py | 6 |
5 files changed, 56 insertions, 36 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<char") class PairedChildren(Children): def __init__(self, d, numChild, useKeyAndValue = False, @@ -367,12 +358,23 @@ class DumperBase: def putNewline(self): pass + def stripClassTag(self, 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 + def stripForFormat(self, typeName): if typeName in self.cachedFormats: return self.cachedFormats[typeName] stripped = "" inArray = 0 - for c in stripClassTag(typeName): + for c in self.stripClassTag(typeName): if c == '<': break if c == ' ': @@ -503,6 +505,15 @@ class DumperBase: def stringData(self, value): return self.byteArrayDataHelper(self.extractPointer(value)) + def encodeStdString(self, value, limit = 0): + data = value["_M_dataplus"]["_M_p"] + sizePtr = data.cast(self.sizetType().pointer()) + size = int(sizePtr[-3]) + alloc = int(sizePtr[-2]) + self.check(0 <= size and size <= alloc and alloc <= 100*1000*1000) + elided, shown = self.computeLimit(size, limit) + return self.readMemory(data, shown) + def extractTemplateArgument(self, typename, position): level = 0 skipSpace = False @@ -589,24 +600,28 @@ class DumperBase: return False #warn("CHILDREN: %s %s %s" % (numChild, childType, childNumChild)) - def putMapName(self, value, index = -1): + def putMapName(self, value, index = None): ns = self.qtNamespace() - if str(value.type) == ns + "QString": + typeName = self.stripClassTag(str(value.type)) + if typeName == ns + "QString": self.put('key="%s",' % self.encodeString(value)) self.put('keyencoded="%s",' % Hex4EncodedLittleEndian) - elif str(value.type) == ns + "QByteArray": + elif typeName == ns + "QByteArray": self.put('key="%s",' % self.encodeByteArray(value)) self.put('keyencoded="%s",' % Hex2EncodedLatin1) + elif typeName == "std::string": + self.put('key="%s",' % self.encodeStdString(value)) + self.put('keyencoded="%s",' % Hex2EncodedLatin1) else: val = str(value.GetValue()) if self.isLldb else str(value) - if index == -1: - key = 'key="%s",' % val + if index is None: + key = '%s' % val else: - key = 'key="[%d] %s",' % (index, val) + key = '[%s] %s' % (index, val) self.put('key="%s",' % self.hexencode(key)) - self.put('keyencoded="%s",' % Hex2EncodedLatin1) + self.put('keyencoded="%s",' % Hex2EncodedUtf8WithoutQuotes) - def putPair(self, pair, index = -1): + def putPair(self, pair, index = None): if self.pairData.useKeyAndValue: key = pair["key"] value = pair["value"] @@ -620,12 +635,15 @@ class DumperBase: elif self.pairData.keyIsQByteArray: self.put('key="%s",' % self.encodeByteArray(key)) self.put('keyencoded="%s",' % Hex2EncodedLatin1) + elif self.pairData.keyIsStdString: + self.put('key="%s",' % self.encodeStdString(key)) + self.put('keyencoded="%s",' % Hex2EncodedLatin1) else: name = str(key.GetValue()) if self.isLldb else str(key) if index == -1: self.put('name="%s",' % name) else: - self.put('key="[%d] %s",' % (index, name)) + self.put('key="[%s] %s",' % (index, name)) self.putItem(value) else: self.putEmptyValue() @@ -959,7 +977,7 @@ class DumperBase: and innerTypeName != "wchar_t": self.putType(innerTypeName) savedCurrentChildType = self.currentChildType - self.currentChildType = stripClassTag(innerTypeName) + self.currentChildType = self.stripClassTag(innerTypeName) self.putItem(value.dereference()) self.currentChildType = savedCurrentChildType #self.putPointerValue(value) diff --git a/share/qtcreator/debugger/gdbbridge.py b/share/qtcreator/debugger/gdbbridge.py index 4a99983e4a..648d21febd 100644 --- a/share/qtcreator/debugger/gdbbridge.py +++ b/share/qtcreator/debugger/gdbbridge.py @@ -544,7 +544,7 @@ class Dumper(DumperBase): self.putValue("<not accessible>") 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("<not accessible>") 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"]) |