views:

179

answers:

3

I'm using the Intel compiler and visual studio and I can't seem to debug values that are in maps. I get a quick preview which shows the size of the map but the elements only show up as "(error)", I'll illustrate with a quick example, i've generated a map with a single entry myMapVariable[6]=1;

if I mouse over I get this "myMapVariable 1" and in the watch window I get the same thing and expanding on the plus gives a single child entry which says name = "(error)" and value = 0 (which is wrong).

I've added a line to my autoexp.dat debugging file which shows the raw member variables under the child called [raw members] and the resulting output of that is shown in this image. I've pretty much reached the limits of my ability to dig into this further without help so I would ask if anyone here can provide some insights.

A: 

My only suggestion is to make sure the map is initialized and in scope. Otherwise, I'm not sure, I've never seen this but I use VS2008 now.

rlbond
yes it's initialised, i sometimes have to stop the debugger and add a loop that iterates through the map just so I can see what the values are :( maybe 2008 is the answer (or at least a good diversion)
Jamie Cook
A: 

You're most likely using aggressive optimization settings. At least your screenshot is typical of that sort of thing. In that case, the debugger is actively stuffing hot values into registers, and it may be that, at the point you're stopped, the values that are needed to properly visualize the entire map are already discarded and overwritten by something else that is enough (like, say, a pointer to a current node). I would imagine that Intel C++, which is well-known for its high-quality optimization, does this sort of thing even more often than VC++ (but I've seen such with the latter often enough as well).

Consider recompiling the project in Debug configuration (which would disable the optimizer), and see if that helps.

Pavel Minaev
Pavel, thanks for the feedback - I'm actually running this in debug mode which has the /Od flag (Optimisations disabled). I might try this out with the straight MSVC compiler and see if that makes a difference. see if it's something to do with how the intel compiler treats the std::map
Jamie Cook
A: 

I have the exact same problem, even though I'm using VC++ compiler. I realized that the content of std::maps elements in the watch window depend on the stack frame I select in the Call stack window. For instance, if I want to inspect the content of std::map<> m_mapObject of a CClass instance, and the stack frame I select is inside a CClass defined method (CClass::Method()), I will be able to see the contents of all the elements correctly. But, if I select one stack frame lower (the caller method of the CClass instance method i.e. the one that calls m_oCClassObject->Method()), I will see only (error) in the elements name and 0 as its value. Did you find anything new concerning that issue ? Because I spent hours trying to find a solution for this and I found nothing.

Thanks,