An Easy Way to Visualize Customize Data Structure in Visual Studio
Start from Visual Studio 2005, STL containers can be shown in the Watch windows, and we can expand the tree-like control to navigator through the whole data structure to exam every element of the container. This brings a great benefit of debugging code, and it is one of the major reason why I prefer STL containers.
While working with legacy code there are a lot of customized data structures which doesn’t implemented well enough for the debugger to figure out its data structure automatically. Thus it cannot be shown in the Watch window other than a plain pointer address, even with symbol set up correctly. This really becomes an debug obstacle.
Once a while I believe that in order to get over the problem we have to implement an extension, like it is described in the following articles:
- How to create a debugger visualizer for Visual Studio (C# tutorial)
- Authoring Visual Studio Debugger Visualizers
Well there turned to be another way easier approach. Under <VisualStudio Install Location>\Common7\Packages\Debugger there is a file named autoexp.dat. Open it with any text editor we could see a bunch of interesting stuff. It looks like that all those find STL/ATL Watch stuff is defined in this file!
The header of the file described how to add your own definition for the customize data structure. There is a great article also covered a good amount of details. See the following link:
Now armed with the new trick, my debugging life becomes easier!