2D Matrix Watch – Introducing autoexp.dat

Deep inside your VS installation (%VS installation%\Common7\Packages\Debugger), hides a bag of goodies called autoexp.dat.
It is only semi-official, and almost entirely undocumented. Andy Pennell confesses its his fault,  but I suspect there’s more to it.  Admittedly, its still (as of VS2008) fragile, can easily crash the IDE, subject to the dreaded ‘syntax may change’ disclaimer, and generally half baked.   All that being said, its probably the best productivity-enhancer I came across in the Visual Studio universe.

Lacking official documentation, Avery – creator of the VirtualDub video editor/converter – did a spectacular  job of reverse-engineering it (1, 2) .

autoexp’s prominent feature is customization of native variables watch, both as tooltip and in watch windows. Ever wondered how STL containers are wired to the IDE?    How come STL vectors show their contents automatically, but native arrays require manual work?

vec21

Wonder no more – the wiring is done by autoexp. If that sounds even remotely useful to you, go read Avery’s posts now.  You’ll never watch arrays, lists or hash tables the same way again.

now off to a first tweak using autoexp.

Suppose you have a Direct3D-like matrix type:

struct MATRIX
{
	float        _11, _12, _13, _14;
	float        _21, _22, _23, _24;
	float        _31, _32, _33, _34;
	float        _41, _42, _43, _44;
};

and the IDE isn’t doing a very good job of helping you grok its contents:

matwatch11

Fear not!  Declare a MatrixLine type, then re-declare the matrix as a union with an array of MatrixLines:

struct MatrixLine
{float f1, f2, f3, f4; };

struct MATRIX
{
 union
 {
 struct
 {
 float        _11, _12, _13, _14;
 float        _21, _22, _23, _24;
 float        _31, _32, _33, _34;
 float        _41, _42, _43, _44;
 };
 MatrixLine line[4]; // facilitates 2d matrix visualizer in autoexp.dat
 };
};

In autoexp.dat,  under the [Visualizer] section – define a preview for each MatrixLine, and set the Matrix watch to show its MatrixLines:

MatrixLine{
	preview(#([$c.f1,f],", ",[$c.f2,f],", ",[$c.f3,f],", ",[$c.f4,f]))
	children([$c,!])
}

MATRIX{
	preview([$e,!])
	children(
            #array (
                expr: $e.line[$i],
                size: 4
					)
			)
}

and enjoy your shiny new matrix watch!

matwatch21

About these ads

4 comments on “2D Matrix Watch – Introducing autoexp.dat

  1. […] March 5, 2009 at 10:44 am · Filed under Debugging, Visual Studio $err,hr is quite useful as is, but it only knows how to interpret built-in error codes. Happily, there is an easy way to extend it, via a section in autoexp. […]

  2. […] it used to be that to achieve that you used the [ExecutionControl] section in autoexp.dat, and seems it is widely believed to still hold. However, since 2003(!) the home of these setting is […]

  3. […] when navigating in legacy code the need often arises to watch CArrays, CLists, CMaps and the like. autoexp.dat provides only STL visualizers out of the box, but you can just paste the lines below into […]

  4. Kobi Kai says:

    good oniion mate!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s