Commit 01597744 authored by hjk's avatar hjk
Browse files

Debugger: Improve QVariant dumper



Access to the is_shared flag seems somewhat indeterministic
across platforms/compilers. Hard-code to non-shared for now.

Change-Id: Iaac9dd8fcee28ffd1e599300a1c12f3215823573
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent ea6a7214
......@@ -1855,27 +1855,27 @@ def qdumpHelper_QVariant_1(d, data):
def qdumpHelper_QVariant_2(d, data):
# QVariant::Int
d.putBetterType("%sQVariant (int)" % d.ns)
d.putValue(data["i"])
d.putValue(int(data["i"]))
def qdumpHelper_QVariant_3(d, data):
# uint
d.putBetterType("%sQVariant (uint)" % d.ns)
d.putValue(data["u"])
d.putValue(int(data["u"]))
def qdumpHelper_QVariant_4(d, data):
# qlonglong
d.putBetterType("%sQVariant (qlonglong)" % d.ns)
d.putValue(data["ll"])
d.putValue(int(data["ll"]))
def qdumpHelper_QVariant_5(d, data):
# qulonglong
d.putBetterType("%sQVariant (qulonglong)" % d.ns)
d.putValue(data["ull"])
d.putValue(int(data["ull"]))
def qdumpHelper_QVariant_6(d, data):
# QVariant::Double
d.putBetterType("%sQVariant (double)" % d.ns)
d.putValue(data["d"])
d.putValue(float(data["d"]))
qdumpHelper_QVariants_A = [
qdumpHelper_QVariant_0,
......@@ -1958,13 +1958,13 @@ def qdumpHelper__QVariant(d, value):
if not inner is None:
innert = inner
elif variantType == 8: # QVariant::VariantMap
inner = d.ns + "QMap<" + d.ns + "QString, " + d.ns + "QVariant>"
inner = d.ns + "QMap<" + d.ns + "QString," + d.ns + "QVariant>"
innert = d.ns + "QVariantMap"
elif variantType == 9: # QVariant::VariantList
inner = d.ns + "QList<" + d.ns + "QVariant>"
innert = d.ns + "QVariantList"
elif variantType == 28: # QVariant::VariantHash
inner = d.ns + "QHash<" + d.ns + "QString, " + d.ns + "QVariant>"
inner = d.ns + "QHash<" + d.ns + "QString," + d.ns + "QVariant>"
innert = d.ns + "QVariantHash"
elif variantType <= 86:
......@@ -1973,9 +1973,9 @@ def qdumpHelper__QVariant(d, value):
if len(inner):
innerType = d.lookupType(inner)
sizePD = d.lookupType(d.ns + 'QVariant::Private::Data').sizeof
sizePD = 8 # sizeof(QVariant::Private::Data)
if innerType.sizeof > sizePD:
sizePS = d.lookupType(d.ns + 'QVariant::PrivateShared').sizeof
sizePS = 2 * d.ptrSize() # sizeof(QVariant::PrivateShared)
val = (data.cast(d.charPtrType()) + sizePS) \
.cast(innerType.pointer()).dereference()
else:
......@@ -1995,9 +1995,14 @@ def qdump__QVariant(d, value):
if len(inner):
innerType = d.lookupType(inner)
# FIXME: Why "shared"?
if innerType.sizeof > d_data.type.sizeof:
v = d_data["shared"]["ptr"].cast(innerType.pointer()).dereference()
# FIXME:
#if int(d_ptr["is_shared"]):
# v = d_data["ptr"].cast(innerType.pointer().pointer().pointer()) \
# .dereference().dereference().dereference()
#else:
v = d_data["ptr"].cast(innerType.pointer().pointer()) \
.dereference().dereference()
else:
v = d_data.cast(innerType)
d.putEmptyValue(-99)
......@@ -2006,12 +2011,13 @@ def qdump__QVariant(d, value):
return innert
# User types.
typeCode = int(d_ptr["type"])
if gdbLoaded:
type = str(call(value, "typeToName",
"('%sQVariant::Type')%d" % (d.ns, d_ptr["type"])))
"('%sQVariant::Type')%d" % (d.ns, typeCode)))
if lldbLoaded:
type = str(call(value, "typeToName",
"(%sQVariant::Type)%d" % (d.ns, d_ptr["type"])))
"(%sQVariant::Type)%d" % (d.ns, typeCode)))
type = type[type.find('"') + 1 : type.rfind('"')]
type = type.replace("Q", d.ns + "Q") # HACK!
type = type.replace("uint", "unsigned int") # HACK!
......
......@@ -3168,20 +3168,24 @@ void tst_Dumpers::dumper_data()
"#include <QRectF>\n"
"#include <QStringList>\n"
"#include <QString>\n",
"QRect r(100, 200, 300, 400);\n"
"QRectF rf(100.5, 200.5, 300.5, 400.5);\n"
"QVariant var; // Type 0, invalid\n"
"QVariant var1(true); // 1, bool\n"
"QVariant var2(2); // 2, int\n"
"QVariant var3(3u); // 3, uint\n"
"QVariant var4(qlonglong(4)); // 4, qlonglong\n"
"QVariant var5(qulonglong(5)); // 5, qulonglong\n"
"QVariant var6(double(6)); // 6, double\n"
"QVariant var6(double(6.0)); // 6, double\n"
"QVariant var7(QChar(7)); // 7, QChar\n"
//None, # 8, QVariantMap
// None, # 9, QVariantList
"QVariant var10(QString(\"Hello 10\")); // 10, QString\n"
"QVariant var11(QStringList() << \"Hello\" << \"World\"); // 11, QStringList\n"
"QVariant var19(QRect(100, 200, 300, 400)); // 19 QRect\n"
"QVariant var20(QRectF(100.5, 200.5, 300.5, 400.5)); // 20 QRectF\n"
"QVariant var19(r); // 19 QRect\n"
"QVariant var20(rf); // 20 QRectF\n"
"unused(&var, &var1, &var2, &var3, &var4, &var5, &var6);\n"
"unused(&var, &var7, &var10, &var11, &var19, &var20);\n"
)
% CoreProfile()
% Check("var", "(invalid)", "@QVariant (invalid)")
......@@ -3190,7 +3194,7 @@ void tst_Dumpers::dumper_data()
% Check("var3", "3", "@QVariant (uint)")
% Check("var4", "4", "@QVariant (qlonglong)")
% Check("var5", "5", "@QVariant (qulonglong)")
% Check("var6", "6", "@QVariant (double)")
% Check("var6", "6.0", "@QVariant (double)")
% Check("var7", "'?' (7)", "@QVariant (QChar)")
% Check("var10", "\"Hello 10\"", "@QVariant (QString)")
% Check("var11", "<2 items>", "@QVariant (QStringList)")
......
Supports Markdown
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