Did you know – Code Map can be used to visualize the call stack directly ?

Did you know – Code Map can be used to visualize the call stack directly ?

In Visual Studio, by using the Call Stack window, we can view the function call that are currently on the stack for that instance of execution steps. It’s one of most frequently used feature during debugging.  This helps us to trace the code flow and debug thing faster and   If you are familiar with Code Maps, you must have seen how friendly and powerful it is for visualize representation of your code  inside Visual Studio. We have seen the usages of code map for dependency graph, call references , related items and showing references etc.

With all these nice feature of Code Maps, one thing that you could  also use very frequently is to get the entire call stack  in a code map.  While in debug, when it’s hit the break point,  select “Show Call Stack on Code Map” option from the context menu.

Show Call Stack on Code Map During Debugging
Show Call Stack on Code Map During Debugging

Must Read : 10 Effective Debugging Tips for .NET Developer

This will generate the code map on the fly for the current call Stacks and will be displayed in a side by side way as shown in the screenshot  below.

 Code Map for the Selected Call Stacks
Code Map for the Selected Call Stacks

Here instead of traditional calling statement, you will get a nice visual way of representation.  Now you use it in same way like you do for traditional call stack windows.

Check this out : Debugging Lambda Expression in Visual Studio 2015 – Watch Windows, Immediate Windows and also in DataTips

Call Stack in Code Map and Call Stack Window Side by Side
Call Stack in Code Map and Call Stack Window Side by Side

Following screenshot shows a side by side view of Call Stack in Code Map and Call Stack Window.

Not only from a debug breakpoint, you can invoke the call stack in code map even if there is an exception. In a short, you can use this feature as similar to a call stack, only the difference with visual representations.

Hope this helps !

Abhijit Jana

Abhijit runs the Daily .NET Tips. He started this site with a vision to have a single knowledge base of .NET tips and tricks and share post that can quickly help any developers . He is a Former Microsoft ASP.NET MVP, CodeProject MVP, Mentor, Speaker, Author, Technology Evangelist and presently working as a .NET Consultant. He blogs at http://abhijitjana.net , you can follow him @AbhijitJana . He is the author of book Kinect for Windows SDK Programming Guide.

2 Comments to “Did you know – Code Map can be used to visualize the call stack directly ?”

Comments are closed.