Friday, October 15, 2010

Using Tracepoints for debugging

Tip - Using Tracepoints in Visual Studio Debugger.

Details – All programmers are familiar with break points while debugging. But sometimes during debugging it’s not possible to interrupt the program execution. The correctness of the program may affected by the delay introduced by the debugger. In such cases we can use trace points. As the name resembles break points breaks the execution of the program while trace points doesn’t (or optional). Trace points provide additional options to know the debugging information on Trace point location. This feature is available since Visual Studio 2005.

You can put the trace point as follows.

Insert Trace point

Set trace point parameters.
The dialog box itself contains how to format information with variables and other parameters.


The output will be displayed in the output window. An example is given below

IN: 20Fxn: DisplayFxn(int),Thread: 0x140C Thread2 CPU Tick:0x4EC5FE Call Stack:      TracePointSample.exe!DisplayFxn()
      TracePointSample.exe!ProcessValue()
      TracePointSample.exe!Thread2()
      kernel32.dll!76ea36d6()
      [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
      ntdll.dll!77a5883c()
      ntdll.dll!77a5880f()

IN: 11Fxn: DisplayFxn(int),Thread: 0xF74 Thread1 CPU Tick:0x4EC6C9 Call Stack:      TracePointSample.exe!DisplayFxn()
      TracePointSample.exe!ProcessValue()
      TracePointSample.exe!Thread1()
      kernel32.dll!76ea36d6()
      [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
      ntdll.dll!77a5883c()
      ntdll.dll!77a5880f()

PS: Please not that the interface for setting trace point may vary on each version of Visual Studio. The screenshot given above it taken from Visual Studio 2010.

Reference:
http://msdn.microsoft.com/en-us/library/232dxah7.aspx
http://codereflect.com/2009/02/12/using-trace-points-in-visual-studio-for-debugging/

Posted by - Sarath C

No comments:

Post a Comment