Will P
Will P

Reputation: 192

Change order of display variables in Visual Studio Debugger

I've got an issue with how Visual Studio is displaying my variables during debugging. I develop on two computers, both on VS2012, and they have the same versions of the development libraries installed, and they display the order of variables in a class differently.

Seems inconsequential, but I'm using a math library (GLM) and when I break and inspect a variable, the order they are shown is different:

enter image description here

The type is a glm::vec3, which is defined by 3 floats x, y, z, but the library is designed to be as close syntactically to glsl, so it also contains other names for the variables (rgb, stp) which really are just references(x=r=s, y=g=t, z=b=p). On my other machine, the preview shows x y and z values, which is what I want.

Viewing these is a pain on this machine, as I have to click the drop down to inspect each individual variable, and the lists of vectors I'm working with can be 100's or 1000's of items long. I also can't print them out in the immediate window and inspect that way either because it prints in the same order.

Anything I can change?

edit:

I needed to update the autoexp.dat file, but it doesn't seem to be working for me. I opened a sample file in VS2010 which I have installed, and modified it's autoexp.dat and it worked great.

One thing I did notice is that my VS2012 is installed in C:\Program Files(x86), rather than C:\Program Files(X86)\Microsoft Visual Studio 11.0 (my 2010 is installed in the correct location), so my Common7 folder is C:\Program Files(x86)\Common7

Is that a problem?

Upvotes: 2

Views: 576

Answers (1)

KeatsPeeks
KeatsPeeks

Reputation: 19337

In VS2012 and later, autoexp.dat has been superseded by the native type visualization framework (natvis).

This works with an xml file with .natvis extension, which can be put at three different locations :

  • %VSINSTALLDIR%\Common7\Packages\Debugger\Visualizers (requires admin access)
  • %USERPROFILE%\My Documents\Visual Studio 2012\Visualizers\
  • VS extension folders

Your .natvis file should look like this (replace TheType by the name of the class you want to visualize) :

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="TheType">
        <DisplayString>x = {x} y = {y} z = {z}</DisplayString>
    </Type>
</AutoVisualizer>

On MSDN : Create custom views of native objects in the debugger

Upvotes: 3

Related Questions