From 479b2c7c1aad7ee642f190e1eb2bcecd7e421c6e Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 7 Oct 2016 11:58:06 +0200 Subject: [PATCH] Debugger: Clean up misctypes.py dumper a bit Change-Id: I028e2460f5b0e2621872993cfa111f5b20b16e7e Reviewed-by: hjk --- share/qtcreator/debugger/misctypes.py | 227 ++++++++------------------ 1 file changed, 72 insertions(+), 155 deletions(-) diff --git a/share/qtcreator/debugger/misctypes.py b/share/qtcreator/debugger/misctypes.py index 84b3cb3e330..29f46c82ee7 100644 --- a/share/qtcreator/debugger/misctypes.py +++ b/share/qtcreator/debugger/misctypes.py @@ -33,73 +33,64 @@ from dumper import * def qdump____m128(d, value): d.putEmptyValue() - d.putNumChild(1) if d.isExpanded(): - d.putArrayData(value.address(), 4, d.lookupType("float")) + d.putArrayData(value.address(), 4, d.lookupType('float')) def qdump____m256(d, value): d.putEmptyValue() - d.putNumChild(1) if d.isExpanded(): - d.putArrayData(value.address(), 8, d.lookupType("float")) + d.putArrayData(value.address(), 8, d.lookupType('float')) def qdump____m512(d, value): d.putEmptyValue() - d.putNumChild(1) if d.isExpanded(): - d.putArrayData(value.address(), 16, d.lookupType("float")) + d.putArrayData(value.address(), 16, d.lookupType('float')) def qdump____m128d(d, value): d.putEmptyValue() - d.putNumChild(1) if d.isExpanded(): - d.putArrayData(value.address(), 2, d.lookupType("double")) + d.putArrayData(value.address(), 2, d.lookupType('double')) def qdump____m256d(d, value): d.putEmptyValue() - d.putNumChild(1) if d.isExpanded(): - d.putArrayData(value.address(), 4, d.lookupType("double")) + d.putArrayData(value.address(), 4, d.lookupType('double')) def qdump____m512d(d, value): d.putEmptyValue() - d.putNumChild(1) if d.isExpanded(): - d.putArrayData(value.address(), 8, d.lookupType("double")) + d.putArrayData(value.address(), 8, d.lookupType('double')) def qdump____m128i(d, value): data = d.hexencode(value.data()) - d.putValue(':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(0, 32, 4))) - d.putNumChild(4) + d.putValue(':'.join('%04x' % int(data[i:i+4], 16) for i in xrange(0, 32, 4))) if d.isExpanded(): with Children(d): addr = value.address() - d.putArrayItem("uint8x16", addr, 16, "unsigned char") - d.putArrayItem("uint16x8", addr, 8, "unsigned short") - d.putArrayItem("uint32x4", addr, 4, "unsigned int") - d.putArrayItem("uint64x2", addr, 2, "unsigned long long") + d.putArrayItem('uint8x16', addr, 16, 'unsigned char') + d.putArrayItem('uint16x8', addr, 8, 'unsigned short') + d.putArrayItem('uint32x4', addr, 4, 'unsigned int') + d.putArrayItem('uint64x2', addr, 2, 'unsigned long long') def qdump____m256i(d, value): data = d.hexencode(value.data()) - d.putValue(':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(0, 64, 4))) - d.putNumChild(4) + d.putValue(':'.join('%04x' % int(data[i:i+4], 16) for i in xrange(0, 64, 4))) if d.isExpanded(): with Children(d): addr = value.address() - d.putArrayItem("uint8x32", addr, 32, "unsigned char") - d.putArrayItem("uint16x16", addr, 16, "unsigned short") - d.putArrayItem("uint32x8", addr, 8, "unsigned int") - d.putArrayItem("uint64x4", addr, 4, "unsigned long long") + d.putArrayItem('uint8x32', addr, 32, 'unsigned char') + d.putArrayItem('uint16x16', addr, 16, 'unsigned short') + d.putArrayItem('uint32x8', addr, 8, 'unsigned int') + d.putArrayItem('uint64x4', addr, 4, 'unsigned long long') def qdump____m512i(d, value): data = d.hexencode(value.data()) - d.putValue(':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(0, 64, 4)) - + ', ' + ':'.join("%04x" % int(data[i:i+4], 16) for i in xrange(64, 128, 4))) - d.putNumChild(2) + d.putValue(':'.join('%04x' % int(data[i:i+4], 16) for i in xrange(0, 64, 4)) + + ', ' + ':'.join('%04x' % int(data[i:i+4], 16) for i in xrange(64, 128, 4))) if d.isExpanded(): with Children(d): - d.putArrayItem("uint32x16", value.address(), 16, "unsigned int") - d.putArrayItem("uint64x8", value.address(), 8, "unsigned long long") + d.putArrayItem('uint32x16', value.address(), 16, 'unsigned int') + d.putArrayItem('uint64x8', value.address(), 8, 'unsigned long long') ####################################################################### # @@ -108,7 +99,7 @@ def qdump____m512i(d, value): ####################################################################### #def qform__Eigen__Matrix(): -# return "Transposed" +# return 'Transposed' def qdump__Eigen__Matrix(d, value): innerType = value.type.templateArgument(0, False) @@ -118,7 +109,7 @@ def qdump__Eigen__Matrix(d, value): rowMajor = (int(options) & 0x1) # The magic dimension value is -1 in Eigen3, but 10000 in Eigen2. # 10000 x 10000 matrices are rare, vectors of dim 10000 less so. - # So "fix" only the matrix case: + # So 'fix' only the matrix case: if argCol == 10000 and argRow == 10000: argCol = -1 argRow = -1 @@ -127,20 +118,20 @@ def qdump__Eigen__Matrix(d, value): ncols = argCol p = value.address() else: - storage = value["m_storage"] - nrows = storage["m_rows"].integer() if argRow == -1 else argRow - ncols = storage["m_cols"].integer() if argCol == -1 else argCol - p = storage["m_data"].integer() + storage = value['m_storage'] + nrows = storage['m_rows'].integer() if argRow == -1 else argRow + ncols = storage['m_cols'].integer() if argCol == -1 else argCol + p = storage['m_data'].integer() innerSize = innerType.size() - d.putValue("(%s x %s), %s" % (nrows, ncols, ["ColumnMajor", "RowMajor"][rowMajor])) - d.putField("keeporder", "1") + d.putValue('(%s x %s), %s' % (nrows, ncols, ['ColumnMajor', 'RowMajor'][rowMajor])) + d.putField('keeporder', '1') d.putNumChild(nrows * ncols) limit = 10000 nncols = min(ncols, limit) nnrows = min(nrows, limit * limit / nncols) if d.isExpanded(): - #format = d.currentItemFormat() # format == 1 is "Transposed" + #format = d.currentItemFormat() # format == 1 is 'Transposed' with Children(d, nrows * ncols, childType=innerType): if ncols == 1 or nrows == 1: for i in range(0, min(nrows * ncols, 10000)): @@ -150,14 +141,14 @@ def qdump__Eigen__Matrix(d, value): for i in range(0, nnrows): for j in range(0, nncols): v = d.createValue(p + (i * ncols + j) * innerSize, innerType) - d.putNamedSubItem(s, v, "[%d,%d]" % (i, j)) + d.putNamedSubItem(s, v, '[%d,%d]' % (i, j)) s = s + 1 else: s = 0 for j in range(0, nncols): for i in range(0, nnrows): v = d.createValue(p + (i + j * nrows) * innerSize, innerType) - d.putNamedSubItem(s, v, "[%d,%d]" % (i, j)) + d.putNamedSubItem(s, v, '[%d,%d]' % (i, j)) s = s + 1 @@ -172,15 +163,15 @@ def qdump__NimStringDesc(d, value): data = value.address() + 2 * d.ptrSize() d.putCharArrayHelper(data, size, d.createType('char'), 'utf8') -def qdump__NimGenericSequence__(d, value, regex = "^TY[\d]+$"): +def qdump__NimGenericSequence__(d, value, regex = '^TY[\d]+$'): code = value.type.stripTypedefs().code if code == TypeCodeStruct: size, reserved = d.split('pp', value) data = value.address() + 2 * d.ptrSize() - typeobj = value["data"].type.dereference() + typeobj = value['data'].type.dereference() d.putItemCount(size) d.putArrayData(data, size, typeobj) - d.putBetterType("%s (%s[%s])" % (value.type.name, typeobj.name, size)) + d.putBetterType('%s (%s[%s])' % (value.type.name, typeobj.name, size)) else: d.putEmptyValue() d.putPlainChildren(value) @@ -192,15 +183,15 @@ def qdump__NimGenericSequence__(d, value, regex = "^TY[\d]+$"): ####################################################################### def cleanDType(type): - return str(type).replace("uns long long", "string") + return str(type).replace('uns long long', 'string') def qdump_Array(d, value): - n = value["length"] - p = value["ptr"] + n = value['length'] + p = value['ptr'] t = cleanDType(value.type)[7:] - d.putType("%s[%d]" % (t, n)) - if t == "char": - d.putValue(encodeCharArray(p, 100), "local8bit") + d.putType('%s[%d]' % (t, n)) + if t == 'char': + d.putValue(encodeCharArray(p, 100), 'local8bit') d.putNumChild(0) else: d.putEmptyValue() @@ -214,91 +205,64 @@ def qdump_Array(d, value): def qdump_AArray(d, value): - #n = value["length"] + #n = value['length'] # This ends up as _AArray__ with a single .ptr # member of type void *. Not much that can be done here. - p = value["ptr"] + p = value['ptr'] t = cleanDType(value.type)[8:] - d.putType("%s]" % t.replace("_", "[")) + d.putType('%s]' % t.replace('_', '[')) d.putEmptyValue() - d.putNumChild(1) if d.isExpanded(): with Children(d, 1): - d.putSubItem("ptr", p) + d.putSubItem('ptr', p) ####################################################################### # -# Display Test +# MPI # ####################################################################### -if False: - - # FIXME: Make that work - def qdump__Color(d, value): - v = value - d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"])) - d.putPlainChildren(value) - - def qdump__Color_(d, value): - v = value - d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"])) - if d.isExpanded(): - with Children(d): - with SubItem(d, "0"): - d.putItem(v["r"]) - with SubItem(d, "1"): - d.putItem(v["g"]) - with SubItem(d, "2"): - d.putItem(v["b"]) - with SubItem(d, "3"): - d.putItem(v["a"]) - - if False: def qdump__tree_entry(d, value): - d.putValue("len: %s, offset: %s, type: %s" % - (value["blocklength"], value["offset"], value["type"])) + d.putValue('len: %s, offset: %s, type: %s' % + (value['blocklength'], value['offset'], value['type'])) d.putNumChild(0) def qdump__tree(d, value): - count = value["count"] - entries = value["entries"] - base = value["base"].pointer() + count = value['count'] + entries = value['entries'] + base = value['base'].pointer() d.putItemCount(count) - d.putNumChild(count) if d.isExpanded(): with Children(d): - with SubItem(d, "tree"): + with SubItem(d, 'tree'): d.putEmptyValue() d.putNoType() - d.putNumChild(1) if d.isExpanded(): with Children(d): for i in xrange(count): d.putSubItem(Item(entries[i], iname)) - with SubItem(d, "data"): + with SubItem(d, 'data'): d.putEmptyValue() d.putNoType() - d.putNumChild(1) if d.isExpanded(): with Children(d): for i in xrange(count): with SubItem(d, i): entry = entries[i] - mpitype = str(entry["type"]) + mpitype = str(entry['type']) d.putType(mpitype) - length = int(entry["blocklength"]) - offset = int(entry["offset"]) - d.putValue("%s items at %s" % (length, offset)) - if mpitype == "MPI_INT": - innerType = "int" - elif mpitype == "MPI_CHAR": - innerType = "char" - elif mpitype == "MPI_DOUBLE": - innerType = "double" + length = int(entry['blocklength']) + offset = int(entry['offset']) + d.putValue('%s items at %s' % (length, offset)) + if mpitype == 'MPI_INT': + innerType = 'int' + elif mpitype == 'MPI_CHAR': + innerType = 'char' + elif mpitype == 'MPI_DOUBLE': + innerType = 'double' else: length = 0 d.putNumChild(length) @@ -309,70 +273,23 @@ if False: for j in range(length): d.putSubItem(j, p.dereference()) - #struct KRBase - #{ - # enum Type { TYPE_A, TYPE_B } type; - # KRBase(Type _type) : type(_type) {} - #}; - # - #struct KRA : KRBase { int x; int y; KRA():KRBase(TYPE_A),x(1),y(32) {} }; - #struct KRB : KRBase { KRB():KRBase(TYPE_B) {} }; - # - #void testKR() - #{ - # KRBase *ptr1 = new KRA; - # KRBase *ptr2 = new KRB; - # ptr2 = new KRB; - #} - - def qdump__KRBase(d, value): - if getattr(value, "__nested__", None) is None: - base = ["KRA", "KRB"][int(value["type"])] - nest = value.cast(d.lookupType(base)) - nest.__nested__ = True - warn("NEST %s " % dir(nest)) - d.putItem(nest) - else: - d.putName("type") - d.putValue(value["type"]) - d.putNoType() - - - -if False: - def qdump__bug5106__A5106(d, value): - d.putName("a") - d.putValue("This is the value: %s" % value["m_a"]) - d.putNoType() - d.putNumChild(0) - - -if False: - def qdump__bug6933__Base(d, value): - d.putValue("foo") - d.putPlainChildren(value) - -if False: - def qdump__gdb13393__Base(d, value): - d.putValue("Base (%s)" % value["a"]) - d.putType(value.type) - d.putPlainChildren(value) - - def qdump__gdb13393__Derived(d, value): - d.putValue("Derived (%s, %s)" % (value["a"], value["b"])) - d.putType(value.type) - d.putPlainChildren(value) +####################################################################### +# +# KDSoap +# +####################################################################### def qdump__KDSoapValue1(d, value): - inner = value["d"]["d"].dereference() - d.putStringValue(inner["m_name"]) + inner = value['d']['d'].dereference() + d.putStringValue(inner['m_name']) d.putPlainChildren(inner) def qdump__KDSoapValue(d, value): - p = (value.cast(lookupType("char*")) + 4).dereference().cast(lookupType("QString")) + p = (value.cast(lookupType('char*')) + 4).dereference().cast(lookupType('QString')) d.putStringValue(p) - d.putPlainChildren(value["d"]["d"].dereference()) + d.putPlainChildren(value['d']['d'].dereference()) + ####################################################################### #