In a source window, click a line where you want to set a tracepoint, and then select Insert Tracepoint from Breakpoints on the shortcut menu.
The When Hit dialog box appears. It contains two text boxes where you can enter custom actions: Print a message and Run a macro.
At this point, you can accept the preselected tracepoint settings, or modify them as follows:
To create a tracepoint that prints a message to the Output window, select Print a Message and enter the message text in the corresponding text box. By using Print a Message, you can use tracepoints for same purposes that you would use a trace class, but without the need to modify your code.
You can include programmatic information by using DebuggerDisplayAttribute syntax (see DebuggerDisplayAttribute). For example:
In function '{$FUNC}', on thread '{$TID}'
-or-
Used variable: {varName}, function name: {functionName($FUNC)}
You can use any of the keywords shown on the When Breakpoint Is Hit dialog box. In addition, you can use two other keywords that are not shown in the dialog box: $TICK inserts the current CPU tick count, while $FILEPOS inserts the current file position.
A default message appears in Print a Message when the When Breakpoint Is Hit dialog box opens. If you want to accept this message, click OK.
To run a Visual Studio automation model macro, select Run a Macro and choose a macro from the drop-down list.
When you select Print a Message or Run a Macro, the Continue Execution check box becomes active. Select Continue Execution if you do not want the tracepoint to break execution of your program.