As a partial solution you can add multiple conditional DisplayString
elements to each container type's information in a .natvis
file.
The limitation to this is that you can specify that elements only up to some fixed maximum be displayed in the DisplayString
debugger output (however, all elements are still displayed in the expansion area that you get when clicking on the variable's +
sign in the debugger display).
As an example, drop this into a file named %USERPROFILE%My DocumentsVisual Studio 2013Visualizerscustom.stl.natvis
:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="std::vector<*>">
<DisplayString Condition="(_Mylast - _Myfirst) > 3">[{_Mylast - _Myfirst}] ({_Myfirst[0]}, {_Myfirst[1]}, {_Myfirst[2]}, ...)</DisplayString>
<DisplayString Condition="(_Mylast - _Myfirst) == 3">[{_Mylast - _Myfirst}] ({_Myfirst[0]}, {_Myfirst[1]}, {_Myfirst[2]})</DisplayString>
<DisplayString Condition="(_Mylast - _Myfirst) == 2">[{_Mylast - _Myfirst}] ({_Myfirst[0]}, {_Myfirst[1]})</DisplayString>
<DisplayString Condition="(_Mylast - _Myfirst) == 1">[{_Mylast - _Myfirst}] ({_Myfirst[0]})</DisplayString>
<DisplayString>{{ size={_Mylast - _Myfirst} }}</DisplayString>
<Expand>
<Item Name="[size]">_Mylast - _Myfirst</Item>
<Item Name="[capacity]">_Myend - _Myfirst</Item>
<ArrayItems>
<Size>_Mylast - _Myfirst</Size>
<ValuePointer>_Myfirst</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
And in your next VS2013 C++ debug session vectors will show up to the first three elements in the debugger's DisplayString
output in a format similar to the old autoexp.dat display.
You can make the obvious additional edits to the custom natvis to display more than 3 elements. Unfortunately, you'll need to do something similar for each container type you want displayed this way; probably a good job for an intern.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…