42.2. Tracepoints

A tracepoint differs from a breakpoint in that it triggers an additional action when it is hit. In fact, for purposes such as applying filters, conditions, and hit counts, a tracepoint can be thought of as a breakpoint.

Tracepoints can be compared to using either Debug or Trace statements in your code, but they can be dynamically set as the application is being debugged and do not affect your code.

42.2.1. Creating a Tracepoint

Tracepoints can be created from either an existing breakpoint or the Breakpoint right-click context menu. To create a tracepoint from an existing breakpoint, select When Hit from the Breakpoint right-click context menu. The resulting dialog, shown in Figure 42-12, gives you the option of printing a message to the console window or running a macro. Alternatively, to create a tracepoint at a new location, select Insert Tracepoint from the Breakpoint item on the right-click context menu. This again loads the dialog shown in Figure 42-12 so you can customize the tracepoint action.

Figure 42.12. Figure 42-12

Once you set a tracepoint, the code window changes the appearance of that line of code to indicate that a tracepoint has been set. This is shown in Figure 42-13, where the tracepoint appears with a diamond in the margin. (The diamond is red, although this can't be seen in the figure.)

Figure 42.13. Figure 42-13

42.2.2. Tracepoint ...

Get Professional Visual Studio® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.