Visual Studio 2013 Preview: Code Map Debugger Integration

5-16-2012 12-48-10 PM

 

Prologue

The original Code Map was introduced in the product with Visual Studio 2012 Update 1. You need to read my original post before moving on:

https://blogs.msdn.com/b/zainnab/archive/2013/02/07/visual-studio-2012-update-1-understanding-code-map.aspx

 

My assessment at the time was that it was a good feature but had poor performance and didn’t really add much value relative to Dependency Graphs. With debugger integration however Code Maps have definitely come into their own and the performance is very good.

 

Note: Code Map Debugger Integration is a feature in the Ultimate edition of Visual Studio.

 

 

 

Code Map Debugger Integration

Assuming you have a handle on Code Maps now let’s see how the debugger integration works. First, I’ll take the TailSpin Toys sample code and set a breakpoint within the code base (ShoppingCart.cs, line 61):

5-16-2012 12-04-13 PM

 

 

I’ll press F5 and add an item to my cart to trigger the debugger:

5-16-2012 12-07-12 PM

 

 

Ordinarily, we would step though the code and hope we remember how we got to a particular place. Those days are gone! Now we can turn on the Code Map feature while debugging:

5-16-2012 12-12-27 PM

 

 

You can also find this on the Menu Bar at Debug | Show Call Stack on Code Map:

5-16-2012 12-13-37 PM

 

 

You will see a Code Map in sync with the debugger at this point. You can create Code Maps in C#, VB, C++, JavaScript currently. Once activated all future debugging sessions will include a Code Map until you turn this feature off:

5-16-2012 12-17-38 PM

 

 

If we take a closer look at the current map, we can see that it shows how we arrived at the current call (the squares above the last AddItem call) and our current location (yellow arrow). Although the current location indicator is partially covering it, you can also see the breakpoint indicator:

5-16-2012 12-27-35 PM

 

 

Stepping through the code we see the map keeps updating so we don’t have to keep the path in our heads:

5-16-2012 12-29-19 PM

 

 

The Code Map will continue to update for our debugging session showing where we have been and where we currently are in the call stack:

5-16-2012 12-35-58 PM

 

 

The graphs can get quite large:

5-16-2012 12-40-46 PM

 

 

For this reason it’s important to use the map tools at your disposal. The context menu items when you Right Click any node are a great example of common tools:

5-16-2012 12-45-23 PM

 

 

You can Double Click any node to view the code from that location in the stack. A green arrow will indicate your current position:

5-16-2012 12-54-27 PM

 

 

If you happen to choose a node that isn’t part of the current active call stack then you will get a slightly different indicator:

5-16-2012 12-57-41 PM

 

 

When you stop debugging the Code Map will be preserved so you can save it if desired and keep a map of the code base you just went through. I think this is an exceptional addition to the debugging experience!