Tuesday, December 16, 2008

[VC++] Debugging with the help of AUTOEXP.DAT

Hope you might have debugged some application in VC++ debugger. Have you ever thought of how you are seeing the value of object as tool tip while debugging. For example, while debugging you point to the CString object you can see the value of member variable m_pchData of CString class.


You can give the same support for your custom defined data structures, suppose you have a complex object which holds many items and you want to know the values stored while debugging (sometimes you can expand the variable in watch/Quick watch window but that is difficult for a complex data structure).
In the below debug snapshot, you can see all the values (even other structure’s value) in the structure INFO_EX_t as tool tip while debugging,



For this all you have to do is modify the file MSDEV_INSTAL_DIR\Microsoft Visual Studio\Common\MSDev98\Bin\AUTOEXP.DAT, add an entry for your data structure also. For showing the above variable expansion I have added the below line,

where ‘st’ in the above line is a format specifier for the string to choose UNICODE or ANSI depending on the current setting.
Another usage of AUTOEXP.DAT is you can prevent the stepping to some specific functions (for eg: CString::operator) while debugging with F11. For that what you have to do is add an entry like what I shown below,
[ExecutionControl]
CString::operator==NoStepInto

Just try it you will find it useful some day !

No comments: