Commit 8b2ce98e authored by hjk's avatar hjk

Debugger: Fix QModelIndex dumper

Change-Id: Icd0989bd3581f3b61eb975d58bc1c9e119e27d88
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 3c3d4566
......@@ -687,36 +687,6 @@ def value(expr):
Value = gdb.Value
def makeValue(type, init):
type = "::" + 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)
value = parseAndEvaluate("$d").dereference()
#warn(" TYPE: %s" % value.type)
#warn(" ADDR: %s" % value.address)
#warn(" VALUE: %s" % value)
return value
def makeStdString(init):
# Works only for small allocators, but they are usually empty.
gdb.execute("set $d=(std::string*)calloc(sizeof(std::string), 2)");
gdb.execute("call($d->basic_string(\"" + init +
"\",*(std::allocator<char>*)(1+$d)))")
value = parseAndEvaluate("$d").dereference()
#warn(" TYPE: %s" % value.type)
#warn(" ADDR: %s" % value.address)
#warn(" VALUE: %s" % value)
return value
def makeExpression(value):
type = "::" + stripClassTag(str(value.type))
#warn(" TYPE: %s" % type)
#exp = "(*(%s*)(&%s))" % (type, value.address)
exp = "(*(%s*)(%s))" % (type, value.address)
#warn(" EXP: %s" % exp)
return exp
qqNs = None
......@@ -1092,6 +1062,36 @@ class Dumper(DumperBase):
def call(self, value, func, *args):
return self.call2(value, func, args)
def makeValue(self, type, init):
type = "::" + 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)
value = parseAndEvaluate("$d").dereference()
#warn(" TYPE: %s" % value.type)
#warn(" ADDR: %s" % value.address)
#warn(" VALUE: %s" % value)
return value
def makeExpression(self, value):
type = "::" + stripClassTag(str(value.type))
#warn(" TYPE: %s" % type)
#exp = "(*(%s*)(&%s))" % (type, value.address)
exp = "(*(%s*)(%s))" % (type, value.address)
#warn(" EXP: %s" % exp)
return exp
def makeStdString(init):
# Works only for small allocators, but they are usually empty.
gdb.execute("set $d=(std::string*)calloc(sizeof(std::string), 2)");
gdb.execute("call($d->basic_string(\"" + init +
"\",*(std::allocator<char>*)(1+$d)))")
value = parseAndEvaluate("$d").dereference()
#warn(" TYPE: %s" % value.type)
#warn(" ADDR: %s" % value.address)
#warn(" VALUE: %s" % value)
return value
def childAt(self, value, index):
field = value.type.fields()[index]
if len(field.name):
......
......@@ -98,9 +98,9 @@ def qdump__QAbstractItemModel(d, value):
#format == 2:
# Create a default-constructed QModelIndex on the stack.
try:
ri = makeValue(d.ns + "QModelIndex", "-1, -1, 0, 0")
this_ = makeExpression(value)
ri_ = makeExpression(ri)
ri = d.makeValue(d.ns + "QModelIndex", "-1, -1, 0, 0")
this_ = d.makeExpression(value)
ri_ = d.makeExpression(ri)
rowCount = int(d.parseAndEvaluate("%s.rowCount(%s)" % (this_, ri_)))
columnCount = int(d.parseAndEvaluate("%s.columnCount(%s)" % (this_, ri_)))
except:
......@@ -152,9 +152,9 @@ def qdump__QModelIndex(d, value):
mm = m.dereference()
mm = mm.cast(mm.type.unqualified())
try:
mi = makeValue(d.ns + "QModelIndex", "%s,%s,%s,%s" % (r, c, p, m))
mm_ = makeExpression(mm)
mi_ = makeExpression(mi)
mi = d.makeValue(d.ns + "QModelIndex", "%s,%s,%s,%s" % (r, c, p, m))
mm_ = d.makeExpression(mm)
mi_ = d.makeExpression(mi)
rowCount = int(d.parseAndEvaluate("%s.rowCount(%s)" % (mm_, mi_)))
columnCount = int(d.parseAndEvaluate("%s.columnCount(%s)" % (mm_, mi_)))
except:
......@@ -166,7 +166,7 @@ def qdump__QModelIndex(d, value):
# Access DisplayRole as value
val = d.parseAndEvaluate("%s.data(%s, 0)" % (mm_, mi_))
v = val["d"]["data"]["ptr"]
d.putStringValue(makeValue(d.ns + 'QString', v))
d.putStringValue(d.makeValue(d.ns + 'QString', v))
except:
d.putValue("(invalid)")
......
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