forked from qt-creator/qt-creator
Debugger: Implement Dumper.putCallItem() in LLDB interface
Change-Id: I7243b4fe9e8fd91653e236722282fa8f8a9ed82d Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -68,6 +68,20 @@ def isSimpleType(typeobj):
|
||||
#warn("TYPECLASS: %s" % typeClass)
|
||||
return typeClass == lldb.eTypeClassBuiltin
|
||||
|
||||
def call2(value, func, args):
|
||||
# args is a tuple.
|
||||
arg = ','.join(args)
|
||||
warn("CALL: %s -> %s(%s)" % (value, func, arg))
|
||||
type = value.type.name
|
||||
exp = "((%s*)%s)->%s(%s)" % (type, value.address, func, arg)
|
||||
warn("CALL: %s" % exp)
|
||||
result = value.CreateValueFromExpression('$tmp', exp)
|
||||
warn(" -> %s" % result)
|
||||
return result
|
||||
|
||||
def call(value, func, *args):
|
||||
return call2(value, func, args)
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# Helpers
|
||||
@@ -136,7 +150,7 @@ def registerDumper(function):
|
||||
pass
|
||||
|
||||
def warn(message):
|
||||
print '\nWARNING="%s",\n' % message.encode("latin1").replace('"', "'")
|
||||
print '\n\nWARNING="%s",\n' % message.encode("latin1").replace('"', "'")
|
||||
|
||||
def showException(msg, exType, exValue, exTraceback):
|
||||
warn("**** CAUGHT EXCEPTION: %s ****" % msg)
|
||||
@@ -408,6 +422,18 @@ class Children:
|
||||
return True
|
||||
|
||||
|
||||
class NoAddress:
|
||||
def __init__(self, d):
|
||||
self.d = d
|
||||
|
||||
def __enter__(self):
|
||||
self.savedPrintsAddress = self.d.currentPrintsAddress
|
||||
self.d.currentPrintsAddress = False
|
||||
|
||||
def __exit__(self, exType, exValue, exTraceBack):
|
||||
self.d.currentPrintsAddress = self.savedPrintsAddress
|
||||
|
||||
|
||||
|
||||
class SubItem:
|
||||
def __init__(self, d, component):
|
||||
@@ -676,6 +702,14 @@ class Dumper:
|
||||
for i in self.childRange():
|
||||
self.putSubItem(i, (base + i).dereference())
|
||||
|
||||
def parseAndEvalute(self, expr):
|
||||
return expr
|
||||
|
||||
def putCallItem(self, name, value, func, *args):
|
||||
result = call2(value, func, args)
|
||||
with SubItem(self, name):
|
||||
self.putItem(result)
|
||||
|
||||
def childRange(self):
|
||||
if self.currentMaxNumChild is None:
|
||||
return xrange(0, self.currentNumChild)
|
||||
@@ -689,7 +723,8 @@ class Dumper:
|
||||
self.putFields(value)
|
||||
|
||||
def lookupType(self, name):
|
||||
#warn("LOOKUP: %s" % self.target.FindFirstType(name))
|
||||
#warn("LOOKUP TYPE NAME: %s" % name)
|
||||
#warn("LOOKUP RESULT: %s" % self.target.FindFirstType(name))
|
||||
return self.target.FindFirstType(name)
|
||||
|
||||
def setupInferior(self, args):
|
||||
|
||||
@@ -252,12 +252,14 @@ def qdump__QModelIndex(d, value):
|
||||
|
||||
|
||||
def qdump__QDate(d, value):
|
||||
jd = value["jd"]
|
||||
jd = int(value["jd"])
|
||||
if int(jd):
|
||||
d.putValue(jd, JulianDate)
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
qt = d.ns + "Qt::"
|
||||
if lldbLoaded:
|
||||
qt += "DateFormat::" # FIXME: Bug?...
|
||||
# FIXME: This improperly uses complex return values.
|
||||
with Children(d):
|
||||
d.putCallItem("toString", value, "toString", qt + "TextDate")
|
||||
@@ -277,6 +279,8 @@ def qdump__QTime(d, value):
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
qt = d.ns + "Qt::"
|
||||
if lldbLoaded:
|
||||
qt += "DateFormat::" # FIXME: Bug?...
|
||||
# FIXME: This improperly uses complex return values.
|
||||
with Children(d):
|
||||
d.putCallItem("toString", value, "toString", qt + "TextDate")
|
||||
@@ -297,15 +301,17 @@ def qdump__QDateTime(d, value):
|
||||
except:
|
||||
d.putPlainChildren(value)
|
||||
return
|
||||
mds = p["time"]["mds"]
|
||||
if int(mds) >= 0:
|
||||
d.putValue("%s/%s" % (p["date"]["jd"], mds),
|
||||
mds = int(p["time"]["mds"])
|
||||
if mds >= 0:
|
||||
d.putValue("%s/%s" % (int(p["date"]["jd"]), mds),
|
||||
JulianDateAndMillisecondsSinceMidnight)
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
# FIXME: This improperly uses complex return values.
|
||||
with Children(d):
|
||||
qt = d.ns + "Qt::"
|
||||
if lldbLoaded:
|
||||
qt += "DateFormat::" # FIXME: Bug?...
|
||||
d.putCallItem("toTime_t", value, "toTime_t")
|
||||
d.putCallItem("toString", value, "toString", qt + "TextDate")
|
||||
d.putCallItem("(ISO)", value, "toString", qt + "ISODate")
|
||||
@@ -1829,15 +1835,19 @@ def qdump__QVariant(d, value):
|
||||
return innert
|
||||
|
||||
# User types.
|
||||
type = str(call(value, "typeToName",
|
||||
"('%sQVariant::Type')%d" % (d.ns, d_ptr["type"])))
|
||||
if gdbLoaded:
|
||||
type = str(call(value, "typeToName",
|
||||
"('%sQVariant::Type')%d" % (d.ns, d_ptr["type"])))
|
||||
if lldbLoaded:
|
||||
type = str(call(value, "typeToName",
|
||||
"(%sQVariant::Type)%d" % (d.ns, d_ptr["type"])))
|
||||
type = type[type.find('"') + 1 : type.rfind('"')]
|
||||
type = type.replace("Q", d.ns + "Q") # HACK!
|
||||
type = type.replace("uint", "unsigned int") # HACK!
|
||||
type = type.replace("COMMA", ",") # HACK!
|
||||
warn("TYPE: %s" % type)
|
||||
#warn("TYPE: %s" % type)
|
||||
data = call(value, "constData")
|
||||
warn("DATA: %s" % data)
|
||||
#warn("DATA: %s" % data)
|
||||
d.putEmptyValue(-99)
|
||||
d.putType("%sQVariant (%s)" % (d.ns, type))
|
||||
d.putNumChild(1)
|
||||
|
||||
Reference in New Issue
Block a user