-
Notifications
You must be signed in to change notification settings - Fork 1
/
stdtypes.py
1355 lines (1043 loc) · 41.3 KB
/
stdtypes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
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
############################################################################
#
# Copyright (C) 2016 The Qt Company Ltd.
# Contact: https://www.qt.io/licensing/
#
# This file is part of Qt Creator.
#
# Commercial License Usage
# Licensees holding valid commercial Qt licenses may use this file in
# accordance with the commercial license agreement provided with the
# Software or, alternatively, in accordance with the terms contained in
# a written agreement between you and The Qt Company. For licensing terms
# and conditions see https://www.qt.io/terms-conditions. For further
# information use the contact form at https://www.qt.io/contact-us.
#
# GNU General Public License Usage
# Alternatively, this file may be used under the terms of the GNU
# General Public License version 3 as published by the Free Software
# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
# included in the packaging of this file. Please review the following
# information to ensure the GNU General Public License requirements will
# be met: https://www.gnu.org/licenses/gpl-3.0.html.
#
############################################################################
from utils import DisplayFormat
from dumper import Children, SubItem
def qform__std__array():
return [DisplayFormat.ArrayPlot]
def qdump__std__array(d, value):
size = value.type[1]
d.putItemCount(size)
if d.isExpanded():
d.putPlotData(value.address(), size, value.type[0])
def qform__std____1__array():
return [DisplayFormat.ArrayPlot]
def qdump__std____1__array(d, value):
qdump__std__array(d, value)
def qdump__std__function(d, value):
(ptr, dummy1, manager, invoker) = value.split('pppp')
if manager:
if ptr > 2:
d.putSymbolValue(ptr)
else:
d.putEmptyValue()
d.putBetterType(value.type)
else:
d.putValue('(null)')
d.putPlainChildren(value)
def qdump__std__complex(d, value):
innerType = value.type[0]
(real, imag) = value.split('{%s}{%s}' % (innerType.name, innerType.name))
d.putValue("(%s, %s)" % (real.display(), imag.display()))
d.putExpandable()
if d.isExpanded():
with Children(d, 2, childType=innerType):
d.putSubItem("real", real)
d.putSubItem("imag", imag)
def qdump__std____1__complex(d, value):
qdump__std__complex(d, value)
def qdump__std__deque(d, value):
if d.isQnxTarget():
qdumpHelper__std__deque__qnx(d, value)
elif d.isMsvcTarget():
qdumpHelper__std__deque__msvc(d, value)
elif value.hasMember("_M_impl"):
qdumpHelper__std__deque__libstdcxx(d, value)
elif value.hasMember("__start_"):
qdumpHelper__std__deque__libcxx(d, value)
elif value.type.size() == 10 * d.ptrSize():
qdumpHelper__std__deque__libstdcxx(d, value)
elif value.type.size() == 6 * d.ptrSize():
qdumpHelper__std__deque__libcxx(d, value)
else:
qdumpHelper__std__deque__libstdcxx(d, value)
def qdump__std____1__deque(d, value):
qdumpHelper__std__deque__libcxx(d, value)
def qdumpHelper__std__deque__libstdcxx(d, value):
innerType = value.type[0]
innerSize = innerType.size()
bufsize = 1
if innerSize < 512:
bufsize = 512 // innerSize
(mapptr, mapsize, startCur, startFirst, startLast, startNode,
finishCur, finishFirst, finishLast, finishNode) = value.split("pppppppppp")
size = bufsize * ((finishNode - startNode) // d.ptrSize() - 1)
size += (finishCur - finishFirst) // innerSize
size += (startLast - startCur) // innerSize
d.check(0 <= size and size <= 1000 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
with Children(d, size, maxNumChild=2000, childType=innerType):
pcur = startCur
plast = startLast
pnode = startNode
for i in d.childRange():
d.putSubItem(i, d.createValue(pcur, innerType))
pcur += innerSize
if pcur == plast:
newnode = pnode + d.ptrSize()
pfirst = d.extractPointer(newnode)
plast = pfirst + bufsize * d.ptrSize()
pcur = pfirst
pnode = newnode
def qdumpHelper__std__deque__libcxx(d, value):
mptr, mfirst, mbegin, mend, start, size = value.split("pppptt")
d.check(0 <= size and size <= 1000 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
innerType = value.type[0]
innerSize = innerType.size()
ptrSize = d.ptrSize()
bufsize = (4096 // innerSize) if innerSize < 256 else 16
with Children(d, size, maxNumChild=2000, childType=innerType):
for i in d.childRange():
k, j = divmod(start + i, bufsize)
base = d.extractPointer(mfirst + k * ptrSize)
d.putSubItem(i, d.createValue(base + j * innerSize, innerType))
def qdumpHelper__std__deque__qnx(d, value):
innerType = value.type[0]
innerSize = innerType.size()
if innerSize <= 1:
bufsize = 16
elif innerSize <= 2:
bufsize = 8
elif innerSize <= 4:
bufsize = 4
elif innerSize <= 8:
bufsize = 2
else:
bufsize = 1
try:
val = value['_Mypair']['_Myval2']
except:
val = value
myoff = val['_Myoff'].integer()
mysize = val['_Mysize'].integer()
mapsize = val['_Mapsize'].integer()
d.check(0 <= mapsize and mapsize <= 1000 * 1000 * 1000)
d.putItemCount(mysize)
if d.isExpanded():
with Children(d, mysize, maxNumChild=2000, childType=innerType):
map = val['_Map']
for i in d.childRange():
block = myoff / bufsize
offset = myoff - (block * bufsize)
if mapsize <= block:
block -= mapsize
d.putSubItem(i, map[block][offset])
myoff += 1
def qdumpHelper__std__deque__msvc(d, value):
innerType = value.type[0]
innerSize = innerType.size()
if innerSize <= 1:
bufsize = 16
elif innerSize <= 2:
bufsize = 8
elif innerSize <= 4:
bufsize = 4
elif innerSize <= 8:
bufsize = 2
else:
bufsize = 1
(proxy, map, mapsize, myoff, mysize) = value.split("ppppp")
d.check(0 <= mapsize and mapsize <= 1000 * 1000 * 1000)
d.putItemCount(mysize)
if d.isExpanded():
with Children(d, mysize, maxNumChild=2000, childType=innerType):
for i in d.childRange():
if myoff >= bufsize * mapsize:
myoff = 0
buf = map + ((myoff // bufsize) * d.ptrSize())
address = d.extractPointer(buf) + ((myoff % bufsize) * innerSize)
d.putSubItem(i, d.createValue(address, innerType))
myoff += 1
def qdump__std____debug__deque(d, value):
qdump__std__deque(d, value)
def qdump__std__list(d, value):
if d.isQnxTarget() or d.isMsvcTarget():
qdump__std__list__QNX(d, value)
return
if value.type.size() == 3 * d.ptrSize():
# C++11 only.
(dummy1, dummy2, size) = value.split("ppp")
d.putItemCount(size)
else:
# Need to count manually.
p = d.extractPointer(value)
head = value.address()
size = 0
while head != p and size < 1001:
size += 1
p = d.extractPointer(p)
d.putItemCount(size, 1000)
if d.isExpanded():
p = d.extractPointer(value)
innerType = value.type[0]
with Children(d, size, maxNumChild=1000, childType=innerType):
for i in d.childRange():
d.putSubItem(i, d.createValue(p + 2 * d.ptrSize(), innerType))
p = d.extractPointer(p)
def qdump__std__list__QNX(d, value):
try:
_ = value["_Mypair"]["_Myval2"]["_Myproxy"]
(proxy, head, size) = value.split("ppp")
except Exception:
(head, size) = value.split("pp")
d.putItemCount(size, 1000)
if d.isExpanded():
p = d.extractPointer(head)
innerType = value.type[0]
with Children(d, size, maxNumChild=1000, childType=innerType):
for i in d.childRange():
d.putSubItem(i, d.createValue(p + 2 * d.ptrSize(), innerType))
p = d.extractPointer(p)
def qdump__std____debug__list(d, value):
qdump__std__list(d, value)
def qdump__std____cxx11__list(d, value):
qdump__std__list(d, value)
def qdump__std____1__list(d, value):
if value.type.size() == 3 * d.ptrSize():
# C++11 only.
(dummy1, dummy2, size) = value.split("ppp")
d.putItemCount(size)
else:
# Need to count manually.
p = d.extractPointer(value)
head = value.address()
size = 0
while head != p and size < 1001:
size += 1
p = d.extractPointer(p)
d.putItemCount(size, 1000)
if d.isExpanded():
(prev, p) = value.split("pp")
innerType = value.type[0]
typeCode = "pp{%s}" % innerType.name
with Children(d, size, maxNumChild=1000, childType=innerType):
for i in d.childRange():
(prev, p, val) = d.split(typeCode, p)
d.putSubItem(i, val)
def qform__std__map():
return [DisplayFormat.CompactMap]
def qdump__std__map(d, value):
if d.isQnxTarget() or d.isMsvcTarget():
qdump_std__map__helper(d, value)
return
# stuff is actually (color, pad) with 'I@', but we can save cycles/
(compare, stuff, parent, left, right) = value.split('ppppp')
size = value["_M_t"]["_M_impl"]["_M_node_count"].integer()
d.check(0 <= size and size <= 100 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
keyType = value.type[0]
valueType = value.type[1]
with Children(d, size, maxNumChild=1000):
node = value["_M_t"]["_M_impl"]["_M_header"]["_M_left"]
nodeSize = node.dereference().type.size()
typeCode = "@{%s}@{%s}" % (keyType.name, valueType.name)
for i in d.childRange():
(pad1, key, pad2, value) = d.split(typeCode, node.pointer() + nodeSize)
d.putPairItem(i, (key, value))
if node["_M_right"].pointer() == 0:
parent = node["_M_parent"]
while True:
if node.pointer() != parent["_M_right"].pointer():
break
node = parent
parent = parent["_M_parent"]
if node["_M_right"] != parent:
node = parent
else:
node = node["_M_right"]
while True:
if node["_M_left"].pointer() == 0:
break
node = node["_M_left"]
def qdump_std__map__helper(d, value):
try:
_ = value["_Mypair"]["_Myval2"]["_Myval2"]["_Myproxy"]
(proxy, head, size) = value.split("ppp")
except Exception:
(head, size) = value.split("pp")
d.check(0 <= size and size <= 100 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
keyType = value.type[0]
valueType = value.type[1]
pairType = value.type[3][0]
def helper(node):
(left, parent, right, color, isnil, pad, pair) = d.split(
"pppcc@{%s}" % (pairType.name), node)
if left != head:
for res in helper(left):
yield res
yield pair.split("{%s}@{%s}" % (keyType.name, valueType.name))[::2]
if right != head:
for res in helper(right):
yield res
(smallest, root) = d.split("pp", head)
with Children(d, size, maxNumChild=1000):
for (pair, i) in zip(helper(root), d.childRange()):
d.putPairItem(i, pair)
def qdump__std____debug__map(d, value):
qdump__std__map(d, value)
def qdump__std____debug__set(d, value):
qdump__std__set(d, value)
def qdump__std__multiset(d, value):
qdump__std__set(d, value)
def qdump__std____cxx1998__map(d, value):
qdump__std__map(d, value)
def qform__std__multimap():
return [DisplayFormat.CompactMap]
def qdump__std__multimap(d, value):
return qdump__std__map(d, value)
def qdumpHelper__std__tree__iterator(d, value, isSet=False):
treeTypeName = None
if value.type.name.endswith("::iterator"):
treeTypeName = value.type.name[:-len("::iterator")]
elif value.type.name.endswith("::const_iterator"):
treeTypeName = value.type.name[:-len("::const_iterator")]
treeType = d.lookupType(treeTypeName) if treeTypeName else value.type[0]
keyType = treeType[0]
valueType = treeType[1]
node = value["_M_node"].dereference() # std::_Rb_tree_node_base
d.putExpandable()
d.putEmptyValue()
if d.isExpanded():
with Children(d):
if isSet:
typecode = 'pppp@{%s}' % keyType.name
(color, parent, left, right, pad1, key) = d.split(typecode, node)
d.putSubItem("value", key)
else:
typecode = 'pppp@{%s}@{%s}' % (keyType.name, valueType.name)
(color, parent, left, right, pad1, key, pad2, value) = d.split(typecode, node)
d.putSubItem("first", key)
d.putSubItem("second", value)
with SubItem(d, "[node]"):
d.putExpandable()
d.putEmptyValue()
d.putType(" ")
if d.isExpanded():
with Children(d):
#d.putSubItem("color", color)
nodeType = node.type.pointer()
d.putSubItem("left", d.createValue(left, nodeType))
d.putSubItem("right", d.createValue(right, nodeType))
d.putSubItem("parent", d.createValue(parent, nodeType))
def qdump__std___Rb_tree_iterator(d, value):
qdumpHelper__std__tree__iterator(d, value)
def qdump__std___Rb_tree_const_iterator(d, value):
qdumpHelper__std__tree__iterator(d, value)
def qdump__std__map__iterator(d, value):
qdumpHelper__std__tree__iterator(d, value)
def qdump____gnu_debug___Safe_iterator(d, value):
d.putItem(value["_M_current"])
def qdump__std__map__const_iterator(d, value):
qdumpHelper__std__tree__iterator(d, value)
def qdump__std__set__iterator(d, value):
qdumpHelper__std__tree__iterator(d, value, True)
def qdump__std__set__const_iterator(d, value):
qdumpHelper__std__tree__iterator(d, value, True)
def qdump__std____cxx1998__set(d, value):
qdump__std__set(d, value)
def qdumpHelper__std__tree__iterator_MSVC(d, value):
d.putExpandable()
d.putEmptyValue()
if d.isExpanded():
with Children(d):
childType = value.type[0][0][0]
(proxy, nextIter, node) = value.split("ppp")
(left, parent, right, color, isnil, pad, child) = \
d.split("pppcc@{%s}" % (childType.name), node)
if (childType.name.startswith("std::pair")):
# workaround that values created via split have no members
keyType = childType[0].name
valueType = childType[1].name
d.putPairItem(None, child.split("{%s}@{%s}" % (keyType, valueType))[::2])
else:
d.putSubItem("value", child)
def qdump__std___Tree_const_iterator(d, value):
qdumpHelper__std__tree__iterator_MSVC(d, value)
def qdump__std___Tree_iterator(d, value):
qdumpHelper__std__tree__iterator_MSVC(d, value)
def qdump__std__set(d, value):
if d.isQnxTarget() or d.isMsvcTarget():
qdump__std__set__QNX(d, value)
return
impl = value["_M_t"]["_M_impl"]
size = impl["_M_node_count"].integer()
d.check(0 <= size and size <= 100 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
valueType = value.type[0]
node = impl["_M_header"]["_M_left"]
nodeSize = node.dereference().type.size()
typeCode = "@{%s}" % valueType.name
with Children(d, size, maxNumChild=1000, childType=valueType):
for i in d.childRange():
(pad, val) = d.split(typeCode, node.pointer() + nodeSize)
d.putSubItem(i, val)
if node["_M_right"].pointer() == 0:
parent = node["_M_parent"]
while node.pointer() == parent["_M_right"].pointer():
node = parent
parent = parent["_M_parent"]
if node["_M_right"] != parent:
node = parent
else:
node = node["_M_right"]
while node["_M_left"].pointer() != 0:
node = node["_M_left"]
def qdump__std__set__QNX(d, value):
try:
_ = value["_Mypair"]["_Myval2"]["_Myval2"]["_Myproxy"]
(proxy, head, size) = value.split("ppp")
except Exception:
(head, size) = value.split("pp")
d.check(0 <= size and size <= 100 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
childType = value.type[0]
def helper(node):
(left, parent, right, color, isnil, pad, value) = d.split(
"pppcc@{%s}" % childType.name, node)
if left != head:
for res in helper(left):
yield res
yield value
if right != head:
for res in helper(right):
yield res
(smallest, root) = d.split("pp", head)
with Children(d, size, maxNumChild=1000):
for (item, i) in zip(helper(root), d.childRange()):
d.putSubItem(i, item)
def std1TreeMin(d, node):
#_NodePtr __tree_min(_NodePtr __x):
# while (__x->__left_ != nullptr)
# __x = __x->__left_;
# return __x;
#
left = node['__left_']
if left.pointer():
node = left
return node
def std1TreeIsLeftChild(d, node):
# bool __tree_is_left_child(_NodePtr __x):
# return __x == __x->__parent_->__left_;
#
other = node['__parent_']['__left_']
return node.pointer() == other.pointer()
def std1TreeNext(d, node):
#_NodePtr __tree_next(_NodePtr __x):
# if (__x->__right_ != nullptr)
# return __tree_min(__x->__right_);
# while (!__tree_is_left_child(__x))
# __x = __x->__parent_;
# return __x->__parent_;
#
right = node['__right_']
if right.pointer():
return std1TreeMin(d, right)
while not std1TreeIsLeftChild(d, node):
node = node['__parent_']
return node['__parent_']
def qdump__std____1__set(d, value):
(proxy, head, size) = value.split("ppp")
d.check(0 <= size and size <= 100 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
valueType = value.type[0]
def in_order_traversal(node):
(left, right, parent, color, pad, data) = d.split("pppB@{%s}" % (valueType.name), node)
if left:
for res in in_order_traversal(left):
yield res
yield data
if right:
for res in in_order_traversal(right):
yield res
with Children(d, size, maxNumChild=1000):
for (i, data) in zip(d.childRange(), in_order_traversal(head)):
d.putSubItem(i, data)
def qdump__std____1__multiset(d, value):
qdump__std____1__set(d, value)
def qform__std____1__map():
return [DisplayFormat.CompactMap]
def qdump__std____1__map(d, value):
try:
(proxy, head, size) = value.split("ppp")
d.check(0 <= size and size <= 100 * 1000 * 1000)
# Sometimes there is extra data at the front. Don't know why at the moment.
except RuntimeError:
(junk, proxy, head, size) = value.split("pppp")
d.check(0 <= size and size <= 100 * 1000 * 1000)
d.putItemCount(size)
if d.isExpanded():
keyType = value.type[0]
valueType = value.type[1]
pairType = value.type[3][0]
def in_order_traversal(node):
(left, right, parent, color, pad, pair) = d.split("pppB@{%s}" % (pairType.name), node)
if left:
for res in in_order_traversal(left):
yield res
yield pair.split("{%s}@{%s}" % (keyType.name, valueType.name))[::2]
if right:
for res in in_order_traversal(right):
yield res
with Children(d, size, maxNumChild=1000):
for (i, pair) in zip(d.childRange(), in_order_traversal(head)):
d.putPairItem(i, pair, 'key', 'value')
def qform__std____1__multimap():
return [DisplayFormat.CompactMap]
def qdump__std____1__multimap(d, value):
qdump__std____1__map(d, value)
def qdump__std____1__map__iterator(d, value):
d.putEmptyValue()
if d.isExpanded():
with Children(d):
node = value['__i_']['__ptr_'].dereference()['__value_']['__cc']
d.putSubItem('first', node['first'])
d.putSubItem('second', node['second'])
def qdump__std____1__map__const_iterator(d, value):
qdump__std____1__map__iterator(d, value)
def qdump__std____1__set__iterator(d, value):
d.putEmptyValue()
d.putExpandable()
if value.type.name.endswith("::iterator"):
treeTypeName = value.type.name[:-len("::iterator")]
elif value.type.name.endswith("::const_iterator"):
treeTypeName = value.type.name[:-len("::const_iterator")]
treeType = d.lookupType(treeTypeName)
keyType = treeType[0]
if d.isExpanded():
with Children(d):
node = value['__ptr_'].dereference()['__value_']
node = node.cast(keyType)
d.putSubItem('value', node)
def qdump__std____1__set_const_iterator(d, value):
qdump__std____1__set__iterator(d, value)
def qdump__std__stack(d, value):
d.putItem(value["c"])
d.putBetterType(value.type)
def qdump__std____debug__stack(d, value):
qdump__std__stack(d, value)
def qdump__std____1__stack(d, value):
d.putItem(value["c"])
d.putBetterType(value.type)
def qform__std__string():
return [DisplayFormat.Latin1String, DisplayFormat.SeparateLatin1String,
DisplayFormat.Utf8String, DisplayFormat.SeparateUtf8String]
def qdump__std__string(d, value):
qdumpHelper_std__string(d, value, d.createType("char"), d.currentItemFormat())
def qdumpHelper_std__string(d, value, charType, format):
if d.isQnxTarget():
qdumpHelper__std__string__QNX(d, value, charType, format)
return
if d.isMsvcTarget():
qdumpHelper__std__string__MSVC(d, value, charType, format)
return
# GCC 9, QTCREATORBUG-22753
try:
data = value["_M_dataplus"]["_M_p"].pointer()
except:
data = value.extractPointer()
try:
size = int(value["_M_string_length"])
d.putCharArrayHelper(data, size, charType, format)
return
except:
pass
# We can't lookup the std::string::_Rep type without crashing LLDB,
# so hard-code assumption on member position
# struct { size_type _M_length, size_type _M_capacity, int _M_refcount; }
(size, alloc, refcount) = d.split("ppi", data - 3 * d.ptrSize())
d.check(refcount >= -1) # Can be -1 according to docs.
d.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000)
d.putCharArrayHelper(data, size, charType, format)
def qdumpHelper__std__string__QNX(d, value, charType, format):
size = value['_Mysize']
alloc = value['_Myres']
_BUF_SIZE = int(16 / charType.size())
if _BUF_SIZE <= alloc: # (_BUF_SIZE <= _Myres ? _Bx._Ptr : _Bx._Buf);
data = value['_Bx']['_Ptr']
else:
data = value['_Bx']['_Buf']
sizePtr = data.cast(d.charType().pointer())
refcount = int(sizePtr[-1])
d.check(refcount >= -1) # Can be -1 accoring to docs.
d.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000)
d.putCharArrayHelper(sizePtr, size, charType, format)
def qdumpHelper__std__string__MSVC(d, value, charType, format):
try:
_ = value["_Mypair"]["_Myval2"]["_Myproxy"]
(proxy, buffer, size, alloc) = value.split("p16spp")
except Exception:
proxy = None
(buffer, size, alloc) = value.split("16spp")
d.check(0 <= size and size <= alloc and alloc <= 100 * 1000 * 1000)
_BUF_SIZE = int(16 / charType.size())
if _BUF_SIZE <= alloc:
if proxy is None:
data = value.extractPointer()
else:
(proxy, data) = value.split("pp")
else:
if proxy is None:
data = value.address()
else:
data = value.address() + d.ptrSize()
d.putCharArrayHelper(data, size, charType, format)
def qdump__std____1__string(d, value):
firstByte = value.split('b')[0]
if int(firstByte & 1) == 0:
# Short/internal.
size = int(firstByte / 2)
data = value.address() + 1
else:
# Long/external.
(dummy, size, data) = value.split('ppp')
d.putCharArrayHelper(data, size, d.charType(), d.currentItemFormat())
d.putType("std::string")
def qdump__std____1__wstring(d, value):
firstByte = value.split('b')[0]
if int(firstByte & 1) == 0:
# Short/internal.
size = int(firstByte / 2)
data = value.address() + 4
else:
# Long/external.
(dummy, size, data) = value.split('ppp')
d.putCharArrayHelper(data, size, d.createType('wchar_t'))
d.putType("std::wstring")
def qdump__std____weak_ptr(d, value):
return qdump__std__shared_ptr(d, value)
def qdump__std__weak_ptr(d, value):
return qdump__std__shared_ptr(d, value)
def qdump__std____1__weak_ptr(d, value):
return qdump__std____1__shared_ptr(d, value)
def qdump__std__shared_ptr(d, value):
if d.isMsvcTarget():
i = value["_Ptr"]
else:
i = value["_M_ptr"]
if i.pointer() == 0:
d.putValue("(null)")
else:
d.putItem(i.dereference())
d.putBetterType(value.type)
def qdump__std____1__shared_ptr(d, value):
i = value["__ptr_"]
if i.pointer() == 0:
d.putValue("(null)")
else:
d.putItem(i.dereference())
d.putBetterType(value.type)
def qdump__std__unique_ptr(d, value):
if value.type.size() == d.ptrSize():
p = d.extractPointer(value)
else:
_, p = value.split("pp"); # For custom deleters.
if p == 0:
d.putValue("(null)")
else:
d.putItem(d.createValue(p, value.type[0]))
d.putBetterType(value.type)
def qdump__std____1__unique_ptr(d, value):
qdump__std__unique_ptr(d, value)
def qdump__std__pair(d, value):
typeCode = '{%s}@{%s}' % (value.type[0].name, value.type[1].name)
first, pad, second = value.split(typeCode)
with Children(d):
key = d.putSubItem('first', first)
value = d.putSubItem('second', second)
key = key.value if key.encoding is None else "..."
value = value.value if value.encoding is None else "..."
d.putValue('(%s, %s)' % (key, value))
def qform__std__unordered_map():
return [DisplayFormat.CompactMap]
def qform__std____debug__unordered_map():
return [DisplayFormat.CompactMap]
def qdump__std__unordered_map(d, value):
if d.isQnxTarget():
qdump__std__list__QNX(d, value["_List"])
return
if d.isMsvcTarget():
_list = value["_List"]
try:
_ = _list["_Mypair"]["_Myval2"]["_Myproxy"]
(_, start, size) = _list.split("ppp")
except Exception:
(start, size) = _list.split("pp")
else:
try:
# gcc ~= 4.7
size = value["_M_element_count"].integer()
start = value["_M_before_begin"]["_M_nxt"]
except:
try:
# libc++ (Mac)
size = value["_M_h"]["_M_element_count"].integer()
start = value["_M_h"]["_M_bbegin"]["_M_node"]["_M_nxt"]
except:
try:
# gcc 4.9.1
size = value["_M_h"]["_M_element_count"].integer()
start = value["_M_h"]["_M_before_begin"]["_M_nxt"]
except:
# gcc 4.6.2
size = value["_M_element_count"].integer()
start = value["_M_buckets"].dereference()
# FIXME: Pointer-aligned?
d.putItemCount(size)
# We don't know where the data is
d.putNumChild(0)
return
d.putItemCount(size)
if d.isExpanded():
keyType = value.type[0]
valueType = value.type[1]
if d.isMsvcTarget():
typeCode = 'pp@{%s}@{%s}' % (keyType.name, valueType.name)
p = d.extractPointer(start)
else:
typeCode = 'p@{%s}@{%s}' % (keyType.name, valueType.name)
p = start.pointer()
with Children(d, size):
for i in d.childRange():
if d.isMsvcTarget():
p, _, _, key, _, val = d.split(typeCode, p)
else:
p, _, key, _, val = d.split(typeCode, p)
d.putPairItem(i, (key, val))
def qdump__std____debug__unordered_map(d, value):
qdump__std__unordered_map(d, value)
def qform__std__unordered_multimap():
return qform__std__unordered_map()
def qform__std____debug__unordered_multimap():
return qform__std____debug__unordered_map()
def qdump__std__unordered_multimap(d, value):
qdump__std__unordered_map(d, value)
def qdump__std____debug__unordered_multimap(d, value):
qdump__std__unordered_multimap(d, value)
def qdump__std__unordered_set(d, value):
if d.isQnxTarget() or d.isMsvcTarget():
qdump__std__list__QNX(d, value["_List"])
return
try:
# gcc ~= 4.7
size = value["_M_element_count"].integer()
start = value["_M_before_begin"]["_M_nxt"]
offset = 0
except:
try:
# libc++ (Mac)
size = value["_M_h"]["_M_element_count"].integer()
start = value["_M_h"]["_M_bbegin"]["_M_node"]["_M_nxt"]
offset = 0
except:
try:
# gcc 4.6.2
size = value["_M_element_count"].integer()
start = value["_M_buckets"].dereference()
offset = d.ptrSize()
except:
# gcc 4.9.1
size = value["_M_h"]["_M_element_count"].integer()
start = value["_M_h"]["_M_before_begin"]["_M_nxt"]
offset = 0
d.putItemCount(size)
if d.isExpanded():
p = start.pointer()
valueType = value.type[0]
with Children(d, size, childType=valueType):
ptrSize = d.ptrSize()
for i in d.childRange():
d.putSubItem(i, d.createValue(p + ptrSize - offset, valueType))
p = d.extractPointer(p + offset)
def qform__std____1__unordered_map():
return [DisplayFormat.CompactMap]
def qdump__std____1__unordered_map(d, value):
(size, _) = value["__table_"]["__p2_"].split("pp")
d.putItemCount(size)
keyType = value.type[0]
valueType = value.type[1]
pairType = value.type[4][0]