qttypes.py 86.2 KB
Newer Older
hjk's avatar
hjk committed
1
2
3
4
5
6
7
8
9

#Note: Keep name-type-value-numchild-extra order

#######################################################################
#
# Dumper Implementations
#
#######################################################################

10
11
from __future__ import with_statement

hjk's avatar
hjk committed
12
13
14
15
16
def qdump__QAtomicInt(d, item):
    d.putValue(item.value["_q_value"])
    d.putNumChild(0)


17
18
19
20
21
def qdump__QBasicAtomicInt(d, item):
    d.putValue(item.value["_q_value"])
    d.putNumChild(0)


22
23
24
25
26
27
28
29
30
31
32
33
def qdump__QBasicAtomicPointer(d, item):
    innerType = templateArgument(item.value.type.unqualified(), 0)
    d.putType(item.value.type)
    p = cleanAddress(item.value["_q_value"])
    d.putValue(p)
    d.putPointerValue(item.value.address)
    d.putNumChild(p)
    if d.isExpanded(item):
        with Children(d):
           d.putItem(item.value["_q_value"])


34
def qdump__QByteArray(d, item):
35
36
    d.putByteArrayValue(item.value)

hjk's avatar
hjk committed
37
38
    d_ptr = item.value['d'].dereference()
    size = d_ptr['size']
39
    d.putNumChild(size)
hjk's avatar
hjk committed
40
41

    if d.isExpanded(item):
42
        innerType = lookupType("char")
43
44
45
46
        with Children(d, [size, 1000], innerType):
            data = d_ptr['data']
            p = gdb.Value(data.cast(innerType.pointer()))
            for i in d.childRange():
47
                d.putSubItem(Item(p.dereference(), item.iname, i))
48
                p += 1
hjk's avatar
hjk committed
49
50


51
def qdump__QChar(d, item):
hjk's avatar
hjk committed
52
    ucs = int(item.value["ucs"])
53
    d.putValue("'%c' (%d)" % (printableChar(ucs), ucs))
hjk's avatar
hjk committed
54
55
56
    d.putNumChild(0)


57
58
59

def qdump__QAbstractItemModel(d, item):
    # Create a default-constructed QModelIndex on the stack.
60
    try:
61
62
63
        ri = makeValue(d.ns + "QModelIndex", "-1, -1, 0, 0")
        this_ = makeExpression(item.value)
        ri_ = makeExpression(ri)
64
65
66
67
68
        rowCount = int(parseAndEvaluate("%s.rowCount(%s)" % (this_, ri_)))
        columnCount = int(parseAndEvaluate("%s.columnCount(%s)" % (this_, ri_)))
    except:
        d.putPlainChildren(item)
        return
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    d.putValue("%d x %d" % (rowCount, columnCount))
    d.putNumChild(rowCount * columnCount)
    if d.isExpanded(item):
        with Children(d, rowCount * columnCount, ri.type):
            i = 0
            for row in xrange(rowCount):
                for column in xrange(columnCount):
                    with SubItem(d):
                        d.putField("iname", "%s.%d" % (item.iname, i))
                        d.putName("[%s, %s]" % (row, column))
                        mi = parseAndEvaluate("%s.index(%d,%d,%s)"
                            % (this_, row, column, ri_))
                        #warn("MI: %s " % mi)
                        #name = "[%d,%d]" % (row, column)
                        #d.putValue("%s" % mi)
84
                        d.putItem(Item(mi, item.iname, i))
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
                        i = i + 1
                        #warn("MI: %s " % mi)
                        #d.putName("[%d,%d]" % (row, column))
                        #d.putValue("%s" % mi)
                        #d.putNumChild(0)
                        #d.putType(mi.type)
    #gdb.execute("call free($ri)")

def qdump__QModelIndex(d, item):
    r = item.value["r"]
    c = item.value["c"]
    p = item.value["p"]
    m = item.value["m"]
    mm = m.dereference()
    mm = mm.cast(mm.type.unqualified())
100
    try:
101
102
103
        mi = makeValue(d.ns + "QModelIndex", "%s,%s,%s,%s" % (r, c, p, m))
        mm_ = makeExpression(mm)
        mi_ = makeExpression(mi)
104
105
106
107
108
        rowCount = int(parseAndEvaluate("%s.rowCount(%s)" % (mm_, mi_)))
        columnCount = int(parseAndEvaluate("%s.columnCount(%s)" % (mm_, mi_)))
    except:
        d.putPlainChildren(item)
        return
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129

    try:
        # Access DisplayRole as value
        value = parseAndEvaluate("%s.data(%s, 0)" % (mm_, mi_))
        v = value["d"]["data"]["ptr"]
        d.putStringValue(makeValue(d.ns + 'QString', v))
    except:
        d.putValue("(invalid)")

    if r >= 0 and c >= 0 and not isNull(m):
        d.putNumChild(rowCount * columnCount)
        if d.isExpanded(item):
            with Children(d):
                i = 0
                for row in xrange(rowCount):
                    for column in xrange(columnCount):
                        with SubItem(d):
                            d.putField("iname", "%s.%d" % (item.iname, i))
                            d.putName("[%s, %s]" % (row, column))
                            mi2 = parseAndEvaluate("%s.index(%d,%d,%s)"
                                % (mm_, row, column, mi_))
130
                            d.putItem(Item(mi2, item.iname, i))
131
                            i = i + 1
hjk's avatar
hjk committed
132
                #d.putCallItem("parent", item, "parent")
133
134
135
136
137
138
139
140
141
142
143
144
145
                #with SubItem(d):
                #    d.putName("model")
                #    d.putValue(m)
                #    d.putType(d.ns + "QAbstractItemModel*")
                #    d.putNumChild(1)
    else:
        d.putValue("(invalid)")
        d.putNumChild(0)
        if d.isExpanded(item):
            with Children(d):
                pass
    #gdb.execute("call free($mi)")

hjk's avatar
hjk committed
146

147
148
149
150
151
def qdump__QDate(d, item):
    if int(item.value["jd"]) == 0:
        d.putValue("(null)")
        d.putNumChild(0)
        return
hjk's avatar
hjk committed
152
153
    qt = d.ns + "Qt::"
    d.putStringValue(call(item.value, "toString", qt + "TextDate"))
154
    d.putNumChild(1)
hjk's avatar
hjk committed
155
    if d.isExpanded(item):
156
        # FIXME: This improperly uses complex return values.
hjk's avatar
hjk committed
157
158
159
160
161
162
        with Children(d, 4):
            d.putCallItem("toString", item, "toString", qt + "TextDate")
            d.putCallItem("(ISO)", item, "toString", qt + "ISODate")
            d.putCallItem("(SystemLocale)", item, "toString",
                qt + "SystemLocaleDate")
            d.putCallItem("(Locale)", item, "toString", qt + "LocaleDate")
hjk's avatar
hjk committed
163
164


165
166
167
168
169
def qdump__QTime(d, item):
    if int(item.value["mds"]) == -1:
        d.putValue("(null)")
        d.putNumChild(0)
        return
hjk's avatar
hjk committed
170
171
    qt = d.ns + "Qt::"
    d.putStringValue(call(item.value, "toString", qt + "TextDate"))
172
173
174
175
    d.putNumChild(1)
    if d.isExpanded(item):
        # FIXME: This improperly uses complex return values.
        with Children(d, 8):
hjk's avatar
hjk committed
176
177
178
179
180
181
            d.putCallItem("toString", item, "toString", qt + "TextDate")
            d.putCallItem("(ISO)", item, "toString", qt + "ISODate")
            d.putCallItem("(SystemLocale)", item, "toString",
                 qt + "SystemLocaleDate")
            d.putCallItem("(Locale)", item, "toString", qt + "LocaleDate")
            d.putCallItem("toUTC", item, "toTimeSpec", qt + "UTC")
182
183
184


def qdump__QDateTime(d, item):
185
186
187
188
189
190
191
192
    try:
        # Fails without debug info.
        if int(item.value["d"]["d"].dereference()["time"]["mds"]) == -1:
            d.putValue("(null)")
            d.putNumChild(0)
            return
    except:
        d.putPlainChildren(item)
193
        return
hjk's avatar
hjk committed
194
195
    qt = d.ns + "Qt::"
    d.putStringValue(call(item.value, "toString", qt + "TextDate"))
196
197
198
199
    d.putNumChild(1)
    if d.isExpanded(item):
        # FIXME: This improperly uses complex return values.
        with Children(d, 8):
hjk's avatar
hjk committed
200
201
202
203
204
205
206
            d.putCallItem("toTime_t", item, "toTime_t")
            d.putCallItem("toString", item, "toString", qt + "TextDate")
            d.putCallItem("(ISO)", item, "toString", qt + "ISODate")
            d.putCallItem("(SystemLocale)", item, "toString", qt + "SystemLocaleDate")
            d.putCallItem("(Locale)", item, "toString", qt + "LocaleDate")
            d.putCallItem("toUTC", item, "toTimeSpec", qt + "UTC")
            d.putCallItem("toLocalTime", item, "toTimeSpec", qt + "LocalTime")
207
208


209
def qdump__QDir(d, item):
210
    d.putStringValue(item.value["d_ptr"]["d"].dereference()["path"])
211
    d.putNumChild(2)
hjk's avatar
hjk committed
212
    if d.isExpanded(item):
213
        with Children(d, 2):
hjk's avatar
hjk committed
214
215
            d.putCallItem("absolutePath", item, "absolutePath")
            d.putCallItem("canonicalPath", item, "canonicalPath")
hjk's avatar
hjk committed
216
217


218
def qdump__QFile(d, item):
219
220
221
222
    ptype = lookupType(d.ns + "QFilePrivate")
    d_ptr = item.value["d_ptr"]["d"].dereference()
    d.putStringValue(d_ptr.cast(ptype)["fileName"])
    d.putNumChild(1)
hjk's avatar
hjk committed
223
    if d.isExpanded(item):
224
        with Children(d, 1):
225
            d.putCallItem("exists", item, "exists()")
hjk's avatar
hjk committed
226
227


228
def qdump__QFileInfo(d, item):
229
230
231
232
233
    try:
        d.putStringValue(item.value["d_ptr"]["d"].dereference()["fileName"])
    except:
        d.putPlainChildren(item)
        return
234
    d.putNumChild(3)
hjk's avatar
hjk committed
235
    if d.isExpanded(item):
236
        with Children(d, 10, lookupType(d.ns + "QString")):
hjk's avatar
hjk committed
237
238
239
240
241
242
243
            d.putCallItem("absolutePath", item, "absolutePath")
            d.putCallItem("absoluteFilePath", item, "absoluteFilePath")
            d.putCallItem("canonicalPath", item, "canonicalPath")
            d.putCallItem("canonicalFilePath", item, "canonicalFilePath")
            d.putCallItem("completeBaseName", item, "completeBaseName")
            d.putCallItem("completeSuffix", item, "completeSuffix")
            d.putCallItem("baseName", item, "baseName")
244
245
            if False:
                #ifdef Q_OS_MACX
hjk's avatar
hjk committed
246
247
248
249
                d.putCallItem("isBundle", item, "isBundle")
                d.putCallItem("bundleName", item, "bundleName")
            d.putCallItem("fileName", item, "fileName")
            d.putCallItem("filePath", item, "filePath")
250
            # Crashes gdb (archer-tromey-python, at dad6b53fe)
hjk's avatar
hjk committed
251
252
253
            #d.putCallItem("group", item, "group")
            #d.putCallItem("owner", item, "owner")
            d.putCallItem("path", item, "path")
254

hjk's avatar
hjk committed
255
256
            d.putCallItem("groupid", item, "groupId")
            d.putCallItem("ownerid", item, "ownerId")
257
258

            #QFile::Permissions permissions () const
hjk's avatar
hjk committed
259
            perms = call(item.value, "permissions")
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
            if perms is None:
                d.putValue("<not available>")
            else:
                with SubItem(d):
                    d.putName("permissions")
                    d.putValue(" ")
                    d.putType(d.ns + "QFile::Permissions")
                    d.putNumChild(10)
                    if d.isExpandedIName(item.iname + ".permissions"):
                        with Children(d, 10):
                            perms = perms['i']
                            d.putBoolItem("ReadOwner",  perms & 0x4000)
                            d.putBoolItem("WriteOwner", perms & 0x2000)
                            d.putBoolItem("ExeOwner",   perms & 0x1000)
                            d.putBoolItem("ReadUser",   perms & 0x0400)
                            d.putBoolItem("WriteUser",  perms & 0x0200)
                            d.putBoolItem("ExeUser",    perms & 0x0100)
                            d.putBoolItem("ReadGroup",  perms & 0x0040)
                            d.putBoolItem("WriteGroup", perms & 0x0020)
                            d.putBoolItem("ExeGroup",   perms & 0x0010)
                            d.putBoolItem("ReadOther",  perms & 0x0004)
                            d.putBoolItem("WriteOther", perms & 0x0002)
                            d.putBoolItem("ExeOther",   perms & 0x0001)

            #QDir absoluteDir () const
            #QDir dir () const
hjk's avatar
hjk committed
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
            d.putCallItem("caching", item, "caching")
            d.putCallItem("exists", item, "exists")
            d.putCallItem("isAbsolute", item, "isAbsolute")
            d.putCallItem("isDir", item, "isDir")
            d.putCallItem("isExecutable", item, "isExecutable")
            d.putCallItem("isFile", item, "isFile")
            d.putCallItem("isHidden", item, "isHidden")
            d.putCallItem("isReadable", item, "isReadable")
            d.putCallItem("isRelative", item, "isRelative")
            d.putCallItem("isRoot", item, "isRoot")
            d.putCallItem("isSymLink", item, "isSymLink")
            d.putCallItem("isWritable", item, "isWritable")
            d.putCallItem("created", item, "created")
            d.putCallItem("lastModified", item, "lastModified")
            d.putCallItem("lastRead", item, "lastRead")
hjk's avatar
hjk committed
301
302


hjk's avatar
hjk committed
303
304
305
306
307
308
def qdump__QFixed(d, item):
    v = int(item.value["val"])
    d.putValue("%s/64 = %s" % (v, v/64.0))
    d.putNumChild(0)


309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# Stock gdb 7.2 seems to have a problem with types here:
#
#  echo -e "namespace N { struct S { enum E { zero, one, two }; }; }\n"\
#      "int main() { N::S::E x = N::S::one;\n return x; }" >> main.cpp
#  g++ -g main.cpp
#  gdb-7.2 -ex 'file a.out' -ex 'b main' -ex 'run' -ex 'step' \
#     -ex 'ptype N::S::E' -ex 'python print gdb.lookup_type("N::S::E")' -ex 'q'
#  gdb-7.1 -ex 'file a.out' -ex 'b main' -ex 'run' -ex 'step' \
#     -ex 'ptype N::S::E' -ex 'python print gdb.lookup_type("N::S::E")' -ex 'q'
#  gdb-cvs -ex 'file a.out' -ex 'b main' -ex 'run' -ex 'step' \
#     -ex 'ptype N::S::E' -ex 'python print gdb.lookup_type("N::S::E")' -ex 'q'
#
# gives as of 2010-11-02
#
#  type = enum N::S::E {N::S::zero, N::S::one, N::S::two} \n
hjk's avatar
hjk committed
324
325
#    Traceback (most recent call last): File "<string>", line 1,
#      in <module> RuntimeError: No type named N::S::E.
326
327
328
329
330
#  type = enum N::S::E {N::S::zero, N::S::one, N::S::two} \n  N::S::E
#  type = enum N::S::E {N::S::zero, N::S::one, N::S::two} \n  N::S::E
#
# i.e. there's something broken in stock 7.2 that is was ok in 7.1 and is ok later.

331
def qdump__QFlags(d, item):
hjk's avatar
hjk committed
332
    i = item.value["i"]
333
    try:
334
        enumType = templateArgument(item.value.type.unqualified(), 0)
335
336
337
        d.putValue("%s (%s)" % (i.cast(enumType), i))
    except:
        d.putValue("%s" % i)
hjk's avatar
hjk committed
338
339
340
    d.putNumChild(0)


341
def qdump__QHash(d, item):
hjk's avatar
hjk committed
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363

    def hashDataFirstNode(value):
        value = value.cast(hashDataType)
        bucket = value["buckets"]
        e = value.cast(hashNodeType)
        for n in xrange(value["numBuckets"] - 1, -1, -1):
            n = n - 1
            if n < 0:
                break
            if bucket.dereference() != e:
                return bucket.dereference()
            bucket = bucket + 1
        return e;

    def hashDataNextNode(node):
        next = node["next"]
        if next["next"]:
            return next
        d = node.cast(hashDataType.pointer()).dereference()
        numBuckets = d["numBuckets"]
        start = (node["h"] % numBuckets) + 1
        bucket = d["buckets"] + start
364
        for n in xrange(numBuckets - start):
hjk's avatar
hjk committed
365
366
367
368
369
            if bucket.dereference() != next:
                return bucket.dereference()
            bucket += 1
        return node

370
371
    keyType = templateArgument(item.value.type, 0)
    valueType = templateArgument(item.value.type, 1)
hjk's avatar
hjk committed
372
373
374

    d_ptr = item.value["d"]
    e_ptr = item.value["e"]
375
    size = d_ptr["size"]
hjk's avatar
hjk committed
376
377
378
379

    hashDataType = d_ptr.type
    hashNodeType = e_ptr.type

380
    check(0 <= size and size <= 100 * 1000 * 1000)
381
    checkRef(d_ptr["ref"])
hjk's avatar
hjk committed
382

383
384
    d.putItemCount(size)
    d.putNumChild(size)
hjk's avatar
hjk committed
385
386
387
388
389
    if d.isExpanded(item):
        isSimpleKey = isSimpleType(keyType)
        isSimpleValue = isSimpleType(valueType)
        node = hashDataFirstNode(item.value)
        innerType = e_ptr.dereference().type
390
391
392
393
        childType = innerType
        if isSimpleKey and isSimpleValue:
            childType = isSimpleValue
        with Children(d, [size, 1000], childType):
394
395
396
397
398
399
400
            for i in d.childRange():
                it = node.dereference().cast(innerType)
                with SubItem(d):
                    key = it["key"]
                    value = it["value"]
                    if isSimpleKey and isSimpleValue:
                        d.putName(key)
401
                        d.putItem(Item(value, item.iname, i))
402
403
                        d.putType(valueType)
                    else:
404
                        d.putItem(Item(it, item.iname, i))
405
                node = hashDataNextNode(node)
hjk's avatar
hjk committed
406
407


408
def qdump__QHashNode(d, item):
409
410
    keyType = templateArgument(item.value.type, 0)
    valueType = templateArgument(item.value.type, 1)
hjk's avatar
hjk committed
411
412
413
    key = item.value["key"]
    value = item.value["value"]

414
    if isSimpleType(keyType) and isSimpleType(valueType):
415
        d.putItem(Item(value, "data", item.iname))
hjk's avatar
hjk committed
416
    else:
417
        d.putValue(" ")
hjk's avatar
hjk committed
418

419
    d.putNumChild(2)
hjk's avatar
hjk committed
420
    if d.isExpanded(item):
421
422
423
        with Children(d):
            with SubItem(d):
                d.putName("key")
424
                d.putItem(Item(key, item.iname, "key"))
425
426
            with SubItem(d):
                d.putName("value")
427
                d.putItem(Item(value, item.iname, "value"))
hjk's avatar
hjk committed
428
429


hjk's avatar
hjk committed
430
431
432
433
434
435
436
437
438
def qdump__QHostAddress(d, item):
    data = item.value["d"]["d"].dereference()
    d.putStringValue(data["ipString"])
    d.putNumChild(1)
    if d.isExpanded(item):
        with Children(d):
           d.putFields(Item(data, item.iname))


439
def qdump__QList(d, item):
hjk's avatar
hjk committed
440
441
442
443
444
    d_ptr = item.value["d"]
    begin = d_ptr["begin"]
    end = d_ptr["end"]
    array = d_ptr["array"]
    check(begin >= 0 and end >= 0 and end <= 1000 * 1000 * 1000)
445
446
    size = end - begin
    check(size >= 0)
hjk's avatar
hjk committed
447
448
449
    #if n > 0:
    #    checkAccess(&list.front())
    #    checkAccess(&list.back())
450
    checkRef(d_ptr["ref"])
hjk's avatar
hjk committed
451
452

    # Additional checks on pointer arrays.
453
    innerType = templateArgument(item.value.type, 0)
hjk's avatar
hjk committed
454
455
456
457
    innerTypeIsPointer = innerType.code == gdb.TYPE_CODE_PTR \
        and str(innerType.target().unqualified()) != "char"
    if innerTypeIsPointer:
        p = gdb.Value(array).cast(innerType.pointer()) + begin
hjk's avatar
hjk committed
458
        checkPointerRange(p, min(size, 100))
hjk's avatar
hjk committed
459

460
461
    d.putItemCount(size)
    d.putNumChild(size)
hjk's avatar
hjk committed
462
463
464
465
466
467
468
469
    if d.isExpanded(item):
        innerSize = innerType.sizeof
        # The exact condition here is:
        #  QTypeInfo<T>::isLarge || QTypeInfo<T>::isStatic
        # but this data is available neither in the compiled binary nor
        # in the frontend.
        # So as first approximation only do the 'isLarge' check:
        isInternal = innerSize <= d_ptr.type.sizeof and d.isMovableType(innerType)
470
        dummyType = lookupType("void").pointer().pointer()
471
472
        innerTypePointer = innerType.pointer()
        p = gdb.Value(array).cast(dummyType) + begin
473
474
475
476
        if innerTypeIsPointer:
            inner = innerType.target()
        else:
            inner = innerType
477
        # about 0.5s / 1000 items
478
479
480
        with Children(d, [size, 2000], inner):
            for i in d.childRange():
                if isInternal:
481
                    pp = p.cast(innerTypePointer).dereference();
482
                    d.putSubItem(Item(pp, item.iname, i))
483
                else:
484
                    pp = p.cast(innerTypePointer.pointer()).dereference()
485
                    d.putSubItem(Item(pp, item.iname, i))
486
                p += 1
hjk's avatar
hjk committed
487

hjk's avatar
hjk committed
488
489
def qform__QImage():
    return "Normal,Displayed"
hjk's avatar
hjk committed
490

491
def qdump__QImage(d, item):
492
493
494
495
496
    try:
        painters = item.value["painters"]
    except:
        d.putPlainChildren(item)
        return
hjk's avatar
hjk committed
497
498
499
    check(0 <= painters and painters < 1000)
    d_ptr = item.value["d"]
    if isNull(d_ptr):
500
        d.putValue("(null)")
hjk's avatar
hjk committed
501
    else:
502
        checkRef(d_ptr["ref"])
503
        d.putValue("(%dx%d)" % (d_ptr["width"], d_ptr["height"]))
504
505
    bits = d_ptr["data"]
    nbytes = d_ptr["nbytes"]
506
    d.putNumChild(0)
hjk's avatar
hjk committed
507
508
    #d.putNumChild(1)
    if d.isExpanded(item):
509
510
511
        with Children(d):
            with SubItem(d):
                d.putName("data")
512
                d.putNoType()
513
514
                d.putNumChild(0)
                d.putValue("size: %s bytes" % nbytes);
515
    format = d.itemFormat(item)
516
    if format == 1:
517
        d.putDisplay(StopDisplay)
518
    elif format == 2:
hjk's avatar
hjk committed
519
520
521
522
        if False:
            # Take four bytes at a time, this is critical for performance.
            # In fact, even four at a time is too slow beyond 100x100 or so.
            d.putField("editformat", 1)  # Magic marker for direct "QImage" data.
523
            d.put('%s="' % name)
hjk's avatar
hjk committed
524
525
526
            d.put("%08x" % int(d_ptr["width"]))
            d.put("%08x" % int(d_ptr["height"]))
            d.put("%08x" % int(d_ptr["format"]))
527
            p = bits.cast(lookupType("unsigned int").pointer())
hjk's avatar
hjk committed
528
529
530
            for i in xrange(nbytes / 4):
                d.put("%08x" % int(p.dereference()))
                p += 1
531
            d.put('",')
hjk's avatar
hjk committed
532
533
534
        else:
            # Write to an external file. Much faster ;-(
            file = tempfile.mkstemp(prefix="gdbpy_")
535
            filename = file[1].replace("\\", "\\\\")
536
            p = bits.cast(lookupType("unsigned char").pointer())
hjk's avatar
hjk committed
537
538
            gdb.execute("dump binary memory %s %s %s" %
                (filename, cleanAddress(p), cleanAddress(p + nbytes)))
539
540
            d.putDisplay(DisplayImage, " %d %d %d %s"
                % (d_ptr["width"], d_ptr["height"], d_ptr["format"], filename))
hjk's avatar
hjk committed
541
542


543
def qdump__QLinkedList(d, item):
hjk's avatar
hjk committed
544
545
    d_ptr = item.value["d"]
    e_ptr = item.value["e"]
546
    n = d_ptr["size"]
hjk's avatar
hjk committed
547
    check(0 <= n and n <= 100*1000*1000)
548
    checkRef(d_ptr["ref"])
hjk's avatar
hjk committed
549
    d.putItemCount(n)
550
    d.putNumChild(n)
hjk's avatar
hjk committed
551
    if d.isExpanded(item):
552
        innerType = templateArgument(item.value.type, 0)
553
        with Children(d, [n, 1000], innerType):
554
555
            p = e_ptr["n"]
            for i in d.childRange():
556
                d.putSubItem(Item(p["t"], item.iname, i))
557
                p = p["n"]
hjk's avatar
hjk committed
558
559


560
def qdump__QLocale(d, item):
hjk's avatar
hjk committed
561
    d.putStringValue(call(item.value, "name"))
562
563
564
    d.putNumChild(0)
    return
    # FIXME: Poke back for variants.
hjk's avatar
hjk committed
565
    if d.isExpanded(item):
566
        with Children(d, 1, lookupType(d.ns + "QChar"), 0):
hjk's avatar
hjk committed
567
568
569
570
            d.putCallItem("country", item, "country")
            d.putCallItem("language", item, "language")
            d.putCallItem("measurementSystem", item, "measurementSystem")
            d.putCallItem("numberOptions", item, "numberOptions")
571
            d.putCallItem("timeFormat_(short)", item,
hjk's avatar
hjk committed
572
                "timeFormat", d.ns + "QLocale::ShortFormat")
573
            d.putCallItem("timeFormat_(long)", item,
hjk's avatar
hjk committed
574
575
576
577
578
579
580
                "timeFormat", d.ns + "QLocale::LongFormat")
            d.putCallItem("decimalPoint", item, "decimalPoint")
            d.putCallItem("exponential", item, "exponential")
            d.putCallItem("percent", item, "percent")
            d.putCallItem("zeroDigit", item, "zeroDigit")
            d.putCallItem("groupSeparator", item, "groupSeparator")
            d.putCallItem("negativeSign", item, "negativeSign")
hjk's avatar
hjk committed
581
582


583
def qdump__QMapNode(d, item):
584
585
    d.putValue(" ")
    d.putNumChild(2)
hjk's avatar
hjk committed
586
    if d.isExpanded(item):
587
588
589
        with Children(d, 2):
            with SubItem(d):
                d.putName("key")
590
                d.putItem(Item(item.value["key"], item.iname, "name"))
591
592
            with SubItem(d):
                d.putName("value")
593
                d.putItem(Item(item.value["value"], item.iname, "value"))
hjk's avatar
hjk committed
594
595


hjk's avatar
hjk committed
596
def qdumpHelper__QMap(d, item, forceLong):
hjk's avatar
hjk committed
597
598
599
600
    d_ptr = item.value["d"].dereference()
    e_ptr = item.value["e"].dereference()
    n = d_ptr["size"]
    check(0 <= n and n <= 100*1000*1000)
601
    checkRef(d_ptr["ref"])
hjk's avatar
hjk committed
602
603

    d.putItemCount(n)
604
    d.putNumChild(n)
hjk's avatar
hjk committed
605
606
607
608
    if d.isExpanded(item):
        if n > 1000:
            n = 1000

609
610
        keyType = templateArgument(item.value.type, 0)
        valueType = templateArgument(item.value.type, 1)
hjk's avatar
hjk committed
611
612
613
614
615
616
617
618
619

        isSimpleKey = isSimpleType(keyType)
        isSimpleValue = isSimpleType(valueType)

        it = e_ptr["forward"].dereference()

        # QMapPayloadNode is QMapNode except for the 'forward' member, so
        # its size is most likely the offset of the 'forward' member therein.
        # Or possibly 2 * sizeof(void *)
620
621
622
        nodeType = lookupType(d.ns + "QMapNode<%s, %s>" % (keyType, valueType))
        payloadSize = nodeType.sizeof - 2 * lookupType("void").pointer().sizeof
        charPtr = lookupType("char").pointer()
hjk's avatar
hjk committed
623

624
625
626
627
        if isSimpleKey and isSimpleValue:
            innerType = valueType
        else:
            innerType = nodeType
hjk's avatar
hjk committed
628

629
630
631
632
633
634
635
636
        with Children(d, n, innerType):
            for i in xrange(n):
                itd = it.dereference()
                base = it.cast(charPtr) - payloadSize
                node = base.cast(nodeType.pointer()).dereference()
                with SubItem(d):
                    key = node["key"]
                    value = node["value"]
hjk's avatar
hjk committed
637
638
                    #if isSimpleType(item.value.type):
                    # or isStringType(d, item.value.type):
639
640
                    if isSimpleKey and isSimpleValue:
                        #d.putType(valueType)
hjk's avatar
hjk committed
641
642
643
644
                        if forceLong:
                            d.putName("[%s] %s" % (i, key))
                        else:
                            d.putName(key)
645
                        d.putItem(Item(value, item.iname, i))
646
                    else:
647
                        d.putItem(Item(node, item.iname, i))
648
                it = it.dereference()["forward"].dereference()
hjk's avatar
hjk committed
649
650


hjk's avatar
hjk committed
651
652
653
654
655
def qdump__QMap(d, item):
    qdumpHelper__QMap(d, item, False)

def qdump__QMultiMap(d, item):
    qdumpHelper__QMap(d, item, True)
hjk's avatar
hjk committed
656
657
658
659
660
661
662
663
664
665
666
667
668


def extractCString(table, offset):
    result = ""
    while True:
        d = table[offset]
        if d == 0:
            break
        result += "%c" % d
        offset += 1
    return result


669
def qdump__QObject(d, item):
hjk's avatar
hjk committed
670
    #warn("OBJECT: %s " % item.value)
671
    try:
672
        privateTypeName = d.ns + "QObjectPrivate"
673
        privateType = lookupType(privateTypeName)
674
        staticMetaObject = item.value["staticMetaObject"]
675
676
677
        d_ptr = item.value["d_ptr"]["d"].cast(privateType.pointer()).dereference()
        #warn("D_PTR: %s " % d_ptr)
        objectName = d_ptr["objectName"]
678
679
680
    except:
        d.putPlainChildren(item)
        return
hjk's avatar
hjk committed
681
    #warn("SMO: %s " % staticMetaObject)
682
683
684
685
686
687
688
    #warn("SMO DATA: %s " % staticMetaObject["d"]["stringdata"])
    superData = staticMetaObject["d"]["superdata"]
    #warn("SUPERDATA: %s" % superData)
    #while not isNull(superData):
    #    superData = superData.dereference()["d"]["superdata"]
    #    warn("SUPERDATA: %s" % superData)

689
690
691
692
693
694
695
    if privateType is None:
        d.putNumChild(4)
        #d.putValue(cleanAddress(item.value.address))
        if d.isExpanded(item):
            with Children(d):
                d.putFields(item)
        return
hjk's avatar
hjk committed
696
    #warn("OBJECTNAME: %s " % objectName)
697
    #warn("D_PTR: %s " % d_ptr)
hjk's avatar
hjk committed
698
699
700
701
702
703
704
    mo = d_ptr["metaObject"]
    if isNull(mo):
        mo = staticMetaObject
    #warn("MO: %s " % mo)
    #warn("MO.D: %s " % mo["d"])
    metaData = mo["d"]["data"]
    metaStringData = mo["d"]["stringdata"]
705
    #extradata = mo["d"]["extradata"]   # Capitalization!
hjk's avatar
hjk committed
706
707
708
    #warn("METADATA: %s " % metaData)
    #warn("STRINGDATA: %s " % metaStringData)
    #warn("TYPE: %s " % item.value.type)
709
    #warn("INAME: %s " % item.iname)
710
711
    #d.putValue("")
    d.putStringValue(objectName)
hjk's avatar
hjk committed
712
    #QSignalMapper::staticMetaObject
713
    #checkRef(d_ptr["ref"])
hjk's avatar
hjk committed
714
715
    d.putNumChild(4)
    if d.isExpanded(item):
716
      with Children(d):
717
718
719
720
721
722
723

        # Local data
        if privateTypeName != d.ns + "QObjectPrivate":
            if not privateType is None:
              with SubItem(d):
                d.putName("data")
                d.putValue(" ")
724
                d.putNoType()
725
726
727
728
                d.putNumChild(1)
                iname = item.iname + ".data"
                if d.isExpandedIName(iname):
                    with Children(d):
729
730
                        child = Item(d_ptr, iname)
                        d.putFields(child, False)
731
732


hjk's avatar
hjk committed
733
        d.putFields(item)
734
        # Parent and children.
735
        if stripClassTag(str(item.value.type)) == d.ns + "QObject":
736
737
            d.putSubItem(Item(d_ptr["parent"], item.iname, "parent", "parent"))
            d.putSubItem(Item(d_ptr["children"], item.iname, "children", "children"))
hjk's avatar
hjk committed
738

739
        # Properties.
740
        with SubItem(d):
741
            # Prolog
742
743
            extraData = d_ptr["extraData"]   # Capitalization!
            if isNull(extraData):
744
                dynamicPropertyCount = 0
745
            else:
746
                extraDataType = lookupType(
747
748
749
750
751
752
753
754
755
                    d.ns + "QObjectPrivate::ExtraData").pointer()
                extraData = extraData.cast(extraDataType)
                ed = extraData.dereference()
                names = ed["propertyNames"]
                values = ed["propertyValues"]
                #userData = ed["userData"]
                namesBegin = names["d"]["begin"]
                namesEnd = names["d"]["end"]
                namesArray = names["d"]["array"]
756
757
                dynamicPropertyCount = namesEnd - namesBegin

hjk's avatar
hjk committed
758
            #staticPropertyCount = call(mo, "propertyCount")
759
            staticPropertyCount = metaData[6]
760
761
762
763
            #warn("PROPERTY COUNT: %s" % staticPropertyCount)
            propertyCount = staticPropertyCount + dynamicPropertyCount

            d.putName("properties")
764
            d.putNoType()
765
766
767
768
            d.putItemCount(propertyCount)
            d.putNumChild(propertyCount)

            if d.isExpandedIName(item.iname + ".properties"):
769
770
                # FIXME: Make this global. Don't leak.
                variant = "'%sQVariant'" % d.ns
771
                # Avoid malloc symbol clash with QVector
hjk's avatar
hjk committed
772
773
                gdb.execute("set $d = (%s*)calloc(sizeof(%s), 1)"
                    % (variant, variant))
774
                gdb.execute("set $d.d.is_shared = 0")
775

776
                with Children(d, [propertyCount, 500]):
777
                    # Dynamic properties.
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
                    if dynamicPropertyCount != 0:
                        dummyType = lookupType("void").pointer().pointer()
                        namesType = lookupType(d.ns + "QByteArray")
                        valuesBegin = values["d"]["begin"]
                        valuesEnd = values["d"]["end"]
                        valuesArray = values["d"]["array"]
                        valuesType = lookupType(d.ns + "QVariant")
                        p = namesArray.cast(dummyType) + namesBegin
                        q = valuesArray.cast(dummyType) + valuesBegin
                        for i in xrange(dynamicPropertyCount):
                            with SubItem(d):
                                pp = p.cast(namesType.pointer()).dereference();
                                d.putField("key", encodeByteArray(pp))
                                d.putField("keyencoded", Hex2EncodedLatin1)
                                qq = q.cast(valuesType.pointer().pointer())
                                qq = qq.dereference();
                                d.putField("addr", cleanAddress(qq))
795
796
                                d.putField("exp", "*(%s*)%s"
                                     % (variant, cleanAddress(qq)))
797
798
799
                                name = "%s.properties.%d" % (item.iname, i)
                                t = qdump__QVariant(d, Item(qq, name))
                                # Override the "QVariant (foo)" output
hjk's avatar
hjk committed
800
                                d.putBetterType(t)
801
802
                            p += 1
                            q += 1
803
804
805
806

                    # Static properties.
                    propertyData = metaData[7]
                    for i in xrange(staticPropertyCount):
807
                      with NoAddress(d):
808
                        with SubItem(d):
809
                            offset = propertyData + 3 * i
hjk's avatar
hjk committed
810
811
812
813
                            propertyName = extractCString(metaStringData,
                                                          metaData[offset])
                            propertyType = extractCString(metaStringData,
                                                          metaData[offset + 1])
814
815
816
817
818
819
                            d.putName(propertyName)
                            #flags = metaData[offset + 2]
                            #warn("FLAGS: %s " % flags)
                            #warn("PROPERTY: %s %s " % (propertyType, propertyName))
                            # #exp = '((\'%sQObject\'*)%s)->property("%s")' \
                            #     % (d.ns, item.value.address, propertyName)
hjk's avatar
hjk committed
820
821
                            #exp = '"((\'%sQObject\'*)%s)"' %
                            #(d.ns, item.value.address,)
822
                            #warn("EXPRESSION:  %s" % exp)
hjk's avatar
hjk committed
823
824
                            value = call(item.value, "property",
                                str(cleanAddress(metaStringData + metaData[offset])))
825
826
                            value1 = value["d"]
                            #warn("   CODE: %s" % value1["type"])
hjk's avatar
hjk committed
827
828
                            # Type 1 and 2 are bool and int.
                            # Try to save a few cycles in this case:
829
830
                            if int(value1["type"]) > 2:
                                # Poke back value
hjk's avatar
hjk committed
831
832
833
834
835
836
                                gdb.execute("set $d.d.data.ull = %s"
                                        % value1["data"]["ull"])
                                gdb.execute("set $d.d.type = %s"
                                        % value1["type"])
                                gdb.execute("set $d.d.is_null = %s"
                                        % value1["is_null"])
837
                                value = parseAndEvaluate("$d").dereference()
hjk's avatar
hjk committed
838
839
840
841
842
843
                            val, inner, innert, handled = \
                                qdumpHelper__QVariant(d, value)

                            if handled:
                                pass
                            elif len(inner):
844
845
                                # Build-in types.
                                d.putType(inner)
hjk's avatar
hjk committed
846
847
                                name = "%s.properties.%d" \
                                    % (item.iname, i + dynamicPropertyCount)
848
                                d.putItem(Item(val, item.iname + ".properties",
849
850
851
852
                                                    propertyName, propertyName))

                            else:
                                # User types.
853
854
                           #    func = "typeToName(('%sQVariant::Type')%d)"
                           #       % (d.ns, variantType)
855
856
857
                           #    type = str(call(item.value, func))
                           #    type = type[type.find('"') + 1 : type.rfind('"')]
                           #    type = type.replace("Q", d.ns + "Q") # HACK!
hjk's avatar
hjk committed
858
                           #    data = call(item.value, "constData")
859
860
                           #    tdata = data.cast(lookupType(type).pointer())
                           #      .dereference()
861
862
863
864
865
                           #    d.putValue("(%s)" % tdata.type)
                           #    d.putType(tdata.type)
                           #    d.putNumChild(1)
                           #    if d.isExpanded(item):
                           #        with Children(d):
866
867
868
                           #           d.putSubItem(Item(tdata, item.iname,
                           #             "data", "data"))
                                warn("FIXME: CUSTOM QOBJECT PROPERTY: %s %s"
869
870
871
872
873
                                    % (propertyType, innert))
                                d.putType(propertyType)
                                d.putValue("...")
                                d.putNumChild(0)

874
875
876
        # Connections.
        with SubItem(d):
            d.putName("connections")
877
            d.putNoType()
878
879
880
881
            connections = d_ptr["connectionLists"]
            connectionListCount = 0
            if not isNull(connections):
                connectionListCount = connections["d"]["size"]
882
            d.putItemCount(connectionListCount, 0)
883
884
885
886
            d.putNumChild(connectionListCount)
            if d.isExpandedIName(item.iname + ".connections"):
                with Children(d):
                    vectorType = connections.type.target().fields()[0].type
887
                    innerType = templateArgument(vectorType, 0)
888
889
890
891
892
893
                    # Should check:  innerType == ns::QObjectPrivate::ConnectionList
                    p = gdb.Value(connections["p"]["array"]).cast(innerType.pointer())
                    pp = 0
                    for i in xrange(connectionListCount):
                        first = p.dereference()["first"]
                        while not isNull(first):
hjk's avatar
hjk committed
894
895
                            d.putSubItem(Item(first.dereference(),
                                item.iname + ".connections", pp))
896
897
898
899
900
901
902
                            first = first["next"]
                            # We need to enforce some upper limit.
                            pp += 1
                            if pp > 1000:
                                break
                        p += 1

hjk's avatar
hjk committed
903

904
        # Signals
hjk's avatar
hjk committed
905
        signalCount = metaData[13]
906
907
908
        with SubItem(d):
            d.putName("signals")
            d.putItemCount(signalCount)
909
            d.putNoType()
910
911
912
913
914
915
916
917
918
919
            d.putNumChild(signalCount)
            if signalCount:
                # FIXME: empty type does not work for childtype
                #d.putField("childtype", ".")
                d.putField("childnumchild", "0")
            if d.isExpandedIName(item.iname + ".signals"):
                with Children(d):
                    for signal in xrange(signalCount):
                        with SubItem(d):
                            offset = metaData[14 + 5 * signal]
hjk's avatar
hjk committed
920
921
                            d.putField("iname", "%s.signals.%d"
                                % (item.iname, signal))
922
                            d.putName("signal %d" % signal)
923
                            d.putNoType()
924
                            d.putValue(extractCString(metaStringData, offset))
925
                            d.putNumChild(0)  # FIXME: List the connections here.
hjk's avatar
hjk committed
926

927
        # Slots
928
929
930
931
        with SubItem(d):
            slotCount = metaData[4] - signalCount
            d.putName("slots")
            d.putItemCount(slotCount)
932
            d.putNoType()
933
934
935
936
937
938
939
940
941
942
943
            d.putNumChild(slotCount)
            if slotCount:
                #d.putField("childtype", ".")
                d.putField("childnumchild", "0")
            if d.isExpandedIName(item.iname + ".slots"):
                with Children(d):
                    for slot in xrange(slotCount):
                        with SubItem(d):
                            offset = metaData[14 + 5 * (signalCount + slot)]
                            d.putField("iname", "%s.slots.%d" % (item.iname, slot))
                            d.putName("slot %d" % slot)
944
                            d.putNoType()
945
                            d.putValue(extractCString(metaStringData, offset))
946
                            d.putNumChild(0)  # FIXME: List the connections here.
hjk's avatar
hjk committed
947

948
949
950
        # Active connection
        with SubItem(d):
            d.putName("currentSender")
951
            d.putNoType()
952
953
954
955
956
957
958
959
960
961
            sender = d_ptr["currentSender"]
            d.putValue(cleanAddress(sender))
            if isNull(sender):
                d.putNumChild(0)
            else:
                d.putNumChild(1)
                iname = item.iname + ".currentSender"
                if d.isExpandedIName(iname):
                    with Children(d):
                        # Sending object
962
                        d.putSubItem(Item(sender["sender"], iname, "object", "object"))
963
964
965
966
                        # Signal in sending object
                        with SubItem(d):
                            d.putName("signal")
                            d.putValue(sender["signal"])
967
                            d.putNoType()
968
969
                            d.putNumChild(0)

hjk's avatar
hjk committed
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
# QObject

#   static const uint qt_meta_data_QObject[] = {

#   int revision;
#   int className;
#   int classInfoCount, classInfoData;
#   int methodCount, methodData;
#   int propertyCount, propertyData;
#   int enumeratorCount, enumeratorData;
#   int constructorCount, constructorData; //since revision 2
#   int flags; //since revision 3
#   int signalCount; //since revision 4

#    // content:
#          4,       // revision
#          0,       // classname
#          0,    0, // classinfo
#          4,   14, // methods
#          1,   34, // properties
#          0,    0, // enums/sets
#          2,   37, // constructors
#          0,       // flags
#          2,       // signalCount

#  /* 14 */

#    // signals: signature, parameters, type, tag, flags
#          9,    8,    8,    8, 0x05,
#         29,    8,    8,    8, 0x25,

#  /* 24 */
#    // slots: signature, parameters, type, tag, flags
#         41,    8,    8,    8, 0x0a,
#         55,    8,    8,    8, 0x08,

#  /* 34 */
#    // properties: name, type, flags
#         90,   82, 0x0a095103,

#  /* 37 */
#    // constructors: signature, parameters, type, tag, flags
#        108,  101,    8,    8, 0x0e,
#        126,    8,    8,    8, 0x2e,

#          0        // eod
#   };

#   static const char qt_meta_stringdata_QObject[] = {
#       "QObject\0\0destroyed(QObject*)\0destroyed()\0"
#       "deleteLater()\0_q_reregisterTimers(void*)\0"
#       "QString\0objectName\0parent\0QObject(QObject*)\0"
#       "QObject()\0"
#   };


# QSignalMapper

#   static const uint qt_meta_data_QSignalMapper[] = {

#    // content:
#          4,       // revision
#          0,       // classname
#          0,    0, // classinfo
#          7,   14, // methods
#          0,    0, // properties
#          0,    0, // enums/sets
#          0,    0, // constructors
#          0,       // flags
#          4,       // signalCount

#    // signals: signature, parameters, type, tag, flags
#         15,   14,   14,   14, 0x05,
#         27,   14,   14,   14, 0x05,
#         43,   14,   14,   14, 0x05,
#         60,   14,   14,   14, 0x05,

#    // slots: signature, parameters, type, tag, flags
#         77,   14,   14,   14, 0x0a,
#         90,   83,   14,   14, 0x0a,
#        104,   14,   14,   14, 0x08,

#          0        // eod
#   };

#   static const char qt_meta_stringdata_QSignalMapper[] = {
#       "QSignalMapper\0\0mapped(int)\0mapped(QString)\0"
#       "mapped(QWidget*)\0mapped(QObject*)\0"
#       "map()\0sender\0map(QObject*)\0"
#       "_q_senderDestroyed()\0"
#   };

#   const QMetaObject QSignalMapper::staticMetaObject = {
#       { &QObject::staticMetaObject, qt_meta_stringdata_QSignalMapper,
#         qt_meta_data_QSignalMapper, 0 }
#   };



# static const char *sizePolicyEnumValue(QSizePolicy::Policy p)
# {
#     switch (p) {
#     case QSizePolicy::Fixed:
#         return "Fixed"
#     case QSizePolicy::Minimum:
#         return "Minimum"
#     case QSizePolicy::Maximum:
#         return "Maximum"
#     case QSizePolicy::Preferred:
#         return "Preferred"
#     case QSizePolicy::Expanding:
#         return "Expanding"
#     case QSizePolicy::MinimumExpanding:
#         return "MinimumExpanding"
#     case QSizePolicy::Ignored:
#         break
#     }
#     return "Ignored"
# }
#
# static QString sizePolicyValue(const QSizePolicy &sp)
# {
#     QString rc
#     QTextStream str(&rc)
#     // Display as in Designer
#     str << '[' << sizePolicyEnumValue(sp.horizontalPolicy())
#         << ", " << sizePolicyEnumValue(sp.verticalPolicy())
#         << ", " << sp.horizontalStretch() << ", " << sp.verticalStretch() << ']'
#     return rc
# }
# #endif
#
# // Meta enumeration helpers
# static inline void dumpMetaEnumType(QDumper &d, const QMetaEnum &me)
# {
#     QByteArray type = me.scope()
#     if !type.isEmpty())
#         type += "::"
#     type += me.name()
#     d.putField("type", type.constData())
# }
#
# static inline void dumpMetaEnumValue(QDumper &d, const QMetaProperty &mop,
#                                      int value)
# {
#
#     const QMetaEnum me = mop.enumerator()
#     dumpMetaEnumType(d, me)
#     if const char *enumValue = me.valueToKey(value)) {
1119
#         d.putValue(enumValue)
hjk's avatar
hjk committed
1120
#     } else {
1121
#         d.putValue(value)
hjk's avatar
hjk committed
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
#     }
#     d.putField("numchild", 0)
# }
#
# static inline void dumpMetaFlagValue(QDumper &d, const QMetaProperty &mop,
#                                      int value)
# {
#     const QMetaEnum me = mop.enumerator()
#     dumpMetaEnumType(d, me)
#     const QByteArray flagsValue = me.valueToKeys(value)
1132
1133
1134
1135
1136
#     if flagsValue.isEmpty():
#         d.putValue(value)
#     else:
#         d.putValue(flagsValue.constData())
#     d.putNumChild(0)
hjk's avatar
hjk committed
1137
1138
# }

1139
def qdump__QPixmap(d, item):
hjk's avatar
hjk committed
1140
1141
1142
1143
    painters = item.value["painters"]
    check(0 <= painters and painters < 1000)
    d_ptr = item.value["data"]["d"]
    if isNull(d_ptr):