Skip to content

Commit

Permalink
STL.natvis: Simplify visualization for string
Browse files Browse the repository at this point in the history
It appears that debugger visualizer accepts `na` regardless if underlying char type
  • Loading branch information
pps83 committed Dec 10, 2024
1 parent 89ca073 commit b8ad6ca
Showing 1 changed file with 5 additions and 78 deletions.
83 changes: 5 additions & 78 deletions stl/debugger/STL.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -1005,13 +1005,11 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
* wchar_t / unsigned short / char16_t = su format
* char32_t = s32 format
-->
<Type Name="std::basic_string&lt;char,*&gt;">
<AlternativeType Name="std::basic_string&lt;char8_t,*&gt;" />

<Type Name="std::basic_string&lt;*,*&gt;">
<Intrinsic Name="size" Expression="_Mypair._Myval2._Mysize" />
<Intrinsic Name="capacity" Expression="_Mypair._Myval2._Myres" />
<!-- _BUF_SIZE = 16 / sizeof(char) &lt; 1 ? 1 : 16 / sizeof(char) == 16 -->
<Intrinsic Name="bufSize" Expression="16" />
<!-- _BUF_SIZE = 16 / sizeof($T1) &lt; 1 ? 1 : 16 / sizeof($T1) -->
<Intrinsic Name="bufSize" Expression="16 / sizeof($T1) &lt; 1 ? 1 : 16 / sizeof($T1)" />
<Intrinsic Name="isShortString" Expression="capacity() &lt; bufSize()" />
<Intrinsic Name="isLongString" Expression="capacity() &gt;= bufSize()" />
<DisplayString Condition="isShortString()">{_Mypair._Myval2._Bx._Buf,na}</DisplayString>
Expand All @@ -1030,85 +1028,14 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
</Expand>
</Type>

<Type Name="std::basic_string&lt;wchar_t,*&gt;">
<AlternativeType Name="std::basic_string&lt;unsigned short,*&gt;" />
<AlternativeType Name="std::basic_string&lt;char16_t,*&gt;" />

<Intrinsic Name="size" Expression="_Mypair._Myval2._Mysize" />
<Intrinsic Name="capacity" Expression="_Mypair._Myval2._Myres" />
<!-- _BUF_SIZE = 16 / sizeof(wchar_t) &lt; 1 ? 1 : 16 / sizeof(wchar_t) == 8 -->
<Intrinsic Name="bufSize" Expression="8" />
<Intrinsic Name="isShortString" Expression="capacity() &lt; bufSize()" />
<Intrinsic Name="isLongString" Expression="capacity() &gt;= bufSize()" />
<DisplayString Condition="isShortString()">{_Mypair._Myval2._Bx._Buf,su}</DisplayString>
<DisplayString Condition="isLongString()">{_Mypair._Myval2._Bx._Ptr,su}</DisplayString>
<StringView Condition="isShortString()">_Mypair._Myval2._Bx._Buf,su</StringView>
<StringView Condition="isLongString()">_Mypair._Myval2._Bx._Ptr,su</StringView>
<Expand>
<Item Name="[size]" ExcludeView="simple">size()</Item>
<Item Name="[capacity]" ExcludeView="simple">capacity()</Item>
<Item Name="[allocator]" ExcludeView="simple">_Mypair</Item>
<ArrayItems>
<Size>_Mypair._Myval2._Mysize</Size>
<ValuePointer Condition="isShortString()">_Mypair._Myval2._Bx._Buf</ValuePointer>
<ValuePointer Condition="isLongString()">_Mypair._Myval2._Bx._Ptr</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<Type Name="std::basic_string&lt;char32_t,*&gt;">
<Intrinsic Name="size" Expression="_Mypair._Myval2._Mysize" />
<Intrinsic Name="capacity" Expression="_Mypair._Myval2._Myres" />
<!-- _BUF_SIZE = 16 / sizeof(char32_t) &lt; 1 ? 1 : 16 / sizeof(char32_t) == 4 -->
<Intrinsic Name="bufSize" Expression="4" />
<Intrinsic Name="isShortString" Expression="capacity() &lt; bufSize()" />
<Intrinsic Name="isLongString" Expression="capacity() &gt;= bufSize()" />
<DisplayString Condition="isShortString()">{_Mypair._Myval2._Bx._Buf,s32}</DisplayString>
<DisplayString Condition="isLongString()">{_Mypair._Myval2._Bx._Ptr,s32}</DisplayString>
<StringView Condition="isShortString()">_Mypair._Myval2._Bx._Buf,s32</StringView>
<StringView Condition="isLongString()">_Mypair._Myval2._Bx._Ptr,s32</StringView>
<Expand>
<Item Name="[size]" ExcludeView="simple">size()</Item>
<Item Name="[capacity]" ExcludeView="simple">capacity()</Item>
<Item Name="[allocator]" ExcludeView="simple">_Mypair</Item>
<ArrayItems>
<Size>_Mypair._Myval2._Mysize</Size>
<ValuePointer Condition="isShortString()">_Mypair._Myval2._Bx._Buf</ValuePointer>
<ValuePointer Condition="isLongString()">_Mypair._Myval2._Bx._Ptr</ValuePointer>
</ArrayItems>
</Expand>
</Type>

<Type Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char&gt; &gt; &gt;">
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char&gt; &gt; &gt;" />
<AlternativeType Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char8_t&gt; &gt; &gt;" />
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char8_t&gt; &gt; &gt;" />
<Type Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;*&gt; &gt; &gt;">
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;*&gt; &gt; &gt;" />
<SmartPointer Usage="Indexable">_Ptr,na</SmartPointer>
<Expand>
<Item Name="[ptr]">_Ptr</Item>
</Expand>
</Type>

<Type Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;wchar_t&gt; &gt; &gt;">
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;wchar_t&gt; &gt; &gt;" />
<AlternativeType Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;unsigned short&gt; &gt; &gt;" />
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;unsigned short&gt; &gt; &gt;" />
<AlternativeType Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char16_t&gt; &gt; &gt;" />
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char16_t&gt; &gt; &gt;" />
<SmartPointer Usage="Indexable">_Ptr,su</SmartPointer>
<Expand>
<Item Name="[ptr]">_Ptr</Item>
</Expand>
</Type>

<Type Name="std::_String_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char32_t&gt; &gt; &gt;">
<AlternativeType Name="std::_String_const_iterator&lt;std::_String_val&lt;std::_Simple_types&lt;char32_t&gt; &gt; &gt;" />
<SmartPointer Usage="Indexable">_Ptr,s32</SmartPointer>
<Expand>
<Item Name="[ptr]">_Ptr</Item>
</Expand>
</Type>

<Type Name="std::basic_string_view&lt;*,*&gt;">
<Intrinsic Name="size" Expression="_Mysize" />
<Intrinsic Name="data" Expression="_Mydata" />
Expand Down

0 comments on commit b8ad6ca

Please sign in to comment.