Auto-Expanding User-Defined (and STL) Types in the Debugger
In Visual C++ 5 (and probably 6, although I don't have it to test), there is an undocumented feature that controls this display (called auto-expansion). It is controlled by a file named AutoExp.DAT in the \DevStudio\SharedIDE\Bin directory. That file is pretty much self-documenting. An excerpt from the file reads:
"While debugging, Data Tips and items in the Watch and Variable windows are automatically expanded to show their most important elements. The expansion follows the format given by the rules in this file. You can add rules for your types or change the predefined rules."
To resolve my frustration with std::string, I simply added the following lines in the [AutoExpand] section of the file:
; from string std::basic_string<char,std::char_traits<char>,std::allocator<char>> =<_Ptr,s>
Note that the spacing (or lack thereof) is important. Also note that I
was not able to use just std::string or std::basic_string< If you use Unicode and std::wstring, you'll need an entry such as the
following (untested):
You'll also need to change the DisplayUnicode setting to 1 in the
[Unicode] section of the file so that Unicode strings are automatically
expanded as text, rather than arrays of unsigned short.
std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>> =<_Ptr,su>

Comments
Problems with pointers
Posted by Legacy on 03/20/2002 12:00amOriginally posted by: John Culham
This is a great tip, however I can't make it work for pointers. I use:
ReplyCMyClass =Name:<oName.m_pchData,st> length:<length,lu>
which works great for anything defined as
CMyClass oMyObject;
but if I define it as a pointer (90% of the time for this class)
CMyClass* opMyObject = new CMyClass;
then the values for name and length in the tooltip are just "???". Has anyone else come across this problem? Or better yet solved it?
Beware of the evil member function call
Posted by Legacy on 03/21/2000 12:00amOriginally posted by: JCAB
Replystlport version + options
Posted by Legacy on 02/28/2000 12:00amOriginally posted by: Ian Tory
for stlpost 3.2 do:
stlport::_String_base<char,stlport::allocator<char> >=<_M_start,s>
also, for all versions, missing out the ending ",s" gives address plus string, including it gives string only
- Ian
ReplySimilar rule for Objectspace STL
Posted by Legacy on 10/21/1999 12:00amOriginally posted by: Jon Hanson
; from string
lc_bst_helper =<handle_->data_,s>
Reply
I nominate this for tip of the year!
Posted by Legacy on 03/24/1999 12:00amOriginally posted by: Chris Hafey
I always wanted to do this, but never knew how. I am so glad MS put this in a config file instead of hard coding it. Thanks for posting the tip!
Replystd::base_string already defined in VC++ 6.0
Posted by Legacy on 03/16/1999 12:00amOriginally posted by: Franky Braem
Thanks for this tip : It's a great help for debugging an application.
Replyremarks :
In Version 6.0 of VC++ std::basic_string is already defined
in the autoexp.dat file.