This is an archive of the discontinued LLVM Phabricator instance.

Improve natvis for llvm::SmallString so that it correctly displays only the valid portion of the string
ClosedPublic

Authored by amaiorano on Dec 19 2016, 9:52 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

amaiorano updated this revision to Diff 82064.Dec 19 2016, 9:52 PM
amaiorano retitled this revision from to Improve natvis for llvm::SmallString so that it correctly displays only the valid portion of the string .
amaiorano updated this object.

Goes from:


to:

Similarly for the StringView dialog (when you click on the magnifying glass).

amaiorano updated this revision to Diff 82065.EditedDec 19 2016, 10:05 PM

Added "na" format specifier to not show the pointer address to the string, just like the original visualizer did. Updated screenshot of what it looks like forthcoming...

Updated screenshot:

zturner accepted this revision.Dec 20 2016, 8:02 AM
zturner edited edge metadata.

Looks great, thanks

This revision is now accepted and ready to land.Dec 20 2016, 8:02 AM
This revision was automatically updated to reflect the committed changes.