forked from qt-creator/qt-creator
debugger: robustify QFile* dumpers
Change-Id: Ic5ec62a484b2d7c71664e86b7f1f38c582492811 Reviewed-on: http://codereview.qt.nokia.com/4051 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -527,7 +527,7 @@ def makeValue(type, init):
|
||||
type = stripClassTag(type)
|
||||
if type.find(":") >= 0:
|
||||
type = "'" + type + "'"
|
||||
# Avoid malloc symbol clash with QVector
|
||||
# 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()
|
||||
@@ -685,12 +685,13 @@ def qQStringData(value):
|
||||
if qtMajorVersion() < 5:
|
||||
d_ptr = value['d'].dereference()
|
||||
checkRef(d_ptr['ref'])
|
||||
return d_ptr['data'], d_ptr['size'], d_ptr['alloc']
|
||||
return d_ptr['data'], int(d_ptr['size']), int(d_ptr['alloc'])
|
||||
else: # Qt5: Implement the QStringArrayData::data() accessor.
|
||||
qStringData = value['d'].dereference()
|
||||
ushortPointerType = lookupType('ushort *')
|
||||
data = qStringData['d'].cast(ushortPointerType) + ushortPointerType.sizeof / 2 + qStringData['offset']
|
||||
return data, qStringData['size'], qStringData['alloc']
|
||||
data = qStringData['d'].cast(ushortPointerType) \
|
||||
+ ushortPointerType.sizeof / 2 + qStringData['offset']
|
||||
return data, int(qStringData['size']), int(qStringData['alloc'])
|
||||
|
||||
def encodeString(value):
|
||||
data, size, alloc = qQStringData(value)
|
||||
@@ -1175,10 +1176,10 @@ class Dumper:
|
||||
self.putValue("0x%x" % value.dereference().cast(
|
||||
lookupType("unsigned long")), None, -1)
|
||||
|
||||
def putStringValue(self, value):
|
||||
def putStringValue(self, value, priority = 0):
|
||||
if not value is None:
|
||||
str = encodeString(value)
|
||||
self.putValue(str, Hex4EncodedLittleEndian)
|
||||
self.putValue(str, Hex4EncodedLittleEndian, priority)
|
||||
|
||||
def putDisplay(self, format, value = None, cmd = None):
|
||||
self.put('editformat="%s",' % format)
|
||||
@@ -1255,6 +1256,7 @@ class Dumper:
|
||||
with SubItem(self, component):
|
||||
self.putName(name)
|
||||
self.putItem(value)
|
||||
|
||||
def putCallItem(self, name, value, func, *args):
|
||||
result = call2(value, func, args)
|
||||
with SubItem(self, name):
|
||||
@@ -1479,34 +1481,26 @@ class Dumper:
|
||||
warn("WRONG ASSUMPTION HERE: %s " % type.code)
|
||||
check(False)
|
||||
|
||||
# Is this derived from QObject?
|
||||
isQObjectDerived = self.checkForQObjectBase(type)
|
||||
|
||||
nsStrippedType = self.stripNamespaceFromType(typeName)\
|
||||
.replace("::", "__")
|
||||
|
||||
#warn(" STRIPPED: %s" % nsStrippedType)
|
||||
#warn(" DUMPERS: %s" % (nsStrippedType in qqDumpers))
|
||||
|
||||
if self.useFancy \
|
||||
and (format is None or format >= 1) \
|
||||
and (nsStrippedType in qqDumpers \
|
||||
or typeName in qqDumpers \
|
||||
or isQObjectDerived):
|
||||
#warn("IS DUMPABLE: %s " % type)
|
||||
#self.putAddress(value.address)
|
||||
if self.useFancy and (format is None or format >= 1):
|
||||
self.putAddress(value.address)
|
||||
self.putType(typeName)
|
||||
if nsStrippedType in qqDumpers:
|
||||
qqDumpers[nsStrippedType](self, value)
|
||||
|
||||
if typeName in qqDumpers:
|
||||
qqDumpers[typeName](self, value)
|
||||
elif isQObjectDerived:
|
||||
# FIXME: value has references stripped off item.value.
|
||||
#item1 = Item(value, item.iname)
|
||||
return
|
||||
|
||||
nsStrippedType = self.stripNamespaceFromType(typeName)\
|
||||
.replace("::", "__")
|
||||
#warn(" STRIPPED: %s" % nsStrippedType)
|
||||
#warn(" DUMPERS: %s" % (nsStrippedType in qqDumpers))
|
||||
if nsStrippedType in qqDumpers:
|
||||
qqDumpers[nsStrippedType](self, value)
|
||||
return
|
||||
|
||||
# Is this derived from QObject?
|
||||
if self.checkForQObjectBase(type):
|
||||
qdump__QObject(self, value)
|
||||
#warn(" RESULT: %s " % self.output)
|
||||
return
|
||||
return
|
||||
|
||||
#warn("GENERIC STRUCT: %s" % type)
|
||||
#warn("INAME: %s " % self.currentIName)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#Note: Keep name-type-value-numchild-extra order
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# Dumper Implementations
|
||||
@@ -206,7 +204,7 @@ def qdump__QDateTime(d, value):
|
||||
|
||||
def qdump__QDir(d, value):
|
||||
d.putStringValue(value["d_ptr"]["d"].dereference()["path"])
|
||||
d.putNumChild(2)
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
with Children(d):
|
||||
d.putCallItem("absolutePath", value, "absolutePath")
|
||||
@@ -214,13 +212,17 @@ def qdump__QDir(d, value):
|
||||
|
||||
|
||||
def qdump__QFile(d, value):
|
||||
ptype = lookupType(d.ns + "QFilePrivate")
|
||||
d_ptr = value["d_ptr"]["d"].dereference()
|
||||
d.putStringValue(d_ptr.cast(ptype)["fileName"])
|
||||
try:
|
||||
ptype = lookupType(d.ns + "QFilePrivate").pointer()
|
||||
d_ptr = value["d_ptr"]["d"]
|
||||
d.putStringValue(d_ptr.cast(ptype).dereference()["fileName"])
|
||||
except:
|
||||
d.putPlainChildren(value)
|
||||
return
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
with Children(d):
|
||||
d.putCallItem("exists", value, "exists()")
|
||||
d.putCallItem("exists", value, "exists")
|
||||
|
||||
|
||||
def qdump__QFileInfo(d, value):
|
||||
@@ -229,7 +231,7 @@ def qdump__QFileInfo(d, value):
|
||||
except:
|
||||
d.putPlainChildren(value)
|
||||
return
|
||||
d.putNumChild(3)
|
||||
d.putNumChild(1)
|
||||
if d.isExpanded():
|
||||
with Children(d, childType=lookupType(d.ns + "QString")):
|
||||
d.putCallItem("absolutePath", value, "absolutePath")
|
||||
|
||||
@@ -504,9 +504,9 @@ namespace qfileinfo {
|
||||
void testQFileInfo()
|
||||
{
|
||||
QFile file("/tmp/t");
|
||||
QFileInfo fi("/tmp/t");
|
||||
file.setObjectName("A QFile instance");
|
||||
QFileInfo fi("/tmp/tt");
|
||||
QString s = fi.absoluteFilePath();
|
||||
s = fi.bundleName();
|
||||
dummyStatement(&file, &s);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user