Questions tagged [natvis]

Visual Studio uses .natvis files to visualize C++ types in debugger. Natvis file format replaces older autoexp.dat in previous versions of Visual Studio.

Visual C++ debugger uses .natvis files get a user friendly visualization of C++ types. Natvis files are new to Visual Studio 2012.

In addition to C++ libraries supplied by Microsoft, some 3-rd party libraries come with Natvis-enabled support, for example C++ library.

The format of the files is XML based. Here is an example of how std::string is displayed:

<Type Name="std::basic_string&lt;char,*&gt;">
    <DisplayString Condition="_Myres &lt; _BUF_SIZE">{_Bx._Buf,s}</DisplayString>
    <DisplayString Condition="_Myres &gt;= _BUF_SIZE">{_Bx._Ptr,s}</DisplayString>
    <StringView Condition="_Myres &lt; _BUF_SIZE">_Bx._Buf,s</StringView>
    <StringView Condition="_Myres &gt;= _BUF_SIZE">_Bx._Ptr,s</StringView>
    <Expand>
        <Item Name="[size]">_Mysize</Item>
        <Item Name="[capacity]">_Myres</Item>
        <ArrayItems>
            <Size>_Mysize</Size>
            <ValuePointer Condition="_Myres &lt; _BUF_SIZE">_Bx._Buf</ValuePointer>
            <ValuePointer Condition="_Myres &gt;= _BUF_SIZE">_Bx._Ptr</ValuePointer>
        </ArrayItems>
    </Expand>
</Type>
116 questions
18
votes
2 answers

Using std::type_info for casting in natvis

In the codebase I'm working, we use std::any instead of void* to pass classes through some generic non-template code. Specifically, we use Visual Studio 2019, its compiler and standard library. In order to visualize the std::any, microsoft already…
JVApen
  • 11,008
  • 5
  • 31
  • 67
17
votes
8 answers

I am looking for a proper way to display a UUID via NatVis in VS2012

I am looking for a proper way to display a UUID via NatVis in VS2012. My own uuid type uses UUID big-endian internally so a cast to (GUID*) does not work as GUID uses little-endian in Windows. So I always see a misrepresented uuid. Furthermore any…
16
votes
1 answer

Using .natvis file to visualise C++ objects in VS Code

According to this link, .natvis files can be used to visualise native objects. Specifically, I would like to be able to inspect Eigen::Matrix objects using this .natvis file. However, the link above does not contain any information on how to…
Toivo Säwén
  • 1,905
  • 2
  • 17
  • 33
15
votes
6 answers

Can I control the number of digits displayed in debugger windows for float and double variables?

In Visual Studio 2012, I'm looking for a way to customize the default display of floating point types in the Autos, Locals, and Watch windows. I'm familiar with the Native Visualizer (Natvis) utility, but don't see any debugger formatting facilities…
Jay Carlton
  • 1,118
  • 1
  • 11
  • 27
9
votes
1 answer

VS2015 Visualiser, (*.natvis) DisplayString call a function to display the value

I have a complex class, (MyClass), that has a function called ToString(), the function returns a string representation of the string. I would like the visual studio visualiser to use that function to display the variable This is my visualizer,…
FFMG
  • 1,208
  • 1
  • 10
  • 24
8
votes
2 answers

Visual Studio Natvis DisplayString Conditionals

Using Visual Studio 2017, I'm writing a Visualizer for some classes, but I'm running into issues with respect to the .natvis code readability. I have a custom Array type, and I would like to display its members in the Watch window's Value field…
8
votes
1 answer

.natvis - how to reference a template template parameter?

I'm trying to create a .natvis file for visual studio. According to this page I can reference a template parameter with $T1, $T2 and so on. So in the case of MyClass $T1 will reference the type A. This works. But in my case A is a template itself…
nikitablack
  • 4,359
  • 2
  • 35
  • 68
8
votes
2 answers

Natvis Floating-Point Format

Yesterday I discovered MSVC's "Natvis" tool, which allows you to tweak the debugger to present your types in an intelligent way. I quickly set about prettifying my math library. Here's how my 3*3 matrix class looks (uninitialized…
geometrian
  • 14,775
  • 10
  • 56
  • 132
8
votes
3 answers

User defined natvis files in Visual Studio 2012

I'm trying to use new debug visualizers in my project, but something happened to Visual Studio and it does not pick up my natvis files anymore. I tried copying them to %USERPROFILE%\My Documents\Visual Studio 2012\Visualizers as well as to \Program…
Max
  • 19,654
  • 13
  • 84
  • 122
7
votes
2 answers

Is there a way around "This expression has side effects and will not be evaluated."?

In Visual Studio 2017, I have create a .natvis debugger visualization rule which calls a C++ function. In the debugger it shows: This expression has side effects and will not be evaluated. Beside this, it shows a little blue arrow that can be…
uglycoyote
  • 1,555
  • 1
  • 19
  • 25
7
votes
3 answers

Visual Studio & Natvis not working

I'm using VS Ultimate 2012 Update 5 : Microsoft Visual Studio Ultimate 2012 Version 11.0.61219.00 Update 5 Microsoft .NET Framework Version 4.5.50938 ... and try to use/install natvis to get user defined debugger variable vizualisations. I did…
BartmanDilaw
  • 398
  • 4
  • 15
6
votes
2 answers

How to display template parameter type name in natvis?

I want to extend a natvis visualizer for a (C++) template class. Is there a way to display a type name of the first template parameter? It would be great for boost::variant v; v=1; to display 1 (int) or something like that
Roman Khvostikov
  • 305
  • 3
  • 14
6
votes
1 answer

Function local structs/classes and natvis files

Let's say I have to following struct: template struct TSH2SizedArray { inline void Add(const Type & Value); inline Type & operator[](int32 Index); inline const Type & operator[](int32 Index)const; private: …
6
votes
1 answer

Limit display of char* in natvis file to specific length

I've got a custom data structure holding a char* buffer with two lengths associated: maximum and actual length: struct MyData { char* data; int length; int capacity; }; In the Visual Studio (2015) debugger visualizer I only want to display…
Torbjörn
  • 5,512
  • 7
  • 46
  • 73
6
votes
1 answer

How can Visual Studio 2015 Natvis display a function static variable?

I am writing debugger visualizers using a .natvis file in Microsoft Visual Studio 2015. There is one piece of information in my class that I would like to get at if possible. I'm wondering what the syntax would be to get at that variable. Here is a…
Ben
  • 1,003
  • 1
  • 11
  • 18
1
2 3 4 5 6 7 8