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
1 answer

Using a runtime string to specify object type in natvis

Say I have a struct struct Foo { void* bar; const char* barTypeName; } bar is some type erased thing and barTypeName is a proper C++ type identifier that identifies the actual type of bar. I want to visualize this in the Visual Studio…
1
vote
1 answer

How to limit natvis of a single char to only the character in VisualStudio

When creating a {a_char,c} in a .natvis file, the char is being displayed as f.e. 82 'R' I'm looking for a way to display it as 'R' e.g. without the number.
jesses
  • 559
  • 3
  • 15
1
vote
0 answers

Qt4.natvis not working in VSCode on Centos 7

I am using VSCode to develop with Qt4 on Centos 7 over SSH. My launch.json reads: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit:…
Andy Bisson
  • 580
  • 5
  • 19
1
vote
0 answers

VSCode Accessing Local Created Variable in Natvis

I have the following natvis code for visualizing my q23_t class (part of a larger natvis file) in the debugger.I cannot get natvis to show the value of ibit23 which is a locally defined variable. I get the following error: -var-create: unable to…
1
vote
1 answer

How to make multiple list expansions for a single type using natvis Visual Studio C++ debugger visualizer

I'm trying to make debugger visualizer for container that stores values in chunks. I want to make list expansion both for values and for chunks, but as far as I can see single type can have only one list expansion. There may be multiple Expand…
1
vote
1 answer

C++/WinRT natvis doesn't work in fresh install

How can I trouble-shoot this? I combined the natvis example in this question with the C++/WinRT console template and succeeded in getting the natvis for the Matrix2d to work but not for the Uri. #include "pch.h" using namespace winrt; using…
Tom Huntington
  • 2,260
  • 10
  • 20
1
vote
1 answer

How to visualize a column order matrix with natvis like a 2d array

I have a struct struct Matrix2d { // Column first ordered elements vector m_elements; int m_numRows; int m_numCols; }; m_elements stores {0, 1, 2, 3, 4, 5, 6, 7, 8} to represent the 2d matrix 0, 3, 6 1, 4, 7 2, 5, 8 I want to…
user3064869
  • 530
  • 1
  • 6
  • 19
1
vote
1 answer

Why does this std::map not display in a useable way in the watch window of Visual C++?

I'm unable to view certain std::map in the watch window. Looking into the .natvis file, there are multiple implementations for std::map. Is there a way to select one or the…
user12411795
1
vote
1 answer

Matrix display row wise

I know the default ArrayItems-Tag can handle matrices, but I find the result insufficient. Given this example #include #include struct matrix { int height; int width; double* values; }; int main() { double* values =…
user2329125
1
vote
1 answer

C++ Partial Template Specialization and Natvis

I'm trying to create Visual Studio debug visualizers for a partially specialized type. For example, let's say I have something like this: template struct Foo { T bar; }; template struct Foo { T baz; }; Without…
Zeenobit
  • 4,954
  • 3
  • 34
  • 46
1
vote
2 answers

Natvis visualizer to view member pointer type as array

In the Visual Studio 2015 watch window, pointers can be watched as array by adding a comma and the array length, e.g. d,10 will display 10 elements for a double * d. Is it possible to create a Natvis Type Entry which does this based on the number of…
wonko realtime
  • 545
  • 9
  • 26
1
vote
0 answers

Eigen.natvis addition for Eigen::Map

I am trying to add to the Eigen.natvis, found here, so that Eigen::Map objects can also be read in the Visual Studio debugger, Eigen library found here. Here is what I put together:
AOK
  • 493
  • 5
  • 16
1
vote
2 answers

How to debug Windbg? (How to get information about what Windbg is doing)

As most of you know, Windbg can be used for debugging programs, but now I'd like to do just the opposite: I'd like to debug what I'm doing in Windbg, let me show you why: I've found an interesting native visualiser, containing following…
Dominique
  • 16,450
  • 15
  • 56
  • 112
1
vote
1 answer

natvisreload using Visual Studio Professional 2017 : syntax error

I'm trying to do dump analysis using Visual Studio Professional 2017, but when entering the command .natvisreload in the watch-window I get syntax error and there is nothing in the output window. (This seems to mean that the command is not…
Dominique
  • 16,450
  • 15
  • 56
  • 112
1
vote
1 answer

How to get std::pair to display as a proper string segment in Visual Studio's debugger?

How do I get std::pair to display as a proper string segment in Visual Studio, rather than as two pointers to null-terminated strings?
user541686
  • 205,094
  • 128
  • 528
  • 886