Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Garbled debug watch of std::string's?

Tags:

When I'm debugging C++ mixed (managed/unmanaged) projects in Visual Studio 2005, I often get weird data from the debug watches, like below :
(btw, the variable i_processName is a const std::string & )

alt text http://img175.imageshack.us/img175/3561/43419953av1.jpg

Note that the variable actually holds valid data - if i print it to stdout, the printed string is just fine, thanks for asking. The simpler types of data (e.g. ints) (usually?) get their correct values shown.

Did this ever happen to you too?

This is a major PITA when debugging, so ... any ideas on how to make the watches show the correct data, or what's causing this?

like image 976
Cristian Diaconescu Avatar asked Feb 12 '09 15:02

Cristian Diaconescu


1 Answers

Debug display of custom types (this includes the STL) depends on the file autoexp.dat located in the <install_path>\Common7\Packages\Debugger folder. Make sure that yours matches your library version and that an older version of this file hasn't been kept around (when upgrading for example).

Note that you can also write your own visualizers for other types, more info here and here. This is a major time saver for complex projects, well worth the (small) effort put into writing custom visualizers.

like image 181
fbonnet Avatar answered Sep 29 '22 07:09

fbonnet