Geeks With Blogs
Tex-blog Mobile and other stuff
For a long time I have been a big fun of MFC template collections like CArray. The main reason was that they were easy to use and what’s most important quite easy to read in debugger what’s inside them, yet in many places I use mostly STL to take benefit of various collection types and available algorithms. Debugging with STL never was easy, VS 2005 out of the box supports auto expanding of its own STL containers, if you use other implementation than the Microsoft’s one, you have to write your own autoexp.dat file entry. I use STLPort implementation (5.1.0), viewing vector contents in debugger shows information of little use. It is needed to make VS show number of elements and each element separately to make debugging effective.

To accomplish this you have to add new Visualizer to autoexp.dat file. On my computer this file is located in C:\Program Files\Microsoft Visual Studio 8\Common7\Packages\Debugger folder. Its contents is being read every time you begin debugging session. I am not going to explain how visualizer works, there is plenty of articles on that topic, I will just give some hints on how to correct autoexp.dat file to show collections from other STL implementation.

To make VS show our vector contents we will copy MS reference vector visualizer, it looks as follows:

;------------------------------------------------------------------------------
;  std::vector
;------------------------------------------------------------------------------
std::vector<*>{
       children
       (
           #array
           (
                    expr : ($c._Myfirst)[$i],
                   
size : $c._Mylast-$c._Myfirst
             )
       )    

    preview
    (
        #(
                    "[",
            $e._Mylast - $e._Myfirst ,
            "](",         

            #array
            (
                           expr :       ($c._Myfirst)[$i],
                          
size :       $c._Mylast-$c._Myfirst
                    ),
                    ")"
             )
       )   
}

 
We want to keep the whole hierarchy the same, and just modify few things, namely:

  • Namespace, in above visualizer it is std, in my STL implementation it is stlpd_std.
  • Pointers to first and last element, in above visualizer it is _Myfirst and _Mylast, in my STL implementation it is _M_non_dbg_impl._M_start and _M_non_dbg_impl._M_finish.

The second point was the most difficult, I had to experiment a bit. So in the end vector visualizer for my STLPort version is as follows:

stlpd_std::vector<*>{
    children
    (
        #array
        (
            expr :    ($c._M_non_dbg_impl._M_start)[$i],
            size :    ($c._M_non_dbg_impl._M_finish)-($c._M_non_dbg_impl._M_start)
        )
    )

    preview
    (
        #(
            "[",
            $e._M_non_dbg_impl._M_finish - $e._M_non_dbg_impl._M_start ,
            "](",        

            #array
            (
                expr :     ($c._M_non_dbg_impl._M_start)[$i],
                size :     $c._M_non_dbg_impl._M_finish-$c._M_non_dbg_impl._M_start
            ),
            ")"
        )
    )
}

New visualizer needs to be put in [Visualizer] section of autoexp.dat, do not modify any existing entries in this section, put the new one at the end of it.

Posted on Tuesday, September 11, 2007 5:07 AM | Back to top


Comments on this post: STLPort and Visual Studio auto expanding data feature

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Martinez | Powered by: GeeksWithBlogs.net