An important aspect of modern C++ programming is the use complex data types, whether sourced from the Standard Library, Boost or other third party libraries.
This can lead to difficulties during debugging when these objects are not correctly represented in the debugger variable windows.
As my own personal debugging ‘experience’ was being hampered as a result of my rather enthusiastic use of boost::optional (arguably too enthusiastic… and possibly a topic for a future blog post), I decided to do some some research and came across the subject of Visual Studio’s Visualizers on Mateusz Loskot’s blog. This certainly seemed to be a major step up from the various workarounds I have had to use in the past.
In fact, it seems that Visualizers have been around since Visual Studio 2005. This is how common data types, such as std::vector, are handled ‘out the box’.
Prior to Visual Studio 2012, configurations for any additional Visualizers have been made by appending to the autoexp.dat file located at:
So, for example, to add handling for some of the common Boost types you just need to copy and paste into this file the various samples detailed on the Boost documentation page. For more information on the syntax required, refer to this blog.
With the release of Visual Studio 2012 Visualizers have evolved, are now XML based and can be located in standalone ‘natvis’ (short for “native type visualization framework”) files. They can also be easily installed as part of a VSIX package.
The ‘natvis’ format Visualizers for Boost do not seem to be available (or even mentioned) on the Boost docs page yet so it is not clear if this is ‘work in progress’. However I did find some Boost ‘natvis’ files created by Arkadiy Shapkin. These are conversions of the autoexp.dat configurations mentioned above.