Search This Blog

Monday, May 30, 2011

Debugging made easy - Part1

We will briefly discuss 3 things here -
1) Run to Cursor
2) Set Next Statement
3) Insert Tracepoint

1) Run to Cursor - While debugging, if you right click on any statement you can see many options. One of them is Run To Cursor.  It can be used as a one time breakpoint. Like when u want to execute a few rows in a go. You can right click on line where u want ur execution to come and select Run to cursor.

2) Set Next Statement - While debugging when you right click you see another option - Set Next Statement. This command jumps the program counter directly to the line under cursor. You can give a line above or below the current execution step. A major difference between Run to Cursor and Set Next statement is that the former executes all the statements till the point while the latter skips all the lines and directly executes next statement. Because of this behavior, we can take the control inside if-else or loop etc. I usually use it when I get a UE (Unexpected Error) and want to inspect where exactly it came from by setting the first statement of method as Next statement. You can see details at http://msdn.microsoft.com/en-us/library/09yze4a9(v=vs.85).aspx

3)  Insert Tracepoint - You can insert tracepoint as you insert breakpoints. The difference between both of them is that while a breakpoint breaks the execution flow, a trace point does a specified action and/or breaks the execution flow. Tracepoints can be used for the same purpose as Trace is used, without modifying the code, but they work only in "Debug" mode. For more details http://msdn.microsoft.com/en-us/library/232dxah7.aspx

1 comment: