This section of the archives stores flipcode's complete Developer Toolbox collection, featuring a variety of mini-articles and source code contributions from our readers.


  Enhanced Debugging Info For VS6/7
  Submitted by

Hello all,

My buddy and I found this tip while messing with Visual Studio's autoexp.dat file and we thought we'd share it with our fellow flipcoders. For those who don't know it, autoexp.dat (in the Common7\Packages\Debugger directory for VC7 or Common\MSDev98\Bin for VC6) is a text file used by the debugger to figure out what information to display in the 'Value' field of the debug windows (this, locals, watch1, etc...).

Normally, the debugger writes '{...}' as the value of an object, but with autoexp.dat, it will instead write specific information: For instance, in the case of a CPoint object where x=5 and y=-2, it will write '{x=5 y=-2}' in that field, in place of '{...}'. The advantage is obvious: you don't have to hit the + sign and look at the values of the member variables x and y yourself. It saves clicks and space.

Here is what the entry looks like for a CPoint object in autoexp.dat:
CPoint =x= y= ; <-- will display: {x=5 y=-2}

And so autoexp.dat defines what information the debugger should display for many types, among which is std::basic_string<...>. In that particular case, it displays the value of the _Bx._Buf member variable.

Here is the entry for strings (in VC7):
std::basic_string,std::allocator >=<_Bx._Buf> ; <-- will display: '{"Hello World"}'

And that's already wonderful, but as probably a lot of you have noticed, VC7 doesn't do really well with strings, sometimes it displays the right info, sometimes it doesn't.

The reason is that (in VC7) strings have two ways of storing the string data: locally, in a 16-byte buffer (_Bx._Buf) or dynamically through a pointer (_Bx._Ptr). That way, if your string is short enough (less than 15 characters), the string object will not need to allocate memory on the heap and you can take full advantage of inline constructor (in general).

Unfortunately, the debugger doesn't know how which one of _Buf or _Ptr it should display in the 'Value' field of the watch window, and the simple syntax of Autoexp.dat does not support conditional expressions. Fortunately, and that is what we would like to share with the community, Microsoft implemented an Addin library support for the debugger, and in our case for the 'evaluation' of objects and variables. Indeed, it is possible to tell the debugger to use an external library to figure out the information to display. The following entry, in autoexp.dat [...]
[...] tells the debugger that in the case of a _SYSTEMTIME variable, it should call the 'AddIn_SystemTime' function of the 'EEAddIn.dll' library (located in the Common7\IDE folder for VC7 or Common\IDE\IDE98 for VC6). The library then takes care of converting the data into a string of characters that the debugger will display in the 'Value' field of the watch window.

There actually is an help page (and a sample project) on how to build such a dll in the VC7 help (search for "EEAddIn"), but we thought we'd share our attempt at making one for strings (to cope with the problem of _Buf and _Ptr under VC7).

To use our dll file:
In autoexp.dat ("C:\Program Files\Microsoft Visual Studio .NET\ Common7\Packages\Debugger\autoexp.dat"), find the following entry:

std::basic_string,std::allocator >=<_Bx._Buf>

and replace it by:

; comment the old version
; std::basic_string,std::allocator >=<_Bx._Buf> std::basic_string,std::allocator >=$ADDIN(VSPCoreAddin.dll, AddIn_String)

Then copy the VSPCoreAddin.dll file to the "C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE" directory. That's it.

You can also have a look at our source code and implement your own complex data evaluation functions (for VC6 or VC7), just unzip the file and open the project.

The project is available here: (208k)

We hope this will be useful.

Jean Simonet
Olivier Basille

The zip file viewer built into the Developer Toolbox made use of the zlib library, as well as the zlibdll source additions.


Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.