Skip to content

Commit ae9d115

Browse files
STL.natvis: Simplify visualization for string (#5177)
Co-authored-by: Stephan T. Lavavej <[email protected]>
1 parent 56bd1fe commit ae9d115

File tree

1 file changed

+7
-81
lines changed

1 file changed

+7
-81
lines changed

stl/debugger/STL.natvis

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,17 +1001,14 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10011001
* Notes:
10021002
* Hard coding _BUF_SIZE for clang-cl compatibility; clang-cl as of 7.0.1 does not emit S_CONSTANT to get _BUF_SIZE
10031003
*
1004-
* char = na format
1005-
* wchar_t / unsigned short / char16_t = su format
1006-
* char32_t = s32 format
1004+
* The `na` format specifier means "no address". For more info, see:
1005+
* https://learn.microsoft.com/en-us/visualstudio/debugger/format-specifiers-in-cpp?view=vs-2022
10071006
-->
1008-
<Type Name="std::basic_string&lt;char,*&gt;">
1009-
<AlternativeType Name="std::basic_string&lt;char8_t,*&gt;" />
1010-
1007+
<Type Name="std::basic_string&lt;*&gt;">
10111008
<Intrinsic Name="size" Expression="_Mypair._Myval2._Mysize" />
10121009
<Intrinsic Name="capacity" Expression="_Mypair._Myval2._Myres" />
1013-
<!-- _BUF_SIZE = 16 / sizeof(char) &lt; 1 ? 1 : 16 / sizeof(char) == 16 -->
1014-
<Intrinsic Name="bufSize" Expression="16" />
1010+
<!-- _BUF_SIZE = 16 / sizeof($T1) &lt; 1 ? 1 : 16 / sizeof($T1) -->
1011+
<Intrinsic Name="bufSize" Expression="16 / sizeof($T1) &lt; 1 ? 1 : 16 / sizeof($T1)" />
10151012
<Intrinsic Name="isShortString" Expression="capacity() &lt; bufSize()" />
10161013
<Intrinsic Name="isLongString" Expression="capacity() &gt;= bufSize()" />
10171014
<DisplayString Condition="isShortString()">{_Mypair._Myval2._Bx._Buf,na}</DisplayString>
@@ -1030,85 +1027,14 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
10301027
</Expand>
10311028
</Type>
10321029

1033-
<Type Name="std::basic_string&lt;wchar_t,*&gt;">
1034-
<AlternativeType Name="std::basic_string&lt;unsigned short,*&gt;" />
1035-
<AlternativeType Name="std::basic_string&lt;char16_t,*&gt;" />
1036-
1037-
<Intrinsic Name="size" Expression="_Mypair._Myval2._Mysize" />
1038-
<Intrinsic Name="capacity" Expression="_Mypair._Myval2._Myres" />
1039-
<!-- _BUF_SIZE = 16 / sizeof(wchar_t) &lt; 1 ? 1 : 16 / sizeof(wchar_t) == 8 -->
1040-
<Intrinsic Name="bufSize" Expression="8" />
1041-
<Intrinsic Name="isShortString" Expression="capacity() &lt; bufSize()" />
1042-
<Intrinsic Name="isLongString" Expression="capacity() &gt;= bufSize()" />
1043-
<DisplayString Condition="isShortString()">{_Mypair._Myval2._Bx._Buf,su}</DisplayString>
1044-
<DisplayString Condition="isLongString()">{_Mypair._Myval2._Bx._Ptr,su}</DisplayString>
1045-
<StringView Condition="isShortString()">_Mypair._Myval2._Bx._Buf,su</StringView>
1046-
<StringView Condition="isLongString()">_Mypair._Myval2._Bx._Ptr,su</StringView>
1047-
<Expand>
1048-
<Item Name="[size]" ExcludeView="simple">size()</Item>
1049-
<Item Name="[capacity]" ExcludeView="simple">capacity()</Item>
1050-
<Item Name="[allocator]" ExcludeView="simple">_Mypair</Item>
1051-
<ArrayItems>
1052-
<Size>_Mypair._Myval2._Mysize</Size>
1053-
<ValuePointer Condition="isShortString()">_Mypair._Myval2._Bx._Buf</ValuePointer>
1054-
<ValuePointer Condition="isLongString()">_Mypair._Myval2._Bx._Ptr</ValuePointer>
1055-
</ArrayItems>
1056-
</Expand>
1057-
</Type>
1058-
1059-
<Type Name="std::basic_string&lt;char32_t,*&gt;">
1060-
<Intrinsic Name="size" Expression="_Mypair._Myval2._Mysize" />
1061-
<Intrinsic Name="capacity" Expression="_Mypair._Myval2._Myres" />
1062-
<!-- _BUF_SIZE = 16 / sizeof(char32_t) &lt; 1 ? 1 : 16 / sizeof(char32_t) == 4 -->
1063-
<Intrinsic Name="bufSize" Expression="4" />
1064-
<Intrinsic Name="isShortString" Expression="capacity() &lt; bufSize()" />
1065-
<Intrinsic Name="isLongString" Expression="capacity() &gt;= bufSize()" />
1066-
<DisplayString Condition="isShortString()">{_Mypair._Myval2._Bx._Buf,s32}</DisplayString>
1067-
<DisplayString Condition="isLongString()">{_Mypair._Myval2._Bx._Ptr,s32}</DisplayString>
1068-
<StringView Condition="isShortString()">_Mypair._Myval2._Bx._Buf,s32</StringView>
1069-
<StringView Condition="isLongString()">_Mypair._Myval2._Bx._Ptr,s32</StringView>
1070-
<Expand>
1071-
<Item Name="[size]" ExcludeView="simple">size()</Item>
1072-
<Item Name="[capacity]" ExcludeView="simple">capacity()</Item>
1073-
<Item Name="[allocator]" ExcludeView="simple">_Mypair</Item>
1074-
<ArrayItems>
1075-
<Size>_Mypair._Myval2._Mysize</Size>
1076-
<ValuePointer Condition="isShortString()">_Mypair._Myval2._Bx._Buf</ValuePointer>
1077-
<ValuePointer Condition="isLongString()">_Mypair._Myval2._Bx._Ptr</ValuePointer>
1078-
</ArrayItems>
1079-
</Expand>
1080-
</Type>
1081-
1082-
<Type Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char&gt; &gt; &gt;">
1083-
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char&gt; &gt; &gt;" />
1084-
<AlternativeType Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char8_t&gt; &gt; &gt;" />
1085-
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char8_t&gt; &gt; &gt;" />
1030+
<Type Name="std::_String_iterator&lt;*&gt;">
1031+
<AlternativeType Name="std::_String_const_iterator&lt;*&gt;" />
10861032
<SmartPointer Usage="Indexable">_Ptr,na</SmartPointer>
10871033
<Expand>
10881034
<Item Name="[ptr]">_Ptr</Item>
10891035
</Expand>
10901036
</Type>
10911037

1092-
<Type Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;wchar_t&gt; &gt; &gt;">
1093-
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;wchar_t&gt; &gt; &gt;" />
1094-
<AlternativeType Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;unsigned short&gt; &gt; &gt;" />
1095-
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;unsigned short&gt; &gt; &gt;" />
1096-
<AlternativeType Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char16_t&gt; &gt; &gt;" />
1097-
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char16_t&gt; &gt; &gt;" />
1098-
<SmartPointer Usage="Indexable">_Ptr,su</SmartPointer>
1099-
<Expand>
1100-
<Item Name="[ptr]">_Ptr</Item>
1101-
</Expand>
1102-
</Type>
1103-
1104-
<Type Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char32_t&gt; &gt; &gt;">
1105-
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char32_t&gt; &gt; &gt;" />
1106-
<SmartPointer Usage="Indexable">_Ptr,s32</SmartPointer>
1107-
<Expand>
1108-
<Item Name="[ptr]">_Ptr</Item>
1109-
</Expand>
1110-
</Type>
1111-
11121038
<Type Name="std::basic_string_view&lt;*,*&gt;">
11131039
<Intrinsic Name="size" Expression="_Mysize" />
11141040
<Intrinsic Name="data" Expression="_Mydata" />

0 commit comments

Comments
 (0)