diff options
Diffstat (limited to 'share/qtcreator/debugger/dumper.py')
-rw-r--r-- | share/qtcreator/debugger/dumper.py | 145 |
1 files changed, 82 insertions, 63 deletions
diff --git a/share/qtcreator/debugger/dumper.py b/share/qtcreator/debugger/dumper.py index 2b0ad8de5c..e66900c1ef 100644 --- a/share/qtcreator/debugger/dumper.py +++ b/share/qtcreator/debugger/dumper.py @@ -126,7 +126,7 @@ class Children(): self.d.currentNumChild = self.savedNumChild self.d.currentMaxNumChild = self.savedMaxNumChild if self.d.isCli: - self.output += '\n' + ' ' * self.indent + self.d.output += '\n' + ' ' * self.d.indent self.d.put(self.d.childrenSuffix) return True @@ -288,6 +288,7 @@ class DumperBase(): self.counts = {} self.structPatternCache = {} self.timings = [] + self.expandableINames = set({}) def resetStats(self): # Timing collection @@ -739,7 +740,6 @@ class DumperBase(): with SubItem(self, name): self.putValue('0x%x' % value) self.putType('void*') - self.putNumChild(0) def putIntItem(self, name, value): with SubItem(self, name): @@ -748,7 +748,6 @@ class DumperBase(): else: self.putValue(value) self.putType('int') - self.putNumChild(0) def putEnumItem(self, name, ival, typish): buf = bytearray(struct.pack('i', ival)) @@ -762,7 +761,6 @@ class DumperBase(): with SubItem(self, name): self.putValue(value) self.putType('bool') - self.putNumChild(0) def putPairItem(self, index, pair, keyName='first', valueName='second'): with SubItem(self, index): @@ -773,18 +771,20 @@ class DumperBase(): first, second = pair if isinstance(pair, tuple) else pair.members(False) key = self.putSubItem(kname, first) value = self.putSubItem(vname, second) - if index is not None: - self.putField('keyprefix', '[%s] ' % index) - self.putField('key', key.value) - if key.encoding is not None: - self.putField('keyencoded', key.encoding) - self.putValue(value.value, value.encoding) + if self.isCli: + self.putEmptyValue() + else: + if index is not None: + self.putField('keyprefix', '[%s] ' % index) + self.putField('key', key.value) + if key.encoding is not None: + self.putField('keyencoded', key.encoding) + self.putValue(value.value, value.encoding) def putEnumValue(self, ival, vals): nice = vals.get(ival, None) display = ('%d' % ival) if nice is None else ('%s (%d)' % (nice, ival)) self.putValue(display) - self.putNumChild(0) def putCallItem(self, name, rettype, value, func, *args): with SubItem(self, name): @@ -806,15 +806,15 @@ class DumperBase(): self.put('address="0x%x",' % address) def putPlainChildren(self, value, dumpBase=True): - self.putEmptyValue(-99) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): + self.putEmptyValue(-99) with Children(self): self.putFields(value, dumpBase) def putNamedChildren(self, values, names): self.putEmptyValue(-99) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): for n, v in zip(names, values): @@ -846,7 +846,7 @@ class DumperBase(): with SubItem(self, '[vptr]'): # int (**)(void) self.putType(' ') - self.putField('sortgroup', 20) + self.putSortGroup(20) self.putValue(item.name) n = 100 if self.isExpanded(): @@ -862,17 +862,24 @@ class DumperBase(): with UnnamedSubItem(self, "@%d" % baseIndex): self.putField('iname', self.currentIName) self.putField('name', '[%s]' % item.name) - self.putField('sortgroup', 1000 - baseIndex) - self.putAddress(item.address()) + if not self.isCli: + self.putSortGroup(1000 - baseIndex) + self.putAddress(item.address()) self.putItem(item) continue with SubItem(self, item.name): self.putItem(item) + def putExpandable(self): + self.putNumChild(1) + self.expandableINames.add(self.currentIName) + if self.isCli: + self.putValue('{...}', -99) + def putMembersItem(self, value, sortorder=10): with SubItem(self, '[members]'): - self.putField('sortgroup', sortorder) + self.putSortGroup(sortorder) self.putPlainChildren(value) def put(self, stuff): @@ -1044,7 +1051,7 @@ class DumperBase(): def putSpecialValue(self, encoding, value='', children=None): self.putValue(value, encoding) if children is not None: - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): for name, value in children: @@ -1310,7 +1317,6 @@ class DumperBase(): #DumperBase.warn('NULL POINTER') self.putType(value.type) self.putValue('0x0') - self.putNumChild(0) return typeName = value.type.name @@ -1323,7 +1329,6 @@ class DumperBase(): #DumperBase.warn('BAD POINTER: %s' % value) self.putValue('0x%x' % pointer) self.putType(typeName) - self.putNumChild(0) return if self.currentIName.endswith('.this'): @@ -1331,13 +1336,15 @@ class DumperBase(): return displayFormat = self.currentItemFormat(value.type.name) + innerType = value.type.target() # .unqualified() + if innerType.code == TypeCode.Typedef: + innerType = innerType.ltarget if innerType.name == 'void': #DumperBase.warn('VOID POINTER: %s' % displayFormat) self.putType(typeName) self.putSymbolValue(pointer) - self.putNumChild(0) return if displayFormat == DisplayFormat.Raw: @@ -1345,7 +1352,7 @@ class DumperBase(): #DumperBase.warn('RAW') self.putType(typeName) self.putValue('0x%x' % pointer) - self.putNumChild(1) + self.putExpandable() if self.currentIName in self.expandedINames: with Children(self): with SubItem(self, '*'): @@ -1357,7 +1364,7 @@ class DumperBase(): limit = 1000000 if self.tryPutSimpleFormattedPointer(pointer, typeName, innerType, displayFormat, limit): - self.putNumChild(1) + self.putExpandable() return if DisplayFormat.Array10 <= displayFormat and displayFormat <= DisplayFormat.Array1000: @@ -1371,7 +1378,6 @@ class DumperBase(): # A function pointer. self.putSymbolValue(pointer) self.putType(typeName) - self.putNumChild(0) return #DumperBase.warn('AUTODEREF: %s' % self.autoDerefPointers) @@ -1394,7 +1400,7 @@ class DumperBase(): #DumperBase.warn('ADDR PLAIN POINTER: 0x%x' % value.laddress) self.putType(typeName) self.putSymbolValue(pointer) - self.putNumChild(1) + self.putExpandable() if self.currentIName in self.expandedINames: with Children(self): with SubItem(self, '*'): @@ -1543,6 +1549,7 @@ class DumperBase(): return True # If the object is defined in another module there may be another level of indirection customEventFunc = getJumpAddress_x86(self, customEventFunc) + return customEventFunc in (self.qtCustomEventFunc, self.qtCustomEventPltFunc) # def extractQObjectProperty(objectPtr): @@ -1719,13 +1726,12 @@ class DumperBase(): typeObj = self.lookupType(typeName) if typeObj: self.putType(typeObj) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): self.putFields(self.createValue(addr, typeObj)) else: self.putType(typeName) - self.putNumChild(0) # This is called is when a QObject derived class is expanded def tryPutQObjectGuts(self, value): @@ -1750,6 +1756,10 @@ class DumperBase(): ldata = stringdata + index return self.extractCString(ldata).decode('utf8') + def putSortGroup(self, sortorder): + if not self.isCli: + self.putField('sortgroup', sortorder) + def putQMetaStuff(self, value, origType): (metaObjectPtr, handle) = value.split('pI') if metaObjectPtr != 0: @@ -1758,7 +1768,7 @@ class DumperBase(): revision = 7 if self.qtVersion() >= 0x050000 else 6 name = self.metaString(metaObjectPtr, index, revision) self.putValue(name) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): self.putFields(value) @@ -1783,7 +1793,6 @@ class DumperBase(): with SubItem(self, name): self.putValue(value) self.putType(typeName) - self.putNumChild(0) def extractSuperDataPtr(someMetaObjectPtr): #return someMetaObjectPtr['d']['superdata'] @@ -1833,15 +1842,16 @@ class DumperBase(): if qobjectPtr: qobjectType = self.createType('QObject') with SubItem(self, '[parent]'): - self.putField('sortgroup', 9) + if not self.isCli: + self.putSortGroup(9) if parentPtr: self.putItem(self.createValue(parentPtr, qobjectType)) else: self.putValue('0x0') self.putType('QObject *') - self.putNumChild(0) with SubItem(self, '[children]'): - self.putField('sortgroup', 8) + if not self.isCli: + self.putSortGroup(8) base = self.extractPointer(dd + 3 * ptrSize) # It's a QList<QObject *> begin = self.extractInt(base + 8) end = self.extractInt(base + 12) @@ -1852,6 +1862,8 @@ class DumperBase(): size = end - begin self.check(size >= 0) self.putItemCount(size) + if size > 0: + self.putExpandable() if self.isExpanded(): addrBase = array + begin * ptrSize with Children(self, size): @@ -1862,26 +1874,25 @@ class DumperBase(): if isQMetaObject: with SubItem(self, '[strings]'): - self.putField('sortgroup', 2) + if not self.isCli: + self.putSortGroup(2) if largestStringIndex > 0: self.putSpecialValue('minimumitemcount', largestStringIndex) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self, largestStringIndex + 1): for i in self.childRange(): with SubItem(self, i): s = self.metaString(metaObjectPtr, i, revision) self.putValue(self.hexencode(s), 'latin1') - self.putNumChild(0) else: self.putValue(' ') - self.putNumChild(0) if isQMetaObject: with SubItem(self, '[raw]'): - self.putField('sortgroup', 1) + self.putSortGroup(1) self.putEmptyValue() - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): putt('revision', revision) @@ -1899,9 +1910,9 @@ class DumperBase(): if isQObject: with SubItem(self, '[extra]'): - self.putField('sortgroup', 1) + self.putSortGroup(1) self.putEmptyValue() - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): if extraData: @@ -1910,7 +1921,7 @@ class DumperBase(): with SubItem(self, '[metaObject]'): self.putAddress(metaObjectPtr) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): self.putQObjectGutsHelper( @@ -1941,7 +1952,7 @@ class DumperBase(): metaObjectPtr, t[0], revision) self.putType(' ') self.putValue(name) - self.putNumChild(1) + self.putExpandable() with Children(self): putt('[nameindex]', t[0]) #putt('[type]', 'signal') @@ -1955,7 +1966,7 @@ class DumperBase(): if isQMetaObject or isQObject: with SubItem(self, '[properties]'): - self.putField('sortgroup', 5) + self.putSortGroup(5) if self.isExpanded(): dynamicPropertyCount = 0 with Children(self): @@ -2005,8 +2016,9 @@ class DumperBase(): extraData + ptrSize, byteArrayType) for (k, v) in zip(names, values): with SubItem(self, propertyCount + dynamicPropertyCount): - self.putField('key', self.encodeByteArray(k)) - self.putField('keyencoded', 'latin1') + if not self.isCli: + self.putField('key', self.encodeByteArray(k)) + self.putField('keyencoded', 'latin1') self.putItem(v) dynamicPropertyCount += 1 self.putItemCount(propertyCount + dynamicPropertyCount) @@ -2015,7 +2027,7 @@ class DumperBase(): # before we know whether there are actual children. Counting # them is too expensive. self.putSpecialValue('minimumitemcount', propertyCount) - self.putNumChild(1) + self.putExpandable() superDataPtr = extractSuperDataPtr(metaObjectPtr) @@ -2028,7 +2040,7 @@ class DumperBase(): if isQMetaObject or isQObject: with SubItem(self, '[methods]'): - self.putField('sortgroup', 3) + self.putSortGroup(3) self.putItemCount(methodCount) if self.isExpanded(): with Children(self): @@ -2063,30 +2075,29 @@ class DumperBase(): if isQObject: with SubItem(self, '[d]'): self.putItem(self.createValue(dd, '@QObjectPrivate')) - self.putField('sortgroup', 15) + self.putSortGroup(15) if isQMetaObject: with SubItem(self, '[superdata]'): - self.putField('sortgroup', 12) + self.putSortGroup(12) if superDataPtr: self.putType('@QMetaObject') self.putAddress(superDataPtr) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): with Children(self): self.putQObjectGutsHelper(0, 0, -1, superDataPtr, 'QMetaObject') else: self.putType('@QMetaObject *') self.putValue('0x0') - self.putNumChild(0) if handle >= 0: localIndex = int((handle - methods) / 5) with SubItem(self, '[localindex]'): - self.putField('sortgroup', 12) + self.putSortGroup(12) self.putValue(localIndex) with SubItem(self, '[globalindex]'): - self.putField('sortgroup', 11) + self.putSortGroup(11) self.putValue(globalOffset + localIndex) def putQObjectConnections(self, dd): @@ -2102,7 +2113,7 @@ class DumperBase(): connections = connections.dereference() #connections = connections.cast(connections.type.firstBase()) self.putSpecialValue('minimumitemcount', 0) - self.putNumChild(1) + self.putExpandable() if self.isExpanded(): pp = 0 with Children(self): @@ -2770,7 +2781,6 @@ class DumperBase(): return #DumperBase.warn('SOME VALUE: %s' % value) - #DumperBase.warn('HAS CHILDREN VALUE: %s' % value.hasChildren()) #DumperBase.warn('GENERIC STRUCT: %s' % typeobj) #DumperBase.warn('INAME: %s ' % self.currentIName) #DumperBase.warn('INAMES: %s ' % self.expandedINames) @@ -2782,14 +2792,15 @@ class DumperBase(): self.putNumChild(0) return - self.putNumChild(1) + self.putExpandable() self.putEmptyValue() #DumperBase.warn('STRUCT GUTS: %s ADDRESS: 0x%x ' % (value.name, value.address())) if self.showQObjectNames: #with self.timer(self.currentIName): self.putQObjectNameValue(value) if self.isExpanded(): - self.putField('sortable', 1) + if not self.isCli: + self.putField('sortable', 1) with Children(self, 1, childType=None): self.putFields(value) if self.showQObjectNames: @@ -3190,13 +3201,17 @@ class DumperBase(): val.laddress = self.pointer() if val.laddress is None and self.laddress is not None: val.laddress = self.laddress - val.type = self.dumper.nativeDynamicType(val.laddress, self.type.dereference()) + val.type = self.type.dereference() + if self.dumper.useDynamicType: + val.type = self.dumper.nativeDynamicType(val.laddress, val.type) else: val = self.dumper.nativeValueDereferenceReference(self) elif self.type.code == TypeCode.Pointer: if self.nativeValue is None: val.laddress = self.pointer() - val.type = self.dumper.nativeDynamicType(val.laddress, self.type.dereference()) + val.type = self.type.dereference() + if self.dumper.useDynamicType: + val.type = self.dumper.nativeDynamicType(val.laddress, val.type) else: val = self.dumper.nativeValueDereferencePointer(self) else: @@ -3651,7 +3666,9 @@ class DumperBase(): % type(targetTypish)) val = self.Value(self) val.ldata = self.toPointerData(targetAddress) - targetType = self.createType(targetTypish).dynamicType(targetAddress) + targetType = self.createType(targetTypish) + if self.useDynamicType: + targetType = targetType.dynamicType(targetAddress) val.type = self.createPointerType(targetType) return val @@ -3664,7 +3681,8 @@ class DumperBase(): % type(targetType)) val = self.Value(self) val.ldata = self.toPointerData(targetAddress) - targetType = targetType.dynamicType(targetAddress) + if self.useDynamicType: + targetType = targetType.dynamicType(targetAddress) val.type = self.createReferenceType(targetType) return val @@ -3837,7 +3855,8 @@ class DumperBase(): if self.isInt(datish): # Used as address. #DumperBase.warn('CREATING %s AT 0x%x' % (val.type.name, datish)) val.laddress = datish - val.type = val.type.dynamicType(datish) + if self.useDynamicType: + val.type = val.type.dynamicType(datish) return val if isinstance(datish, bytes): #DumperBase.warn('CREATING %s WITH DATA %s' % (val.type.name, self.hexencode(datish))) |