def qdump__TNimNode(d, value): name = value['name'].pointer() d.putSimpleCharArray(name) if name != 0 else d.putEmptyValue() if d.isExpanded(): with Children(d): sons = value['sons'].pointer() size = value['len'].integer() for i in range(size): val = d.createValue(d.extractPointer(sons + i * d.ptrSize()), value.type) with SubItem(d, '[%d]' % i): d.putItem(val) with SubItem(d, '[raw]'): d.putPlainChildren(value)
def qdumpHelper__std__vector__QNX(d, value): innerType = value.type[0] isBool = innerType.name == 'bool' if isBool: (proxy1, proxy2, start, last, end, size) = value.split("pppppi") else: (proxy, start, last, end) = value.split("pppp") size = (last - start) // innerType.size() d.check(0 <= size and size <= 1000 * 1000 * 1000) d.check(last <= end) if size > 0: d.checkPointer(start) d.checkPointer(last) d.checkPointer(end) d.putItemCount(size) if d.isExpanded(): if isBool: with Children(d, size, maxNumChild=10000, childType=innerType): for i in d.childRange(): q = start + int(i / 8) with SubItem(d, i): d.putValue((d.extractPointer(q) >> (i % 8)) & 1) d.putType("bool") else: d.putPlotData(start, size, innerType)
def qdump__cv__Mat(d, value): (flag, dims, rows, cols, data, refcount, datastart, dataend, datalimit, allocator, size, stepp) \ = value.split('iiiipppppppp') steps = d.split('p' * dims, stepp) innerSize = 0 if dims == 0 else steps[dims - 1] if dims != 2: d.putEmptyValue() d.putPlainChildren(value) return if d.currentItemFormat() == DisplayFormat.SeparateFormat: rs = steps[0] * innerSize cs = cols * innerSize dform = 'arraydata:separate:int:%d::2:%d:%d' % (innerSize, cols, rows) out = ''.join(d.readMemory(data + i * rs, cs) for i in range(rows)) d.putDisplay(dform, out) d.putValue('(%s x %s)' % (rows, cols)) if d.isExpanded(): with Children(d): innerType = d.createType(TypeCode.TypeCodeIntegral, innerSize) for i in range(rows): for j in range(cols): with SubItem(d, None): d.putName('[%d,%d]' % (i, j)) addr = data + (i * steps[0] + j) * innerSize d.putItem(d.createValue(addr, innerType))
def putStringItem(d, name, value): with SubItem(d, name): if isinstance(value, d.Value): d.putValue(value.display()) else: d.putValue(value) d.putType('utf16')
def putFloatItem(d, name, value): with SubItem(d, name): if isinstance(value, d.Value): d.putValue(value.display()) else: d.putValue(value) d.putType('float')
def qdumpHelper__std__tree__iterator(d, value, isSet=False): treeTypeName = None if value.type.name.endswith("::iterator"): treeTypeName = value.type.name[:-len("::iterator")] elif value.type.name.endswith("::const_iterator"): treeTypeName = value.type.name[:-len("::const_iterator")] treeType = d.lookupType(treeTypeName) if treeTypeName else value.type[0] keyType = treeType[0] valueType = treeType[1] node = value["_M_node"].dereference() # std::_Rb_tree_node_base d.putExpandable() d.putEmptyValue() if d.isExpanded(): with Children(d): if isSet: typecode = 'pppp@{%s}' % keyType.name (color, parent, left, right, pad1, key) = d.split(typecode, node) d.putSubItem("value", key) else: typecode = 'pppp@{%s}@{%s}' % (keyType.name, valueType.name) (color, parent, left, right, pad1, key, pad2, value) = d.split(typecode, node) d.putSubItem("first", key) d.putSubItem("second", value) with SubItem(d, "[node]"): d.putExpandable() d.putEmptyValue() d.putType(" ") if d.isExpanded(): with Children(d): #d.putSubItem("color", color) nodeType = node.type.pointer() d.putSubItem("left", d.createValue(left, nodeType)) d.putSubItem("right", d.createValue(right, nodeType)) d.putSubItem("parent", d.createValue(parent, nodeType))
def qdump__tree(d, value): count = value['count'] entries = value['entries'] base = value['base'].pointer() d.putItemCount(count) if d.isExpanded(): with Children(d): with SubItem(d, 'tree'): d.putEmptyValue() d.putNoType() if d.isExpanded(): with Children(d): for i in range(count): d.putSubItem(Item(entries[i], iname)) with SubItem(d, 'data'): d.putEmptyValue() d.putNoType() if d.isExpanded(): with Children(d): for i in range(count): with SubItem(d, i): entry = entries[i] 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' else: length = 0 d.putNumChild(length) if d.isExpanded(): with Children(d): t = d.lookupType( innerType).pointer() p = (base + offset).cast(t) for j in range(length): d.putSubItem( j, p.dereference())
def qdumpHelper__std__vector__bool(d, start, size, inner_type): d.check(0 <= size and size <= 1000 * 1000 * 1000) d.putItemCount(size) if d.isExpanded(): with Children(d, size, maxNumChild=10000, childType=inner_type): for i in d.childRange(): q = start + int(i / 8) with SubItem(d, i): d.putValue((int(d.extractPointer(q)) >> (i % 8)) & 1) d.putType("bool")
def putVTableChildren(self, item, itemCount): p = item.address() for i in range(itemCount): deref = self.extractPointer(p) if deref == 0: n = i break with SubItem(self, i): self.putVtableItem(deref) p += self.ptrSize() return itemCount
def qdump__System__Drawing__Color(d, value): a, r, g, b, is_empty = value.split('BBBBI') known_color_name = value['m_known_color_name'] s = 'ARGB(%d, %d, %d, %d)' % (a, r, g, b) if known_color_name.integer() != 0: s += ' Name = ' + known_color_name.display().split(' (')[0] d.putValue(s) d.putExpandable() if d.isExpanded(): with Children(d): d.putBoolItem('IsEmpty', is_empty) d.putIntItem('A', a) d.putIntItem('R', r) d.putIntItem('G', g) d.putIntItem('B', b) with SubItem(d, 'KnownColor'): d.putItem(known_color_name)
def qdump__Foo(d, value): i = value["i"].integer() j = value["j"].integer() d.putValue("[%d,%d]" % (i, j)) d.putExpandable() if d.isExpanded(): with Children(d): d.putSubItem('j', value["j"]) # Don't try this at home :-) # and the "i" (that is the one in quotes stand for type integer... d.putSubItem('i', d.createValue(struct.pack("i", i), d.intType())) with SubItem(d, "sum"): d.putValue(i + j) d.putType(d.intType()) # not really needed though
def qdumpHelper__std__vector(d, value, isLibCpp): innerType = value.type[0] isBool = innerType.name == 'bool' if isBool: if isLibCpp: start = value["__begin_"].pointer() size = value["__size_"] alloc = size else: start = value["_M_start"]["_M_p"].pointer() soffset = value["_M_start"]["_M_offset"].integer() finish = value["_M_finish"]["_M_p"].pointer() foffset = value["_M_finish"]["_M_offset"].integer() alloc = value["_M_end_of_storage"].pointer() size = (finish - start) * 8 + foffset - soffset # 8 is CHAR_BIT. else: if isLibCpp: start = value["__begin_"].pointer() finish = value["__end_"].pointer() alloc = value["__end_cap_"].pointer() else: start = value["_M_start"].pointer() finish = value["_M_finish"].pointer() alloc = value["_M_end_of_storage"].pointer() size = int((finish - start) / innerType.size()) d.check(finish <= alloc) if size > 0: d.checkPointer(start) d.checkPointer(finish) d.checkPointer(alloc) d.check(0 <= size and size <= 1000 * 1000 * 1000) d.putItemCount(size) if isBool: if d.isExpanded(): with Children(d, size, maxNumChild=10000, childType=innerType): for i in d.childRange(): q = start + int(i / 8) with SubItem(d, i): d.putValue((int(d.extractPointer(q)) >> (i % 8)) & 1) d.putType("bool") d.putNumChild(0) else: d.putPlotData(start, size, innerType)
def sub_item(name, functor, address): with SubItem(d, '[{}]'.format(name)): sub_value = functor(d, address) d.putValue(d.hexencode(sub_value), encoding='utf8')