fenbf / cppstories-discussions

4 stars 1 forks source link

2021/natvis-dbg-tip/ #1

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

A Debugging Tip: Write Custom Visualizers in Visual Studio - C++ Stories

In Visual Studio, when you work with types from the C++ Standard Library or other common APIs, you might be familiar with a concise view of those objects in debugger. You can hover a mouse over an entity, and then the debugger presents short information about their current state. For example:

http://localhost:1313/2021/natvis-dbg-tip/

VincentZalzal commented 3 years ago

Custom visualizers are really useful and underused, in my opinion. We used some at my previous works, and they were especially useful for custom non-contiguous containers. Also, it can help make some data more readable. For example, a 3x3 or 4x4 matrix can be displayed on 3 or 4 lines, as a matrix. Another interesting possibility is to show more information than is stored in the object, by computing it in the visualizer. For example, say you have a box type with min and max member variables. You could also show values for its center and size in the visualizer.