Jude Jude - 1 year ago 87
ASP.NET (C#) Question

What is tracepoint used for?

They can only be placed on method names. How are they used and what are they for?

enter image description here

Answer Source

The Debugger team has a good blog post on this subject with examples as well: http://blogs.msdn.com/b/visualstudioalm/archive/2013/10/10/tracepoints.aspx

Tracepoints are not a new feature at all (they been in Visual Studio since VS 2005). And they aren't breakpoints per say, as they don't cause the program execution to break. That can be useful when you need to inspect something, but no stop the program as that causes the behavior of a bug not to repro, etc.

Tracepoints are an attempt to overcome the case when you can't stop the program to inspect something as that will cause some behavior not to repro, by allowing a breakpoint to log information to the debug output window and continue, without pausing at the UI. You can also do this with macros, but it can be more time consuming.

To set a tracepoint, first set a breakpoint in code. Then use the context menu on the breakpoint and select the “When Hit...” menu item. You can now add log statements for the breakpoint and switch off the default Stop action, so that you log and go. There is a host of other info you can add to the log string, including static information about the location of the bp, such as file, line, function and address. You can also add dynamic information such as expressions, the calling function or callstack. Things like adding thread info and process info, can help you track down timing bugs when dealing with multiple threads and/or processes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download