Commit 66db60e0 authored by hjk's avatar hjk

debugger: replace xrange(0, end) by xrange(end).

parent 57c09a7e
...@@ -194,7 +194,7 @@ def stripClassTag(type): ...@@ -194,7 +194,7 @@ def stripClassTag(type):
return type return type
def checkPointerRange(p, n): def checkPointerRange(p, n):
for i in xrange(0, n): for i in xrange(n):
checkPointer(p) checkPointer(p)
++p ++p
...@@ -218,7 +218,7 @@ def qtNamespace(): ...@@ -218,7 +218,7 @@ def qtNamespace():
def encodeCharArray(p, size): def encodeCharArray(p, size):
s = "" s = ""
for i in xrange(0, size): for i in xrange(size):
s += "%02x" % int(p.dereference()) s += "%02x" % int(p.dereference())
p += 1 p += 1
return s return s
...@@ -250,7 +250,7 @@ def encodeString(value): ...@@ -250,7 +250,7 @@ def encodeString(value):
check(d_ptr["ref"]["_q_value"] > 0) check(d_ptr["ref"]["_q_value"] > 0)
p = gdb.Value(d_ptr["data"]) p = gdb.Value(d_ptr["data"])
s = "" s = ""
for i in xrange(0, size): for i in xrange(size):
val = int(p.dereference()) val = int(p.dereference())
s += "%02x" % (val % 256) s += "%02x" % (val % 256)
s += "%02x" % (val / 256) s += "%02x" % (val / 256)
...@@ -356,7 +356,7 @@ class FrameCommand(gdb.Command): ...@@ -356,7 +356,7 @@ class FrameCommand(gdb.Command):
if d.isExpanded(item): if d.isExpanded(item):
p = item.value p = item.value
d.beginChildren(n) d.beginChildren(n)
for i in xrange(0, n): for i in xrange(n):
value = p.dereference() value = p.dereference()
d.putItem(Item(value, item.iname, i, None)) d.putItem(Item(value, item.iname, i, None))
p += 1 p += 1
...@@ -673,19 +673,6 @@ class Dumper: ...@@ -673,19 +673,6 @@ class Dumper:
result = call(item.value, func) result = call(item.value, func)
self.putItem(Item(result, item.iname, name, name)) self.putItem(Item(result, item.iname, name, name))
#def putItemOrPointerHelper(self, item):
# if item.value.type.code == gdb.TYPE_CODE_PTR \
# and str(item.value.type.target()) != "char":
# if not isNull(item.value):
# self.putItemOrPointerHelper(
# Item(item.value.dereference(), item.iname, None, None))
# else:
# self.putValue("(null)")
# self.putNumChild(0)
# else:
# self.safePutItemHelper(item)
def putItemHelper(self, item): def putItemHelper(self, item):
name = getattr(item, "name", None) name = getattr(item, "name", None)
if not name is None: if not name is None:
...@@ -753,7 +740,7 @@ class Dumper: ...@@ -753,7 +740,7 @@ class Dumper:
self.putType(item.value.type) self.putType(item.value.type)
firstNul = -1 firstNul = -1
p = value p = value
for i in xrange(0, 100): for i in xrange(100):
if p.dereference() == 0: if p.dereference() == 0:
# Found terminating NUL # Found terminating NUL
self.putValue(encodeCharArray(value, i), "6") self.putValue(encodeCharArray(value, i), "6")
...@@ -769,7 +756,6 @@ class Dumper: ...@@ -769,7 +756,6 @@ class Dumper:
self.putType(innerType) self.putType(innerType)
self.childTypes.append( self.childTypes.append(
stripClassTag(str(innerType))) stripClassTag(str(innerType)))
#self.putType(item.value.type.target())
self.putItemHelper( self.putItemHelper(
Item(item.value.dereference(), item.iname, None, None)) Item(item.value.dereference(), item.iname, None, None))
self.childTypes.pop() self.childTypes.pop()
...@@ -823,7 +809,7 @@ class Dumper: ...@@ -823,7 +809,7 @@ class Dumper:
if field.name is None: if field.name is None:
innerType = value.type.target() innerType = value.type.target()
p = value.cast(innerType.pointer()) p = value.cast(innerType.pointer())
for i in xrange(0, value.type.sizeof / innerType.sizeof): for i in xrange(value.type.sizeof / innerType.sizeof):
self.putItem(Item(p.dereference(), item.iname, i, None)) self.putItem(Item(p.dereference(), item.iname, i, None))
p = p + 1 p = p + 1
continue continue
......
...@@ -20,7 +20,7 @@ def qdump__QByteArray(d, item): ...@@ -20,7 +20,7 @@ def qdump__QByteArray(d, item):
data = d_ptr['data'] data = d_ptr['data']
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
p = gdb.Value(data.cast(innerType.pointer())) p = gdb.Value(data.cast(innerType.pointer()))
for i in xrange(0, n): for i in xrange(n):
d.putItem(Item(p.dereference(), item.iname, i, None)) d.putItem(Item(p.dereference(), item.iname, i, None))
p += 1 p += 1
if n < size: if n < size:
...@@ -51,8 +51,8 @@ def qdump__QAbstractItem(d, item): ...@@ -51,8 +51,8 @@ def qdump__QAbstractItem(d, item):
if d.isExpanded(item): if d.isExpanded(item):
innerType = gdb.lookup_type(d.ns + "QAbstractItem") innerType = gdb.lookup_type(d.ns + "QAbstractItem")
d.beginChildren() d.beginChildren()
for row in xrange(0, rowCount): for row in xrange(rowCount):
for column in xrange(0, columnCount): for column in xrange(columnCount):
child = call(m, "index(row, column, mi)") child = call(m, "index(row, column, mi)")
d.putName("[%s,%s]" % (row, column)) d.putName("[%s,%s]" % (row, column))
rr = call(m, "rowCount(child)") rr = call(m, "rowCount(child)")
...@@ -89,8 +89,8 @@ def qdump__QAbstractItemModel(d, item): ...@@ -89,8 +89,8 @@ def qdump__QAbstractItemModel(d, item):
d.putType(d.ns + "QObject") d.putType(d.ns + "QObject")
d.putField("displayedtype", call(item, "m.metaObject()->className()")) d.putField("displayedtype", call(item, "m.metaObject()->className()"))
d.endHash() d.endHash()
for row in xrange(0, rowCount): for row in xrange(rowCount):
for column in xrange(0, columnCount): for column in xrange(columnCount):
mi = call(m, "index(%s,%s)" % (row, column)) mi = call(m, "index(%s,%s)" % (row, column))
d.beginHash() d.beginHash()
d.putName("[%s,%s]" % (row, column)) d.putName("[%s,%s]" % (row, column))
...@@ -246,7 +246,7 @@ def qdump__QHash(d, item): ...@@ -246,7 +246,7 @@ def qdump__QHash(d, item):
numBuckets = d["numBuckets"] numBuckets = d["numBuckets"]
start = (node["h"] % numBuckets) + 1 start = (node["h"] % numBuckets) + 1
bucket = d["buckets"] + start bucket = d["buckets"] + start
for n in xrange(0, numBuckets - start): for n in xrange(numBuckets - start):
if bucket.dereference() != next: if bucket.dereference() != next:
return bucket.dereference() return bucket.dereference()
bucket += 1 bucket += 1
...@@ -278,7 +278,7 @@ def qdump__QHash(d, item): ...@@ -278,7 +278,7 @@ def qdump__QHash(d, item):
innerType = e_ptr.dereference().type innerType = e_ptr.dereference().type
inner = select(isSimpleKey and isSimpleValue, valueType, innerType) inner = select(isSimpleKey and isSimpleValue, valueType, innerType)
d.beginChildren(n, inner) d.beginChildren(n, inner)
for i in xrange(0, n): for i in xrange(n):
it = node.dereference().cast(innerType) it = node.dereference().cast(innerType)
d.beginHash() d.beginHash()
key = it["key"] key = it["key"]
...@@ -363,7 +363,7 @@ def qdump__QList(d, item): ...@@ -363,7 +363,7 @@ def qdump__QList(d, item):
else: else:
inner = innerType inner = innerType
d.beginChildren(n, inner) d.beginChildren(n, inner)
for i in xrange(0, n): for i in xrange(n):
if isInternal: if isInternal:
d.putItem(Item(p.dereference(), item.iname, i, None)) d.putItem(Item(p.dereference(), item.iname, i, None))
else: else:
...@@ -419,7 +419,7 @@ def qdump__QLinkedList(d, item): ...@@ -419,7 +419,7 @@ def qdump__QLinkedList(d, item):
n = 1000 n = 1000
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
p = e_ptr["n"] p = e_ptr["n"]
for i in xrange(0, n): for i in xrange(n):
d.safePutItem(Item(p["t"], None, None, None)) d.safePutItem(Item(p["t"], None, None, None))
p = p["n"] p = p["n"]
if n < nn: if n < nn:
...@@ -496,7 +496,7 @@ def qdump__QMap(d, item): ...@@ -496,7 +496,7 @@ def qdump__QMap(d, item):
innerType = select(isSimpleKey and isSimpleValue, valueType, nodeType) innerType = select(isSimpleKey and isSimpleValue, valueType, nodeType)
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
for i in xrange(0, n): for i in xrange(n):
itd = it.dereference() itd = it.dereference()
base = it.cast(charPtr) - payloadSize base = it.cast(charPtr) - payloadSize
node = base.cast(nodeType.pointer()).dereference() node = base.cast(nodeType.pointer()).dereference()
...@@ -600,7 +600,7 @@ def qdump__QObject(d, item): ...@@ -600,7 +600,7 @@ def qdump__QObject(d, item):
d.putNumChild(propertyCount) d.putNumChild(propertyCount)
if d.isExpandedIName(item.iname + ".properties"): if d.isExpandedIName(item.iname + ".properties"):
d.beginChildren() d.beginChildren()
for property in xrange(0, propertyCount): for property in xrange(propertyCount):
d.beginHash() d.beginHash()
offset = propertyData + 3 * property offset = propertyData + 3 * property
propertyName = extractCString(metaStringData, metaData[offset]) propertyName = extractCString(metaStringData, metaData[offset])
...@@ -648,7 +648,7 @@ def qdump__QObject(d, item): ...@@ -648,7 +648,7 @@ def qdump__QObject(d, item):
connectionLists = d_ptr["connectionLists"] connectionLists = d_ptr["connectionLists"]
warn("CONNECTIONLISTS: %s " % connectionLists) warn("CONNECTIONLISTS: %s " % connectionLists)
for connection in xrange(0, connectionCount): for connection in xrange(connectionCount):
d.beginHash() d.beginHash()
d.putName("connection %d" % connection) d.putName("connection %d" % connection)
d.putValue("") d.putValue("")
...@@ -669,7 +669,7 @@ def qdump__QObject(d, item): ...@@ -669,7 +669,7 @@ def qdump__QObject(d, item):
d.putField("childnumchild", "0") d.putField("childnumchild", "0")
if d.isExpandedIName(item.iname + ".signals"): if d.isExpandedIName(item.iname + ".signals"):
d.beginChildren() d.beginChildren()
for signal in xrange(0, signalCount): for signal in xrange(signalCount):
d.beginHash() d.beginHash()
offset = metaData[14 + 5 * signal] offset = metaData[14 + 5 * signal]
d.putName("signal %d" % signal) d.putName("signal %d" % signal)
...@@ -691,7 +691,7 @@ def qdump__QObject(d, item): ...@@ -691,7 +691,7 @@ def qdump__QObject(d, item):
d.putField("childnumchild", "0") d.putField("childnumchild", "0")
if d.isExpandedIName(item.iname + ".slots"): if d.isExpandedIName(item.iname + ".slots"):
d.beginChildren() d.beginChildren()
for slot in xrange(0, slotCount): for slot in xrange(slotCount):
d.beginHash() d.beginHash()
offset = metaData[14 + 5 * (signalCount + slot)] offset = metaData[14 + 5 * (signalCount + slot)]
d.putName("slot %d" % slot) d.putName("slot %d" % slot)
...@@ -1383,7 +1383,7 @@ def qdump__QSet(d, item): ...@@ -1383,7 +1383,7 @@ def qdump__QSet(d, item):
numBuckets = d["numBuckets"] numBuckets = d["numBuckets"]
start = (node["h"] % numBuckets) + 1 start = (node["h"] % numBuckets) + 1
bucket = d["buckets"] + start bucket = d["buckets"] + start
for n in xrange(0, numBuckets - start): for n in xrange(numBuckets - start):
if bucket.dereference() != next: if bucket.dereference() != next:
return bucket.dereference() return bucket.dereference()
bucket += 1 bucket += 1
...@@ -1413,7 +1413,7 @@ def qdump__QSet(d, item): ...@@ -1413,7 +1413,7 @@ def qdump__QSet(d, item):
innerType = e_ptr.dereference().type innerType = e_ptr.dereference().type
d.beginChildren(n, keyType) d.beginChildren(n, keyType)
for i in xrange(0, n): for i in xrange(n):
it = node.dereference().cast(innerType) it = node.dereference().cast(innerType)
d.beginHash() d.beginHash()
key = it["key"] key = it["key"]
...@@ -1474,7 +1474,7 @@ def qdump__QStringList(d, item): ...@@ -1474,7 +1474,7 @@ def qdump__QStringList(d, item):
innerType = gdb.lookup_type(d.ns + "QString") innerType = gdb.lookup_type(d.ns + "QString")
ptr = gdb.Value(d_ptr["array"]).cast(innerType.pointer()) ptr = gdb.Value(d_ptr["array"]).cast(innerType.pointer())
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
for i in xrange(0, n): for i in xrange(n):
d.putItem(Item(ptr.dereference(), item.iname, i, None)) d.putItem(Item(ptr.dereference(), item.iname, i, None))
ptr += 1 ptr += 1
if n < end - begin: if n < end - begin:
...@@ -1670,7 +1670,7 @@ def qdump__QVector(d, item): ...@@ -1670,7 +1670,7 @@ def qdump__QVector(d, item):
n = 10000 n = 10000
p = gdb.Value(p_ptr["array"]).cast(innerType.pointer()) p = gdb.Value(p_ptr["array"]).cast(innerType.pointer())
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
for i in xrange(0, n): for i in xrange(n):
d.safePutItem(Item(p.dereference(), item.iname, i, None)) d.safePutItem(Item(p.dereference(), item.iname, i, None))
p += 1 p += 1
if n < size: if n < size:
...@@ -1732,7 +1732,7 @@ def qdump__std__deque(d, item): ...@@ -1732,7 +1732,7 @@ def qdump__std__deque(d, item):
pfirst = start["_M_first"] pfirst = start["_M_first"]
plast = start["_M_last"] plast = start["_M_last"]
pnode = start["_M_node"] pnode = start["_M_node"]
for i in xrange(0, n): for i in xrange(n):
d.safePutItem(Item(pcur.dereference(), item.iname, i, None)) d.safePutItem(Item(pcur.dereference(), item.iname, i, None))
pcur += 1 pcur += 1
if pcur == plast: if pcur == plast:
...@@ -1764,7 +1764,7 @@ def qdump__std__list(d, item): ...@@ -1764,7 +1764,7 @@ def qdump__std__list(d, item):
p = node["_M_next"] p = node["_M_next"]
innerType = item.value.type.template_argument(0) innerType = item.value.type.template_argument(0)
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
for i in xrange(0, n): for i in xrange(n):
innerPointer = innerType.pointer() innerPointer = innerType.pointer()
value = (p + 1).cast(innerPointer).dereference() value = (p + 1).cast(innerPointer).dereference()
d.safePutItem(Item(value, item.iname, i, None)) d.safePutItem(Item(value, item.iname, i, None))
...@@ -1792,7 +1792,7 @@ def qdump__std__map(d, item): ...@@ -1792,7 +1792,7 @@ def qdump__std__map(d, item):
node = impl["_M_header"]["_M_left"] node = impl["_M_header"]["_M_left"]
d.beginChildren(n, select(n > 0, innerType, pairType), d.beginChildren(n, select(n > 0, innerType, pairType),
select(isSimpleKey and isSimpleValue, None, 2)) select(isSimpleKey and isSimpleValue, None, 2))
for i in xrange(0, qmin(n, 1000)): for i in xrange(qmin(n, 1000)):
pair = (node + 1).cast(pairPointer).dereference() pair = (node + 1).cast(pairPointer).dereference()
d.beginHash() d.beginHash()
...@@ -1838,7 +1838,7 @@ def qdump__std__set(d, item): ...@@ -1838,7 +1838,7 @@ def qdump__std__set(d, item):
valueType = item.value.type.template_argument(0) valueType = item.value.type.template_argument(0)
node = impl["_M_header"]["_M_left"] node = impl["_M_header"]["_M_left"]
d.beginChildren(n, valueType) d.beginChildren(n, valueType)
for i in xrange(0, qmin(n, 1000)): for i in xrange(qmin(n, 1000)):
element = (node + 1).cast(valueType.pointer()).dereference() element = (node + 1).cast(valueType.pointer()).dereference()
d.putItem(Item(element, item.iname, i, None)) d.putItem(Item(element, item.iname, i, None))
...@@ -1879,7 +1879,7 @@ def qdump__std__string(d, item): ...@@ -1879,7 +1879,7 @@ def qdump__std__string(d, item):
s = "" s = ""
format = "%%0%dx" % (2 * charType.sizeof) format = "%%0%dx" % (2 * charType.sizeof)
n = qmin(size, 1000) n = qmin(size, 1000)
for i in xrange(0, size): for i in xrange(size):
s += format % int(p.dereference()) s += format % int(p.dereference())
p += 1 p += 1
d.putValue(s, 6) d.putValue(s, 6)
...@@ -1906,7 +1906,7 @@ def qdump__std__vector(d, item): ...@@ -1906,7 +1906,7 @@ def qdump__std__vector(d, item):
p = start p = start
innerType = item.value.type.template_argument(0) innerType = item.value.type.template_argument(0)
d.beginChildren(n, innerType) d.beginChildren(n, innerType)
for i in xrange(0, n): for i in xrange(n):
d.safePutItem(Item(p.dereference(), item.iname, i, None)) d.safePutItem(Item(p.dereference(), item.iname, i, None))
p += 1 p += 1
if n < size: if n < size:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment