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

Local variables for Visual studio natvis statements

I'm currently writing a visualiser for a date type in natvis. The date type stores seconds since 1970 in the usual unix way but deriving year, month and day of the month from that is extremely long winded if not using temporary variables. I'd like…
Luther
  • 1,786
  • 3
  • 21
  • 38
5
votes
1 answer

NatVis: typedefs allowed?

I have a type defined as: typedef unsigned short StringChecksum; which I eventually intend to use a NatVis to display the corresponding value in a global string table we have loaded in memory. So I've defined a new NatVis for testing(which is my…
ColinCren
  • 595
  • 3
  • 13
4
votes
2 answers

NatVis display substring of enum

We often use prefix for our enums. It is very verbose to display full name in NatVis. Is it possible to remove prefix of enum name (AKA return substring of enum name) ? enum FooFormat { FooFormat_Foo, FooFormat_Bar, FooFormat_Baz, …
Raymond
  • 885
  • 10
  • 28
4
votes
1 answer

How to handle similar class names in different solutions, using native visualisers

In my company we are working with native visualisers (.natvis files) for debugging memory dumps in Visual Studio. As we have equal class names for different projects, we are thinking of including .natvis files in the project definitions, and this…
Dominique
  • 16,450
  • 15
  • 56
  • 112
4
votes
1 answer

How to add custom Visual Studio debug view of Python object?

I'd like to add a useful visualization of a Python openpyxl ReadOnlyCell object during debugging in Visual Studio 2015 (Python tools). I read into natvis files, but they seem to be only for C++ projects. For example, the screenshot below shows what…
Aralox
  • 1,441
  • 1
  • 24
  • 44
4
votes
2 answers

Access to vector underlying data in .natvis files for Visual Studio ImageWatch plugin

The problem Similar to this question, I am trying to use the ImageWatch plugin for my own defined type MyImageClass. ImageWatch is a Visual Studio Plugin that allows you to view Images in a graphical representation while debugging code. You can…
kiki
  • 325
  • 6
  • 20
4
votes
1 answer

Qt5.natvis doesn't work in VS 2015 Update 2

I'm trying to use qt5.natvis file in VS2015 Update 2, but I still see only pointer address for Qt structures. I placed the file inside C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\Debugger\Visualizers Here's the code I am…
Roman Volkov
  • 245
  • 1
  • 4
  • 12
4
votes
1 answer

Natvis visualizer for c++ union/structure

I'm trying to implement a personal visualizer using msvc natvis visualizer. The problem is that I don't know how to do it regarding union. A simple example with a structure ( value) containing a union of two structure (string1 and string2 ): typedef…
Malick
  • 6,252
  • 2
  • 46
  • 59
4
votes
0 answers

Visual Studio natvis and incomplete types

I'm writing a natvis file for a project where some structs are defined "privately", that is to say in .c code files rather than headers. When I'm debugging the module within which the structs are defined the debugger picks them up, but when dealing…
4
votes
0 answers

VS2012 debug visualisation problems

I am using the natvis system to make debugging my custom types easier. I have a simple array type that I wish to make expandable... used={m_used} ptr={m_ptr}
Stimpleton
  • 41
  • 1
3
votes
0 answers

How do I visualize custom classes in the debugger in a visual studio cross-platform CMake project?

I'm currently getting into cross-platform development using visual studio and CMake. Before, I would only create native Visual Studio applications and I could easily create debug visualizations of custom classes using natvis files. However, every…
Dehim
  • 61
  • 3
3
votes
2 answers

NATVIS reinterpret type or alias type

Is there a way in natvis to reinterpret a type to an already natvis-defined type ? or alias it ? For example, I'd like to do this kind of "trick" (really necessary in my context even if that does sound really weird to you, it's a question of JIT…
Juicebox
  • 442
  • 4
  • 11
3
votes
2 answers

How to see Qt5 QString contents while debugging on Visual Studio 2015

I'm using visual studio 2015 and Qt5. I'have already added qt5.natvis on Vislaualizers folders. I have set the "Use Native Compatibility Mode" option in Tools > Options > Debugging > General menu. Even so, QString value does not appear correctly…
Adso4
  • 111
  • 3
  • 10
3
votes
2 answers

How to display underlying data in a type erasure class using shared_ptr

Ok, so I've got a pretty straightforward class making use of type erasure, using a shared pointer. class Prop { struct PropConcept { virtual ~PropConcept() {} }; template struct PropModel : PropConcept { …
Digital_Utopia
  • 816
  • 8
  • 17
3
votes
2 answers

How to avoid recursion in native visualisers?

I'm debugging a C++ program, which contains quite some CPtrArray objects. Using a customised heap_stat script, I know the pointer values of the CPtrArray objects, which contain a lot of entries. Using native visualisers, I can indeed see the amount…
Dominique
  • 16,450
  • 15
  • 56
  • 112