Better debugger support for boost::optional with VS2005 compiler
Hello, just recently I introduced boost::optional as default type to represent optional/nullable types in a sub-project of our company, which generates C++ code out of UML models. While this worked seamless, programmers not yet used to boost::optional complained that they could not really see, what such type "contains" if they try to observe it in the debugger. I searched for a solution, only finding the discussion around the article "how to see the actual value of a 'boost::optional<__int64>' in VS2005 debugger" from 2006-07-26, which did not gave a satisfactory answer. Please ignore this message, if the here described solution (or a better one), which I worked out this weekend, is already well-known (but I would appreciate if someone could give me a link to the already known solution). My approach was to modify the unofficially supported debugger configuration file autoexp.dat, which typically is found at ${SomePath}\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat If you never have heard of this file, you should make a copy of it, before doing the modifications I discuss here. A more detailled description what can be done with this file, can be read here (but you don't need to do that, if you just want to get the results I propose here): http://www.virtualdub.org/blog/pivot/entry.php?id=120 Just use your preferred text editor to open the autoexp.dat, jump at the end of it and go five rows back. You should be +/- 1 row about the line with the content: ; This section lets you define your own errors for the HRESULT display. Go one row back (row 1957 in my file), which should be the end of the so-called [Visualizer] section. Now insert here the text provided at the end of this article and just start you debugger session (you don't need to restart the studio) - you should have a nice view on each boost::optional, even those which are optionals of references. I tested the visualizer for the following boost versions: 1.30.0 1.31.0 1.32.0 1.33.0 1.33.1 1.34.1 and all of them worked. I would like to thank the boost developers for their great contributions (where boost::optional is only one of them) and I hope you can even more enjoy boost::optional with this trick. Unfortunately I have not found similar solutions for other compilers yet, e.g for gcc, which probably is due to my lack of experience with them but I would appreciate if someone else publishes them, too. Greetings from Bremen, Daniel Krügler ;------------------------------------------------------------------------------ ; Visualizer for boost::optional, boost::optional_detail::optional_base ;------------------------------------------------------------------------------ boost::optional<*>|boost::optional_detail::optional_base<*> { preview ( #if($e.m_initialized) ( *(($T1 *) (&$e.m_storage.dummy_.data[0])) ) #else ( "?" ) ) children ( #if($e.m_initialized) ( #(value: *(($T1 *) (&$e.m_storage.dummy_.data[0])) ) ) #else ( "?" ) ) } ;------------------------------------------------------------------------------
On Mon, Mar 3, 2008 at 3:58 AM, Daniel Krügler
I would like to thank the boost developers for their great contributions (where boost::optional is only one of them) and I hope you can even more enjoy boost::optional with this trick. Unfortunately I have not found similar solutions for other compilers yet, e.g for gcc, which probably is due to my lack of experience with them but I would appreciate if someone else publishes them, too.
Daniel, please see http://svn.boost.org/trac/boost/wiki/DebuggerVisualizers and perhaps contact Filip. He has made visualizers for other Boost libraries, and is maintaining the Wiki page for that effort. Great work! --Michael Fawcett
Michael Fawcett wrote:
On Mon, Mar 3, 2008 at 3:58 AM, Daniel Krügler
wrote: I would like to thank the boost developers for their great contributions (where boost::optional is only one of them) and I hope you can even more enjoy boost::optional with this trick. Unfortunately I have not found similar solutions for other compilers yet, e.g for gcc, which probably is due to my lack of experience with them but I would appreciate if someone else publishes them, too.
Daniel, please see http://svn.boost.org/trac/boost/wiki/DebuggerVisualizers and perhaps contact Filip. He has made visualizers for other Boost libraries, and is maintaining the Wiki page for that effort.
Great work!
Thanks Michael and also thanks for your link - I wasn't aware of this project. I submitted the ticket #1666 (unfortunately I overlooked that this is a bug ticket ;-) to the project, proposing this addition (I checked that it did not yet exist there) - Daniel
Hi Daniel,
My approach was to modify the unofficially supported debugger configuration file autoexp.dat, which typically is found at
${SomePath}\Microsoft Visual Studio 8\Common7\Packages\Debugger\autoexp.dat
Slightly OT: This article was very useful for me: http://shadone.blogspot.com/2007/09/visual-studio-2005-tips-tricks.html It also explains autoexp.dat and has some Qt Debugger Visuals and shows how to step over certain functions (like NOT stepping into shared_ptr everytime) by modifying some registry entries. -- Best regards, Rainer
participants (3)
-
Daniel Krügler
-
Michael Fawcett
-
Rainer Thaden