How to use visual studio debugging tools to make development easier - II
In this article i will explain you how Breakpoints and Tracepoints of visual studio debugger helps you to make your development easier. Also you will learn how to use immediate window, call stack, watch window, pinup and unpin variables in visual studio 2010
Index
Introduction
DataTip
Pinup and Unpin variables
Adding Comments for point while debugging
Watch Windows
Locals Windows
Autos Windows
Object ID
Immediate Windows
Call Stack Windows
Summing upIntroduction
Welcome again in the second version of this article which decrease your development effort and gives you a shortest way to code your idea in your application.
we have already seen use of step over and step into flow, Hitcount, conditional break point, labeling to breakpoint, SetNextStatement in previous version of this article, (you can check this link click ME)
In this article we will see different debugging supporting tools like Pinup variables, adding comments while debugging, last run debugging value, other debugging windows like local, autos, watch, Immediate Window, call stack, shortcut keys etc.DataTip
Data tip is nothing a kind of an advanced tool tip that can be used to show in detail object or variable during the debugging of the application.
When debugger reaches to breakpoint, you can keep a mouse pointer on variable and you will the value that holds by the variable, and there is '+' sign, to see the details of some complex object like Dataset, Array, ArrayList etc
check following snap, which will gives you idea.
Pinup and Unpin variables
This is the very powerful features of visual studio, we can see dynamic variable and it's current value while debugging. but this value is available for only limited time as we remove mouse pointer from variable
it will again vanish and cannot hold values. Visual studio has great features over it, we can use pinup and unpin features, it will allow you to pinup current value of a variable. We can pinup as many object as we can.
These values can be used for further reference. When you are at bottom of code while debugging you can change the position of pinned up variables.
Check following below snippet
Click on that pin icon to make it pinned. it will remain same Unless you manually close these pinned items or unpin it from source code.
Adding Comments for point while debugging
Do you know we can give comment to any point or variable while debugging, it's a one of the amazing features of visual studio 2010.
see a below snap for more detail
Additionally you can drag and drop your comment and pinup them to any part of the screen so, when you debug it in large code, you can drag the pinned value with you to the end of the screen.Watch Windows
If you want to check values of any list of variables and that you need to keep with you then those set of variable you add to watch window and you can get them when you want
To add variables in the watch window, you need to “Right Click" on variable and then select “Add To Watch".
Or you can go to debug menu -> window -> watch -> watch1
See below snaps for more detail
After opening watch window you can add variable in it. see the below snapLocal Windows
As name suggest 'Local' this window helps to get the variable information with their current value. infact this method gives us list of variables within a scope of current method.
so we can get the variable list that we can used in current method.
To use this window just go to Debug menu -> window -> locals
see below snaps for more detailAutos Windows
The Autos window displays variables used in the current statement and the previous statement. The debugger identifies these variables for you automatically
you can open this window From the Debug menu, choose Windows and click Autos. (The debugger must be running or in break mode.)Object ID
This is another good facility provided by visual studio editor. we can create a Object ID of any objectg using watch window, the use of object ID is we can see its value at any given point though the object is out of scope
to use this facility you need to open a watch window select object for which you want to create a object ID, Right click on it and click on Make object id, you will get numeric value with # it indicates the number of object id in application
See below snaps for more detailImmediate Window
Very popular and very used feature of visual studio is Immediate Window, by which we can see the runtime values of variables and objects, even we can calculate any number of expression here.
but the drawback of immediate window is, we cannot get the variable values which are out of scope.
To open this window you can use shortcut using keyboard CTRL+ALT+I or using Debug menu -> windows -> Immediate
See below snaps for more detailCall stack
Call is also one of the good features of visual studio 2010, but very few peoples are used this features. When you have multiple or nested calling of methods in your code, call stack will help you to know which method is get called from which line of code
It will make easy to find the trace and we can get line number to fix the issue
You can open call stack window using Debug -> window -> callstack
See below snaps for more detail
Summing up
Understanding whole visual studio IDE features is really a chunk of task to do at once, so we have break it up in several parts, this is second part. In this we have learn about Datatip, Pinup, Commenting, watch windows,
local, autos, ObjectID, immediate window, call stack.
But still there are many features that are still unfold, next part we can cover debug features like Parallel task, parallel stacks, Threads, modules, processes, disassemblies and registers
Suggestion and Queries always welcome
Thanks
Koolprasad2003
Thanks Ketan, Felling glad that it helps you.