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
3
votes
0 answers

Visual Studio NatvisFile add leading zeros to DisplayString

I want to adjust my Visualizer in Visual Studio 2017 via the Nativis file. There is an own class date, which should be displayed more nicely in the debugger. "{1900 + ts.tm_year}-{1 +…
Bowers
  • 836
  • 8
  • 20
3
votes
1 answer

How to propagate ExcludeView/IncludeView in natvis?

So, say I have 2 classes, C and B where they have a composition relationship, C is composed of B. struct C { }; struct B { C c; }; Now, I have a natvis file that has 2 views of C. Must I explicitly propagate this view from B to C? This sounds…
Adrian
  • 10,246
  • 4
  • 44
  • 110
3
votes
1 answer

Is it possible to NATVIS a recursive tuple (variadic template)?

I implemented the tuple from here: https://voidnish.wordpress.com/2013/07/13/tuple-implementation-via-variadic-templates/ Is it possible to visualize it with NATVIS? I got as far as ()
Alex
  • 846
  • 6
  • 16
3
votes
1 answer

Natvis TreeItems definition not working on map

I'm having trouble with the natvis extension of visual studio 2015. In my efforts I need to access a map, but the TreeItems node of natvis does not seem to work for me. I'm actually using the sample code:
xeed
  • 925
  • 8
  • 22
3
votes
1 answer

Visual Studio .natvis file - matrices

I'm trying to display a matrix class in the Visual Studio 2013 debugger. The relevant part of the class is this: class mat { private: size_t rowdim, coldim; double* _mem; }; I'm trying to visualise this as a multi-dimensional array but I…
3
votes
1 answer

Is there any unofficial visualizer for debugging Qt 4.8 projects in Visual Studio 2013?

Where are files required for debugging support of Qt 4.8 types in Visual Studio 2013? I've heard about *.natvis files, but I've found only Qt5 *.natvis files for Visual Studio 2013 or Qt4 *.natvis for Visual Studio 2012. They don't work for me. Are…
ilya
  • 1,103
  • 14
  • 36
3
votes
1 answer

Expand members of templated type on first expansion level of natvis visualiser

The default visualiser for shared_ptr in VS2013 has this (many, many things trimmed out!): _Ptr This means that in the debugger…
Ben Hymers
  • 25,586
  • 16
  • 59
  • 84
2
votes
1 answer

How to create a specific view using natvis debug visualizer?

I'm using the Microsoft extension Image Watch to preview OpenCV images. I'm trying to visualize images that are inside a container by adding their container key, but the Visual Studio debugger watch window doesn't support directly adding a variable…
Cesar
  • 41
  • 2
  • 5
  • 16
2
votes
0 answers

Build custom string in natvis file out of separate chars

I have a type which represents "Battleship" coordinates: struct BattleshipCoordinates { int row; // zero-based row offset int col; // zero-based column offset } Note that the coordinates are stored natively as zero-based index offsets. I…
BTownTKD
  • 7,911
  • 2
  • 31
  • 47
2
votes
0 answers

Reuse Natvis STL visualization fields in custom visualization

Question When writing custom Natvis visualizations for Visual Studio, (how) can I access fields of a lambda wrapped in a std::function? Concrete example I have a class looks somewhat like this (very simplified): class VariableVector { public: //…
Robin
  • 333
  • 1
  • 12
2
votes
0 answers

Display range of value using Natvis

I have an array (limit_array) which is pointed by a pointer (limit_ptr). For simplicity, here I have given an array of length 10. Using IndexListItems of natvis I can iterate through the value which is pointed by the pointer limit_ptr. But in some…
user10634362
  • 549
  • 5
  • 21
2
votes
0 answers

inspect heap allocated array or matrix while debugging c++

I'm using vscode to debug some c++ code, however I cannot inspect any (heap allocated) objects. Like in this example: float arrayStack[10]; for (size_t i = 0; i < 10; i++) { arrayStack[i] = -42.3; } float *arrayHeap = new float[10]; for…
mcExchange
  • 6,154
  • 12
  • 57
  • 103
2
votes
0 answers

How to propagate the view type in natvis from standard containers to their items?

It is possible to define different views for types specified in natvis files, however i don't know a way to propagate these views through standard containers without modifying or rewriting the containers natvis. I have the following test C++ -…
jesses
  • 559
  • 3
  • 15
2
votes
0 answers

Is it possible for a visual studio debug visualizer (natvis) to perform a map lookup?

So I have a type, which is used as a key into a map. The key itself isn't particularly human readable (e.g. a 128 bit guid), but the value in the map that this key references, is. Is it possible, without modifying the code (I've seen methods used…
Dan Forever
  • 381
  • 2
  • 12
2
votes
1 answer

Using natvis with template parameter packs

I have a data structure that looks roughly like this struct Column { void* data; }; template struct Table { size_t count; std::vector columns; // columns.size() == sizeof...(T) }; and I'm trying to visualize it in…
Adam
  • 1,122
  • 9
  • 21