Skip to content

Commit d9af48a

Browse files
committedDec 21, 2016
Improve natvis for llvm::SmallString so that it correctly displays only the valid portion of the string
The usual method, and the one employed before my change, of displaying strings in natvis is to make use of the "<variable>,s" format specifier; however, this method only works for null-terminated strings. My fix here is to use the "<pointer>,[size]" format specifier to display a bounded array, and then cast it to "const char*", which in the MSVC debugger has the desired effect of rendering the character array as a string. Differential Revision: https://reviews.llvm.org/D27972 llvm-svn: 290224
1 parent 46abc76 commit d9af48a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎llvm/utils/LLVMVisualizers/llvm.natvis

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ For later versions of Visual Studio, no setup is required.
5656
</Expand>
5757
</Type>
5858
<Type Name="llvm::SmallString&lt;*&gt;">
59-
<DisplayString>{BeginX,s}</DisplayString>
60-
<StringView>BeginX,s</StringView>
59+
<DisplayString>{(const char*)BeginX,[(char*)EndX - (char*)BeginX] na}</DisplayString>
60+
<StringView>(const char*)BeginX,[(char*)EndX - (char*)BeginX]</StringView>
6161
<Expand>
6262
<Item Name="[size]">(char*)EndX - (char*)BeginX</Item>
6363
<Item Name="[capacity]">(char*)CapacityX - (char*)BeginX</Item>

0 commit comments

Comments
 (0)
Please sign in to comment.