How do I use Natvis?
natvis file:
- Select the C++ project node in Solution Explorer, and select Project > Add new item, or right-click the project and select Add > New item.
- In the Add New Item dialog, select Visual C++ > Utility > Debugger visualization file (. natvis).
- Name the file, and select Add.
Where do you put Natvis files?
Visual Studio provides some . natvis files in the %VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers folder. These files have visualization rules for many common types, and can serve as examples for writing visualizations for new types.
What is a Natvis file?
A NATVIS file is a debugger visualization file used by Microsoft Visual Studio, a software development tool used to create Windows programs and web applications. It contains one or more Type elements, or visualization rules, in XML format. You can open and edit NATVIS files in Visual Studio.
How to create a Visual Studio project using natvis?
Start Visual Studio and open any of the VisualGDB Project Wizards. In this example we will create a Linux project, however the same technique will also work for Embedded, Windows and Android projects. As Natvis files do not require any special steps in the project wizard, you can simply proceed with the default ones.
Where to find dog.natvis in visualizers?
Copy Dog.natvis to the Visualizers folder in your installation directory for Debugging Tools for Windows. For example: Run your program, and break in at the main function. Take a step so that the variable MyDog gets initialized.
Can a natvis file show the contents of a list?
Notice that by default you won’t easily see the contents of the entire list, as only the first and the last elements are directly referenced from the list object. We will now create a .natvis file that will tell VisualGDB how to display the contents of your list.
Can you access local variables in natvis expressions?
For example, x in a Natvis expression refers to the field named x in the object being visualized, not to a local variable named x in the current function. You can’t access local variables in Natvis expressions, although you can access global variables. Natvis expressions don’t allow function evaluation or side effects.