Visual Studio Debugger
How to: Specify a Tracepoint/Breakpoint Action

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic does not applyTopic does not applyTopic appliesTopic does not apply

Standard

Topic applies

Topic applies

Topic applies

Topic applies

Pro and Team

Topic applies

Topic applies

Topic applies

Topic applies

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default

Tracepoints are a new way to use breakpoints. A tracepoint is a breakpoint that has a custom action associated with it. When the tracepoint is hit, it causes the debugger to perform the specified action instead of (or in addition to) breaking program execution.

As you begin to create a tracepoint, the When Hit dialog box will appear. This dialog box contains two text boxes where you can enter custom actions: Print a message and Run a macro. You can accept the preselected tracepoint settings, or you can edit them.

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. With Print a Message, you can use tracepoints for many of the same purposes that you would use the 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 one of the keywords shown in 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.

When the When Breakpoint Is Hit dialog box opens, a default message appears in Print a Message. If you want to accept this default message, click OK.

To run a Visual Studio automation model macro, select Run a Macro, and then select a macro from the drop-down list box.

When you select either Print a Message or Run a Macro from the When Hit dialog box, the Continue Execution check box becomes active. Select Continue Execution if you do not want the tracepoint to break execution of your program.

NoteNote:

The dialog boxes and menu commands you see might differ from those described in Help, depending on your active settings or software edition. To change your settings, select Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

You can create a tracepoint in two different ways:

  • You can create a tracepoint from scratch with the New Tracepoint command.

  • You can convert an existing breakpoint into a tracepoint by adding a tracepoint action.

    Any type of breakpoint can be converted into a tracepoint.

To create a tracepoint from scratch

  1. In a source window, click a line where you want to set a tracepoint, and select Insert Tracepoint from Breakpoints in the shortcut menu.

  2. xxx

  3. Click OK.

To convert a tracepoint from an existing breakpoint

  1. In a source, Disassembly, or Call Stack window, right-click a breakpoint glyph and choose When Hit.

    -or-

    In the Breakpoints window, right-click a breakpoint glyph and choose When Hit.

    The When Hit dialog box appears.

  2. Click OK to accept the preselected tracepoint settings, or edit them as explained in the previous procedure.

See Also

Concepts

Reference

Tags :


Page view tracker