Commit 2b8fe600 authored by hjk's avatar hjk
Browse files

Debugger: Fix QObject dumper auto test



Change-Id: I722bcaf2f46da132b3c15d9be9bdd87f17cd01a3
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 08816cf2
......@@ -1750,16 +1750,6 @@ class Dumper:
dumper(self, value)
return
# Is this derived from QObject?
#try:
# # If this access fails, it's not a QObject.
# d = value["d_ptr"]["d"]
# privateType = lookupType(self.ns + "QObjectPrivate").pointer()
# objectName = d.cast(privateType).dereference()["objectName"]
# self.putStringValue(objectName, 1)
#except:
# pass
# D arrays, gdc compiled.
if typeName.endswith("[]"):
n = value["length"]
......@@ -1778,6 +1768,8 @@ class Dumper:
fields = extractFields(type)
#fields = type.fields()
self.tryPutObjectNameValue(value) # Is this too expensive?
self.putType(typeName)
self.putAddress(value.address)
self.putValue("{...}")
......@@ -1807,6 +1799,29 @@ class Dumper:
with Children(self):
self.putFields(value)
def tryPutObjectNameValue(self, value):
try:
# Is this derived from QObject?
dd = value["d_ptr"]["d"]
privateTypeName = self.ns + "QObjectPrivate"
privateType = lookupType(privateTypeName)
staticMetaObject = value["staticMetaObject"]
d_ptr = dd.cast(privateType.pointer()).dereference()
objectName = None
try:
objectName = d_ptr["objectName"]
except: # Qt 5
p = d_ptr["extraData"]
if not isNull(p):
objectName = p.dereference()["objectName"]
if not objectName is None:
data, size, alloc = qStringData(objectName)
if size > 0:
str = readRawMemory(data, 2 * size)
self.putValue(str, Hex4EncodedLittleEndian, 1)
except:
pass
def putFields(self, value, dumpBase = True):
type = stripTypedefs(value.type)
# Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
......
......@@ -818,21 +818,12 @@ def extractCString(table, offset):
def qdump__QObject(d, value):
#warn("OBJECT: %s " % value)
d.tryPutObjectNameValue(value)
try:
privateTypeName = d.ns + "QObjectPrivate"
privateTypeName = self.ns + "QObjectPrivate"
privateType = lookupType(privateTypeName)
staticMetaObject = value["staticMetaObject"]
d_ptr = value["d_ptr"]["d"].cast(privateType.pointer()).dereference()
#warn("D_PTR: %s " % d_ptr)
objectName = None
try:
objectName = d_ptr["objectName"]
except: # Qt 5
p = d_ptr["extraData"]
if not isNull(p):
objectName = p.dereference()["objectName"]
if not objectName is None:
d.putStringValue(objectName)
except:
d.putPlainChildren(value)
return
......
......@@ -1359,11 +1359,14 @@ void tst_Dumpers::dumper_data()
% CoreProfile()
% Check("map", "<3 items>", "@QMap<@QString, @QPointer<@QObject>>")
% Check("map.0", "[0]", "", "@QMapNode<@QString, @QPointer<@QObject>>")
% Check("map.0.key", "\".\"", "@QString")
% Check("map.0.key", Value4("\".\""), "@QString")
% Check("map.0.key", Value5("\"Hallo\""), "@QString")
% Check("map.0.value", "", "@QPointer<@QObject>")
% Check("map.0.value.o", "\"\"", "@QObject")
//% Check("map.0.value.o", Pointer(), "@QObject")
// FIXME: it's '.wp' in Qt 5
% Check("map.1", "[1]", "", "@QMapNode<@QString, @QPointer<@QObject>>")
% Check("map.1.key", "\"Hallo\"", "@QString")
% Check("map.1.key", Value4("\"Hallo\""), "@QString")
% Check("map.1.key", Value5("\".\""), "@QString")
% Check("map.2", "[2]", "", "@QMapNode<@QString, @QPointer<@QObject>>")
% Check("map.2.key", "\"Welt\"", "@QString");
......@@ -1539,7 +1542,7 @@ void tst_Dumpers::dumper_data()
"ob.setProperty(\"USER DEFINED 1\", 44);\n"
"ob.setProperty(\"USER DEFINED 2\", QStringList() << \"FOO\" << \"BAR\");\n"
""
"QObject ob1;\n"
"QObject ob1, ob2;\n"
"ob1.setObjectName(\"Another Object\");\n"
"QObject::connect(&ob, SIGNAL(destroyed()), &ob1, SLOT(deleteLater()));\n"
"QObject::connect(&ob, SIGNAL(destroyed()), &ob1, SLOT(deleteLater()));\n"
......@@ -1550,9 +1553,12 @@ void tst_Dumpers::dumper_data()
"obs.append(&ob1);\n"
"obs.append(0);\n"
"obs.append(&app);\n"
"ob1.setObjectName(\"A Subobject\");\n")
"ob2.setObjectName(\"A Subobject\");\n"
"unused(&ob, &ob1, &ob2);\n")
% GuiProfile()
% Check("ob", "An Object", "@QObject");
% Check("ob", "\"An Object\"", "@QWidget")
% Check("ob1", "\"Another Object\"", "@QObject")
% Check("ob2", "\"A Subobject\"", "@QObject");
QByteArray senderData =
" class Sender : public QObject\n"
......@@ -2305,7 +2311,7 @@ void tst_Dumpers::dumper_data()
"std::set<QPointer<QObject> > hash;\n"
"QPointer<QObject> ptr(&ob);\n")
% Check("hash", "<0 items>", "std::set<@QPointer<@QObject>, std::less<@QPointer<@QObject>>, std::allocator<@QPointer<@QObject>>>")
% Check("ob", "\"\"", "@QObject")
% Check("ob", "", "@QObject")
% Check("ptr", "", "@QPointer<@QObject>");
QTest::newRow("StdStack1")
......@@ -2764,7 +2770,7 @@ void tst_Dumpers::dumper_data()
" thread[i].start();\n"
"}\n")
% CheckType("this", "Thread")
% Check("this.@1", "[@QThread]", "", "@QThread")
% Check("this.@1", "[@QThread]", "\"This is thread #3\"", "@QThread")
% Check("this.@1.@1", "[@QObject]", "\"This is thread #3\"", "@QObject");
QTest::newRow("QVariant1")
......
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