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
1
vote
2 answers

Natvis FourCC visualisation syntax

I'm trying to define a .natvis for a uint32_t type, to show as an array of four characters, which in the Watch window, during debugging, would be expressed a bit like this: (char*)&fourcc,4. Unfortunately, natvis doesn't seem to like…
zyndor
  • 1,418
  • 3
  • 20
  • 36
1
vote
1 answer

Is there a method to automatically attach a .natvis to debug session started using -DebugExe?

I am working with a solution that includes a .natvis in its tree. The workflow requires that I often start debug sessions of various solution's executables using devenv.exe's /DebugExe switch. But when started this way, the .natvis file isn't used…
1
vote
1 answer

VisualStudio .natvis: can I have a custom complex item in CustomListItems?

In C++, I have an array of integers which I want to visualize, which elements are like this: [0] [1] [2] [3] ... [n] 0 So, I'd like to visualize…
Mike Kaganski
  • 701
  • 6
  • 18
1
vote
1 answer

How to reference variable itself from the natvis expression in C language?

Are there any analog of the C++ this keyword, that can be used in natvis expressions when debugging C code? I would like to do the following and have no mind how to do it without this. Consider we have some struct in C: typedef struct { int…
Oleg Skydan
  • 681
  • 1
  • 5
  • 5
1
vote
2 answers

natvis - Add tabulator to output

Is there a way to format the final output value string of the watch window with tabulators or other usually escaped symbols? I have tried: x={myVal.x}, y={myVal.y},…
Peter Merkert
  • 354
  • 5
  • 14
1
vote
1 answer

Extend Image Watch With COLUMN-major matrix type

I want to extend Image Watch with a *.natvis description for my own matrix class. The data in this matrix class is stored in column major format, in contrast to the row major order of OpenCV. I were able to display my matrices like transposed with…
Knipser
  • 347
  • 1
  • 13
1
vote
2 answers

How to visualise a simple std::string with natvis?

I can't have a decent view of a basic std:string in VS2015 while debugging. I followed the instructions given at this address :https://msdn.microsoft.com/fr-fr/library/jj620914.aspx (that is debugger type set to native mode, and uncheck both Use…
Malick
  • 6,252
  • 2
  • 46
  • 59
1
vote
0 answers

Visual Studio 2015 Natvis thinks QString is an enum instead of a type

In Visual Studio 2015, Update 3, I'm using a customized version of Qt5.natvis (from the old VS Add-In) added to my solution files. Sometime after adding blocks for QFlags, QString is now getting picked up as an enum. Natvis tells me Natvis:…
John Neuhaus
  • 1,784
  • 20
  • 32
1
vote
2 answers

Looking for a visual studio visualizer (natvis) for JsonCpp

I'm looking for a natvis file for JsonCpp and I can't find any. Does anyone know of such a file?
Motti
  • 110,860
  • 49
  • 189
  • 262
1
vote
2 answers

Visual Studio .natvis file, array of class visualization

I have classes that basically look like the following and I would like to make then more readable in Visual Debugger: template struct tvec4 { T x, y, z, w; }; template
Christophe
  • 165
  • 8
1
vote
1 answer

Vs 2012 natvis: possible to define class in xml?

I am currently trying to create a natvis XML file for a large Project at work. We have a Pointer to a type, which the Debugger knows nothing of (Information hiding with a typedef, it was a stupid idea by the author, but can't be changed at the…
Lukas Rieger
  • 676
  • 10
  • 31
0
votes
0 answers

Replace pdb natvis type definition by installed vsix natvis

We have .natvis file with basic type definitions embedded in the .pdb. Then we have an VSIX with .natvis provides more information. We would like to use the base .natvis when the vsix is not installed, and when the vsix is installed, use the .natvis…
Lea
  • 1
0
votes
0 answers

Visual Studio Natvis file for a class with its containing map

I try to start with C++, Cmake. Now I find the possibility to customize the debugger view in Visual Studio 2022 with the natvis file. The file is used by the debugger, but actually I don't understand how I can display the item of a containing…
0
votes
0 answers

MSVC 2022 / natvis definition only shows in datatip but not in local/watch window

I defined a natvis file like this: and I can see the effect in the Datatips when hovering over a variable name: But the definition not use in the Local or Watch window in the debugger: Only the stand view is shown, and the display string isn't…
0
votes
0 answers

VS Code: Custome natvis doesn't work when template parameter is size_t

Here is the natvis: Works with int: Doesn't work with size_t: Softwares: g++: 11.3.0 vscode: size_t is actualy long unsigned int, and I think the reason is 3 keywords, because when you remove one of them it works.