Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to see the contents of std::map in Visual C++ .NET (Visual Studio 2003) while debugging?

I need to see the contents of a std::map variable while debugging. However, if i click on it in the Autos/Locals Tab, I see implementation specific stuff, instead of the keys and its contents which I want to look at. Is there a work-around i'm missing ?

like image 495
TCSGrad Avatar asked Sep 02 '25 05:09

TCSGrad


2 Answers

I don't have a copy of Visual Studio 2003 around to test with, but I just checked VS2008 and 2010 and both automatically display the contents of the map on hover. I vaguely remember having a lot of trouble with STL inspection in 2003, so my guess is that it's a feature that they substantially improved in the intervening years.

If it's possible for your project, you might consider upgrading to Visual C++ 2008 Express, which is free and should have most of the features you need.

like image 95
Dan Story Avatar answered Sep 04 '25 18:09

Dan Story


I have no VS2003 nearby at the moment. But you could try to add in "autoexp.dat" the following section (I was sure that in VS2003 there are already included sections for all standard types):

;------------------------------------------------------------------------------
;  std::map
;------------------------------------------------------------------------------

std::map<*>{
    children
    (
        #tree
        (
            head : $c._Myhead->_Parent, 
            skip : $c._Myhead, 
            size : $c._Mysize, 
            left : _Left, 
            right : _Right
        ) : $e._Myval
    )

    preview
    (
        #(
            "[", 
            $e._Mysize, 
            "](", 

            #tree
            (
                head : $c._Myhead->_Parent, 
                skip : $c._Myhead, 
                size : $c._Mysize, 
                left : _Left, 
                right : _Right
            ) : $e._Myval,

            ")"
        )
    )            
}

The structure of this file and the syntax of autoexp rules may change from one release of Visual Studio to the next. Read here more about custom visualizers for Visual Studio.

like image 25
Kirill V. Lyadvinsky Avatar answered Sep 04 '25 18:09

Kirill V. Lyadvinsky