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
build / config / c++ / libc++.natvis [blame]
<?xml version="1.0" encoding="utf-8" ?>
<AutoVisualizer
xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<!-- libc++'s __compressed_pair is an internal type used pervasively for
doing the empty base class optimization.
__compressed_pair<U,V> derives from __compressed_pair_elem<U,0> and
__compressed_pair_elem<V,1>. __compressed_pair_elem<T> is specialized on
a 3rd template parameter:
* if T is empty and non-final the 3rd param is 1 and it derives from T
* else it has a member variable __value_ of type T
-->
<Type Name="std::__Cr::__compressed_pair_elem<*,*,0>">
<DisplayString>{__value_}</DisplayString>
<Expand>
<ExpandedItem>__value_</ExpandedItem>
</Expand>
</Type>
<Type Name="std::__Cr::__compressed_pair_elem<*,*,1>">
<DisplayString>{*($T1*)this}</DisplayString>
<Expand>
<ExpandedItem>*($T1*)this</ExpandedItem>
</Expand>
</Type>
<Type Name="std::__Cr::array<*,*>">
<DisplayString>{{ size={$T2} }}</DisplayString>
<Expand>
<ArrayItems>
<Size>$T2</Size>
<ValuePointer>__elems_</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<!--libc++'s short string optimization:
A basic_string is 3 size_t words long. In the "alternate string layout"
that we use, they are: pointer to data, size, capacity.
(In the normal layout, it's capacity, size, data instead.)
If a string is short enough that it fits in these three size_ts instead,
the string data is stored inline in these 3 words, with the last byte of
the storage storing the length of the string.
The highest bit of the "capacity" word is set for normal, "long" strings,
and that bit needs to be masked out to know the real capacity.
If this bit is not set, the string data is stored inline.
(In the normal layout, if the lowest bit in the first byte is set,
it's a "long" string, requiring a long string to always have even
capacity. A short string here stores its length in the first byte
and the inline data in the remaining storage.)
-->
<Type Name="std::__Cr::basic_string<char,*>">
<!--<Intrinsic Name="is_long"
Expression="((__rep*)&__r_)->__s.__size_ & 0x80" />-->
<!-- The above doesn't work because of https://llvm.org/PR41615
TODO(thakis): Now that we have clang r362038, try the above approach
again.
The below assumes the alternate string layout and little endianness :/
-->
<Intrinsic Name="is_long"
Expression="*(((char*)this) + 3*sizeof(size_t) - 1) & 0x80" />
<DisplayString Condition="is_long()">{*(char**)this}</DisplayString>
<DisplayString Condition="!is_long()">{(char*)this}</DisplayString>
<StringView Condition="is_long()">*(char**)this</StringView>
<StringView Condition="!is_long()">(char*)this</StringView>
<Expand>
<Item Name="[size]" Condition="is_long()"
ExcludeView="simple">((size_t*)this)[1]</Item>
<Item Name="[size]" Condition="!is_long()"
ExcludeView="simple">*(((char*)this) + 3*sizeof(size_t) - 1)</Item>
<Item Name="[capacity]" Condition="is_long()" ExcludeView="simple">
((size_t*)this)[2] & (~((size_t)0) >> 1)
</Item>
<Item Name="[capacity]" Condition="!is_long()"
ExcludeView="simple">22</Item>
<ArrayItems>
<Size Condition="is_long()">((size_t*)this)[1]</Size>
<Size Condition="!is_long()">
*(((char*)this) + 3*sizeof(size_t) - 1)
</Size>
<ValuePointer Condition="is_long()">*(char**)this</ValuePointer>
<ValuePointer Condition="!is_long()">(char*)this</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="std::__Cr::basic_string<wchar_t,*>">
<Intrinsic Name="is_long"
Expression="*(((char*)this) + 3*sizeof(size_t) - 1) & 0x80" />
<DisplayString Condition="is_long()">{*(wchar_t**)this}</DisplayString>
<DisplayString Condition="!is_long()">{(wchar_t*)this}</DisplayString>
<StringView Condition="is_long()">*(wchar_t**)this</StringView>
<StringView Condition="!is_long()">(wchar_t*)this</StringView>
<Expand>
<Item Name="[size]" Condition="is_long()"
ExcludeView="simple">((size_t*)this)[1]</Item>
<Item Name="[size]" Condition="!is_long()"
ExcludeView="simple">*(((char*)this) + 3*sizeof(size_t) - 1)</Item>
<Item Name="[capacity]" Condition="is_long()" ExcludeView="simple">
((size_t*)this)[2] & (~((size_t)0) >> 1)
</Item>
<Item Name="[capacity]" Condition="!is_long()"
ExcludeView="simple">10</Item>
<ArrayItems>
<Size Condition="is_long()">((size_t*)this)[1]</Size>
<Size Condition="!is_long()">
*(((char*)this) + 3*sizeof(size_t) - 1)
</Size>
<ValuePointer Condition="is_long()">*(wchar_t**)this</ValuePointer>
<ValuePointer Condition="!is_long()">(wchar_t*)this</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="std::__Cr::deque<*,*>">
<Intrinsic Name="size" Expression="*(size_type*)&__size_" />
<Intrinsic Name="block_size"
Expression="sizeof($T1) < 256 ? 4096 / sizeof($T1) : 16" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<IndexListItems>
<Size>size()</Size>
<ValueNode>
*(*(__map_.__begin_ + ($i + __start_) / block_size()) +
($i + __start_) % block_size())
</ValueNode>
</IndexListItems>
</Expand>
</Type>
<Type Name="std::__Cr::forward_list<*>">
<Intrinsic Name="head"
Expression="((__node_pointer)&__before_begin_)->__next_" />
<DisplayString Condition="head() == 0">empty</DisplayString>
<DisplayString Condition="head() != 0">non-empty</DisplayString>
<Expand>
<LinkedListItems>
<HeadPointer>head()</HeadPointer>
<NextPointer>__next_</NextPointer>
<ValueNode>__value_</ValueNode>
</LinkedListItems>
</Expand>
</Type>
<!-- Note: Not in Cr! But will win over the one in stl.natvis -->
<Type Name="std::initializer_list<*>">
<DisplayString>{{ size={__size_} }}</DisplayString>
<Expand>
<ArrayItems>
<Size>__size_</Size>
<ValuePointer>__begin_</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="std::__Cr::list<*>">
<Intrinsic Name="size" Expression="*(size_type*)&__size_alloc_" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<LinkedListItems>
<Size>size()</Size>
<HeadPointer>__end_.__next_</HeadPointer>
<NextPointer>__next_</NextPointer>
<ValueNode>
((std::__Cr::list<$T1,$T2>::__node_pointer)this)
->__value_
</ValueNode>
</LinkedListItems>
</Expand>
</Type>
<Type Name="std::__Cr::map<*>">
<Intrinsic Name="size" Expression="*(size_type*)&__tree_.__pair3_" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<Item Name="[size]">size()</Item>
<TreeItems>
<Size>size()</Size>
<HeadPointer>
((__node_pointer)&__tree_.__pair1_)->__left_
</HeadPointer>
<LeftPointer>
((std::__Cr::map<$T1,$T2,$T3,$T4>::__node_pointer)this)
->__left_
</LeftPointer>
<RightPointer>
((std::__Cr::map<$T1,$T2,$T3,$T4>::__node_pointer)this)
->__right_
</RightPointer>
<ValueNode>
((std::__Cr::map<$T1,$T2,$T3,$T4>::__node_pointer)this)
->__value_.__cc_
</ValueNode>
</TreeItems>
</Expand>
</Type>
<Type Name="std::__Cr::multimap<*>">
<Intrinsic Name="size" Expression="*(size_type*)&__tree_.__pair3_" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<Item Name="[size]">size()</Item>
<TreeItems>
<Size>size()</Size>
<HeadPointer>
((__node_pointer)&__tree_.__pair1_)->__left_
</HeadPointer>
<LeftPointer>
((std::__Cr::multimap<$T1,$T2,$T3,$T4>::__node_pointer)this)
->__left_
</LeftPointer>
<RightPointer>
((std::__Cr::multimap<$T1,$T2,$T3,$T4>::__node_pointer)this)
->__right_
</RightPointer>
<ValueNode>
((std::__Cr::multimap<$T1,$T2,$T3,$T4>::__node_pointer)this)
->__value_.__cc_
</ValueNode>
</TreeItems>
</Expand>
</Type>
<Type Name="std::__Cr::multiset<*>">
<Intrinsic Name="size" Expression="*(size_type*)&__tree_.__pair3_" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<Item Name="[size]">size()</Item>
<TreeItems>
<Size>size()</Size>
<HeadPointer>
((__base::__node_pointer)&__tree_.__pair1_)->__left_
</HeadPointer>
<LeftPointer>
((std::__Cr::multiset<$T1,$T2,$T3>::__base::__node_pointer)this)
->__left_
</LeftPointer>
<RightPointer>
((std::__Cr::multiset<$T1,$T2,$T3>::__base::__node_pointer)this)
->__right_
</RightPointer>
<ValueNode>
((std::__Cr::multiset<$T1,$T2,$T3>::__base::__node_pointer)this)
->__value_
</ValueNode>
</TreeItems>
</Expand>
</Type>
<Type Name="std::__Cr::optional<*>">
<DisplayString Condition="!__engaged_">nullopt</DisplayString>
<DisplayString>{__val_}</DisplayString>
<Expand>
<ExpandedItem Condition="__engaged_">__val_</ExpandedItem>
</Expand>
</Type>
<Type Name="std::__Cr::priority_queue<*>">
<DisplayString>{c}</DisplayString>
<Expand>
<ExpandedItem>c</ExpandedItem>
<Item Name="[comp]">comp</Item>
</Expand>
</Type>
<Type Name="std::__Cr::set<*>">
<Intrinsic Name="size" Expression="*(size_type*)&__tree_.__pair3_" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<Item Name="[size]">size()</Item>
<TreeItems>
<Size>size()</Size>
<HeadPointer>
((__base::__node_pointer)&__tree_.__pair1_)->__left_
</HeadPointer>
<LeftPointer>
((std::__Cr::set<$T1,$T2,$T3>::__base::__node_pointer)this)
->__left_
</LeftPointer>
<RightPointer>
((std::__Cr::set<$T1,$T2,$T3>::__base::__node_pointer)this)
->__right_
</RightPointer>
<ValueNode>
((std::__Cr::set<$T1,$T2,$T3>::__base::__node_pointer)this)
->__value_
</ValueNode>
</TreeItems>
</Expand>
</Type>
<Type Name="std::__Cr::stack<*>">
<AlternativeType Name="std::__Cr::queue<*>" />
<DisplayString>{c}</DisplayString>
<Expand>
<ExpandedItem>c</ExpandedItem>
</Expand>
</Type>
<Type Name="std::__Cr::__tuple_leaf<*,*,0>">
<DisplayString>{__value_}</DisplayString>
</Type>
<Type Name="std::__Cr::tuple<>">
<DisplayString>()</DisplayString>
</Type>
<Type Name="std::__Cr::tuple<*>">
<DisplayString>({(std::__Cr::__tuple_leaf<0,$T1,0>)__base_})</DisplayString>
<Expand>
<Item Name="[0]">(std::__Cr::__tuple_leaf<0,$T1,0>)__base_</Item>
</Expand>
</Type>
<Type Name="std::__Cr::tuple<*,*>">
<DisplayString>({(std::__Cr::__tuple_leaf<0,$T1,0>)__base_}, {(std::__Cr::__tuple_leaf<1,$T2,0>)__base_})</DisplayString>
<Expand>
<Item Name="[0]">(std::__Cr::__tuple_leaf<0,$T1,0>)__base_</Item>
<Item Name="[1]">(std::__Cr::__tuple_leaf<1,$T2,0>)__base_</Item>
</Expand>
</Type>
<Type Name="std::__Cr::tuple<*,*,*>">
<DisplayString>({(std::__Cr::__tuple_leaf<0,$T1,0>)__base_}, {(std::__Cr::__tuple_leaf<1,$T2,0>)__base_}, {(std::__Cr::__tuple_leaf<2,$T3,0>)__base_})</DisplayString>
<Expand>
<Item Name="[0]">(std::__Cr::__tuple_leaf<0,$T1,0>)__base_</Item>
<Item Name="[1]">(std::__Cr::__tuple_leaf<1,$T2,0>)__base_</Item>
<Item Name="[2]">(std::__Cr::__tuple_leaf<2,$T3,0>)__base_</Item>
</Expand>
</Type>
<Type Name="std::__Cr::tuple<*,*,*,*>">
<DisplayString>({(std::__Cr::__tuple_leaf<0,$T1,0>)__base_}, {(std::__Cr::__tuple_leaf<1,$T2,0>)__base_}, {(std::__Cr::__tuple_leaf<2,$T3,0>)__base_}, {(std::__Cr::__tuple_leaf<3,$T4,0>)__base_})</DisplayString>
<Expand>
<Item Name="[0]">(std::__Cr::__tuple_leaf<0,$T1,0>)__base_</Item>
<Item Name="[1]">(std::__Cr::__tuple_leaf<1,$T2,0>)__base_</Item>
<Item Name="[2]">(std::__Cr::__tuple_leaf<2,$T3,0>)__base_</Item>
<Item Name="[3]">(std::__Cr::__tuple_leaf<3,$T4,0>)__base_</Item>
</Expand>
</Type>
<Type Name="std::__Cr::tuple<*,*,*,*,*>">
<DisplayString>({(std::__Cr::__tuple_leaf<0,$T1,0>)__base_}, {(std::__Cr::__tuple_leaf<1,$T2,0>)__base_}, {(std::__Cr::__tuple_leaf<2,$T3,0>)__base_}, {(std::__Cr::__tuple_leaf<3,$T4,0>)__base_}, {(std::__Cr::__tuple_leaf<4,$T5,0>)__base_})</DisplayString>
<Expand>
<Item Name="[0]">(std::__Cr::__tuple_leaf<0,$T1,0>)__base_</Item>
<Item Name="[1]">(std::__Cr::__tuple_leaf<1,$T2,0>)__base_</Item>
<Item Name="[2]">(std::__Cr::__tuple_leaf<2,$T3,0>)__base_</Item>
<Item Name="[3]">(std::__Cr::__tuple_leaf<3,$T4,0>)__base_</Item>
<Item Name="[4]">(std::__Cr::__tuple_leaf<4,$T5,0>)__base_</Item>
</Expand>
</Type>
<Type Name="std::__Cr::tuple<*,*,*,*,*,*>">
<DisplayString>({(std::__Cr::__tuple_leaf<0,$T1,0>)__base_}, {(std::__Cr::__tuple_leaf<1,$T2,0>)__base_}, {(std::__Cr::__tuple_leaf<2,$T3,0>)__base_}, {(std::__Cr::__tuple_leaf<3,$T4,0>)__base_}, {(std::__Cr::__tuple_leaf<4,$T5,0>)__base_}, {(std::__Cr::__tuple_leaf<5,$T6,0>)__base_})</DisplayString>
<Expand>
<Item Name="[0]">(std::__Cr::__tuple_leaf<0,$T1,0>)__base_</Item>
<Item Name="[1]">(std::__Cr::__tuple_leaf<1,$T2,0>)__base_</Item>
<Item Name="[2]">(std::__Cr::__tuple_leaf<2,$T3,0>)__base_</Item>
<Item Name="[3]">(std::__Cr::__tuple_leaf<3,$T4,0>)__base_</Item>
<Item Name="[4]">(std::__Cr::__tuple_leaf<4,$T5,0>)__base_</Item>
<Item Name="[5]">(std::__Cr::__tuple_leaf<5,$T6,0>)__base_</Item>
</Expand>
</Type>
<Type Name="std::__Cr::tuple<*,*,*,*,*,*,*>">
<DisplayString>({(std::__Cr::__tuple_leaf<0,$T1,0>)__base_}, {(std::__Cr::__tuple_leaf<1,$T2,0>)__base_}, {(std::__Cr::__tuple_leaf<2,$T3,0>)__base_}, {(std::__Cr::__tuple_leaf<3,$T4,0>)__base_}, {(std::__Cr::__tuple_leaf<4,$T5,0>)__base_}, {(std::__Cr::__tuple_leaf<5,$T6,0>)__base_}, {(std::__Cr::__tuple_leaf<6,$T7,0>)__base_})</DisplayString>
<Expand>
<Item Name="[0]">(std::__Cr::__tuple_leaf<0,$T1,0>)__base_</Item>
<Item Name="[1]">(std::__Cr::__tuple_leaf<1,$T2,0>)__base_</Item>
<Item Name="[2]">(std::__Cr::__tuple_leaf<2,$T3,0>)__base_</Item>
<Item Name="[3]">(std::__Cr::__tuple_leaf<3,$T4,0>)__base_</Item>
<Item Name="[4]">(std::__Cr::__tuple_leaf<4,$T5,0>)__base_</Item>
<Item Name="[5]">(std::__Cr::__tuple_leaf<5,$T6,0>)__base_</Item>
<Item Name="[6]">(std::__Cr::__tuple_leaf<6,$T7,0>)__base_</Item>
</Expand>
</Type>
<Type Name="std::__Cr::unique_ptr<*>">
<Intrinsic Name="value" Expression="*($T1**)&__ptr_" />
<SmartPointer Usage="Minimal">value()</SmartPointer>
<DisplayString Condition="value() == 0">empty</DisplayString>
<DisplayString Condition="value() != 0">
unique_ptr {value()}</DisplayString>
<Expand>
<Item Condition="value() != 0" Name="[ptr]">value()</Item>
</Expand>
</Type>
<Type Name="std::__Cr::unordered_map<*>">
<AlternativeType Name="std::__Cr::unordered_multimap<*>" />
<AlternativeType Name="std::__Cr::unordered_multiset<*>" />
<AlternativeType Name="std::__Cr::unordered_set<*>" />
<Intrinsic Name="size" Expression="*(size_type*)&__table_.__p2_" />
<Intrinsic Name="bucket_count"
Expression="*(size_type*)&
((__table::__bucket_list_deleter*)
((void**)&__table_.__bucket_list_ + 1))
->__data_" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<Item Name="[bucket_count]">bucket_count()</Item>
<Item Name="[load_factor]">
bucket_count() != 0 ? (float)size() / bucket_count() : 0.f</Item>
<Item Name="[max_load_factor]">*(float*)&__table_.__p3_</Item>
<!-- Use CustomListItems instead of LinkedListItems because we
need to cast to __table::__node_pointer and LinkedListItems
evaluates <Value> in the context of the node, not of the container,
so we'd have to say std::unordered_map<$T1,...>::__table::__node_pointer
and then we couldn't share this <Type> between unordered_(multi)map
and unordered_(multi)set. -->
<CustomListItems>
<Variable Name="node"
InitialValue="*(__table::__next_pointer*)&__table_.__p1_" />
<Size>size()</Size>
<Loop>
<Item>(*(__table::__node_pointer*)&node)->__value_</Item>
<Exec>node = node->__next_</Exec>
</Loop>
</CustomListItems>
</Expand>
</Type>
<!-- This is the node __value_ of an unordered_(multi)map. Expand it through
a separate formatter instead of in the <Item> expression above so that the
same <Type> works for unordered_(multi)set and unordered_(multi)map. -->
<Type Name="std::__Cr::__hash_value_type<*>">
<DisplayString>{__cc}</DisplayString>
<Expand>
<ExpandedItem>__cc</ExpandedItem>
</Expand>
</Type>
<Type Name="std::__Cr::vector<*>">
<Intrinsic Name="size" Expression="__end_ - __begin_" />
<DisplayString>{{ size={size()} }}</DisplayString>
<Expand>
<ArrayItems>
<Size>size()</Size>
<ValuePointer>__begin_</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>