JetBrains Rider 2018.2 Help

Using Breakpoints

Breakpoints are used to suspend the program execution and then analyze variables values, the call stack, and other program parameters at a particular execution point. In JetBrains Rider, you can work with two types of breakpoints:

  • Line breakpoints, which you can set at a particular statement in your code. The debugger suspends program execution once the execution reaches this line. Line breakpoints can be set only on executable lines — comments, declarations, and empty lines are not valid locations for line breakpoints.

  • Exception breakpoints are triggered when the specified exception is thrown. Unlike a line breakpoint, which requires specific source reference, an exception breakpoint applies globally and suspends the program execution when a specific exception is thrown.

To view all breakpoints in the current solution, use the Breakpoints dialog (Ctrl+Alt+B or Run | View Breakpoints... ). For each individual breakpoint in the list, you can view and change its properties as required.

Line breakpoint states

In the editor, you can see line breakpoints as red circles on the left gutter. Breakpoint icons denote breakpoint states and other properties.

State

Icon

Description

Enabled

breakpoint enabled

Line breakpoint. Shown at design-time

breakpoint enabled conditional

Conditional line breakpoint. The breakpoint is hit only when a particular condition is satisfied. Shown at design-time

Disabled

breakpoint disabled breakpoint disabled conditional

A disabled breakpoint will not break the program execution. You may want to disable a breakpoint instead of removing it if you want to enable and use it in the future.

Disabled by dependency

breakpoint dependent breakpoint dependent conditional

Dependent line breakpoint. A dependant breakpoint becomes enabled only after the breakpoint it depends on is hit.

Tracepoint

icon tracepoint icon tracepoint conditional

If a breakpoint does not suspend the program execution (the Suspend flag is disabled in the breakpoint properties), it effectively becomes a tracepoint, which you can use to log the program state when the program reaches the code line marked by it.

Valid

breakpoint valid breakpoint valid conditional

Shown at run-time when the breakpoint is recognized by the debugger as set on an executable code line.

Invalid

breakpoint invalid breakpoint invalid conditional

Shown when the breakpoint is set on a non-executable line indicating that such breakpoint would not be hit. A breakpoint can become invalid, for example, if you do not have correct PDB files for the debugged program.

Setting line breakpoints

To set a line breakpoint

  1. Set the cursor at the statement where you want to suspend the program execution.

  2. Do one of the following:
    • Press F9.

    • Click the left gutter area at a line where you want to toggle a breakpoint.

    • In the main menu, choose Run | Toggle Line Breakpoint.

Initially, a breakpoint is represented with a filled red circle on the left gutter breakpoint enabled. The line of code where the breakpoint is set is highlighted. After you start debugging, a valid breakpoint is marked with the green check mark breakpoint valid and program execution will stop before this line of code is executed.

set line breakpoint run

You have an option to temporarily disable a breakpoint without actually deleting it. Disabled breakpoints are shown as empty red circles breakpoint disabled.

To disable/enable a line breakpoint

  • While holding Alt, click the corresponding breakpoint icon the left gutter.

  • Click on the breakpoint with the middle mouse button.

  • In the Breakpoints dialog, use the check box next to the breakpoint or the Enabled flag in the breakpoint properties.

To disable/enable all line breakpoints

To delete a line breakpoint

  • In the editor, locate the line with the line breakpoint to be deleted, and click its icon in the left gutter.

  • Place the caret on the desired line and press F9.

  • In the Breakpoints dialog, select the desired breakpoint, and click Remove icons general remove svg.

If you need a breakpoint that works just once, you can either set a temporary breakpoint with the dedicated command or make any line or exception breakpoint temporary. When hit, such breakpoints are immediately removed.

To set a temporary line breakpoint

  1. Set the cursor at the statement where you want to suspend execution.

  2. Do one of the following:
    • Press Ctrl+Shift+Alt+F8.

    • In the main menu, choose Run | Toggle Temporary Line Breakpoint.

  3. Alternatively, select the desired breakpoint in the Breakpoints dialog, select the desired line breakpoint, and use the Remove once hit flag in the breakpoint properties.

Setting conditional line breakpoints

The debugger allows you to set a condition, under which a particular breakpoint will be hit. This may be helpful, for example, if you want to see how your program behaves when a variable takes a certain value.

To set a condition for a line breakpoint

  1. Do one of the following:
    • Right-click the corresponding breakpoint icon in the left gutter.

    • In the Breakpoints dialog, select the desired line breakpoint.

  2. Select the Condition flag and enter an expression that uses variables available in the context and evaluates to true or false. Press Shift+Enter to open the multiline editor.

If the expression evaluates to true, the breakpoint is hit. For instance, in the example below, the breakpoint will be hit only if result > 100.

JetBrains Rider: conditional breakpoints

For simple conditions, when all you need is to trigger the breakpoint after a certain number of hits (e.g., if a breakpoint is inside a loop), you can use its Hit count property. In the example below, the program will be suspended on each breakpoint hit which is a multiple of two, i.e. 2, 4, 6, 8, etc.

JetBrains Rider: breakpoints. hit count

Using dependent breakpoints

In some complex debugging cases (e.g. debugging a multithreaded application), suspending on a breakpoint may not make a lot of sense until some other breakpoint is hit. For this purpose, the debugger allows you to create dependent breakpoints.

To set a breakpoint the current one must depend on

  1. Do one of the following:
    • Right-click the corresponding breakpoint icon in the left gutter and click More in the opened breakpoint properties.

    • In the Breakpoints dialog (Ctrl+Alt+B or Run | View Breakpoints... ), select the desired breakpoint. Note that in this dialog, you can can also set a dependant breakpoint for an exception breakpoint.

  2. In Disabled until selected breakpoint is hit, select a breakpoint the current one must depend on.

  3. In After breakpoint was hit, select
    • Disable again to disable the current breakpoint after the selected breakpoint is hit.

    • Leave enabled to keep the current breakpoint enabled after the selected breakpoint is hit.

Using tracepoints to log program state

Sometimes, you may need to evaluate an expression at a specific execution point and log the result or simply log the fact that the breakpoint was reached. Typically, you do not need to suspend the program execution for each log entry.

For these purposes, JetBrains Rider allows you to turn any line or exception breakpoint into a tracepoint. Tracepoint messages will be logged to the debug output (the Debug Output tab of the Debug window).

To log the program state at a tracepoint

  1. Set a breakpoint (F9) at the desired statement or choose one of the existing breakpoints.

  2. Do one of the following:
    • Right-click the breakpoint and then click More in the breakpoint properties.

    • In the Breakpoints dialog (Ctrl+Alt+B or Run | View Breakpoints... ), select the desired breakpoint.

  3. Clear the Suspend checkbox to make it a tracepoint. This is optional, of course. If you want both to stop at the breakpoint and to log its hit, leave the checkbox selected.

  4. Choose how you want to log the breakpoint hit — a 'Breakpoint hit' message, the program's stack trace at this point, or both.

  5. For line breakpoints you can also evaluate any expression and log its result — select Evaluate and log and enter the desired expression(s).
    You can use any variables, classes, and their methods available in the scope. To add clarifying text to the output, use String.Format() or string concatenation.
    If necessary, press Shift+Enter to open the multiline editor.

For example, an expression like this:

JetBrains Rider: evaluating expressions on tracepoint
will print the following result to the Debug Output tab:
JetBrains Rider: evaluating expressions on tracepoint

Using labels for breakpoints

JetBrains Rider allows you to attach labels (names or short descriptions) to breakpoints to facilitate search.

To add a label to a breakpoint

  1. Open the Breakpoints dialog (Ctrl+Alt+B or Run | View Breakpoints... ).

  2. Right-click the breakpoint you are interested in.

  3. In the context menu, choose Edit description, and then type the desired name/description.

breakpoint add name

To find a breakpoint by a label

  1. Open the Breakpoints dialog (Ctrl+Alt+B or Run | View Breakpoints... ).

  2. Start typing the name (description) of the desired breakpoint. Note that the search supports CamelHumps.

The breakpoint with the matching description gets the focus.

breakpoint find name

Grouping breakpoints

In the Breakpoints dialog, you can organize breakpoints in a group, for example, to mark out breakpoints for a specific problem. When a group is created, you can move breakpoints into and out of the group and enable/disable all breakpoints in a group at once.

breakpoints group

To create a group of breakpoints

  1. Open the Breakpoints dialog (Ctrl+Alt+B or Run | View Breakpoints... ).

  2. Select a breakpoint you are interested in. To select multiple breakpoints, hold the Ctrl key while selecting the breakpoints.

  3. Right-click the selection and choose Move to group | Create new... from the context menu.

  4. In the New Group dialog, type the name of the new group. The selected breakpoint moves to the newly created group.

  5. Optionally, you can right-click a group of breakpoints and choose Set as default. After that, all newly created breakpoints will be automatically added to this group.

  6. Optionally, you can select or clear the group check box to enable/disable all breakpoints within a group.

After a group is created you can move other breakpoints to that group by right-clicking and choosing Move to group in the context menu.

To move a breakpoint out of a group, right-click it and choose Move to group | [group name] or Move to group | <no group>. As soon as the last breakpoint is moved out of the group, the group is removed.

To remove a group together with all breakpoints in it, click Remove icons general remove svg when that group is selected.

Thread-specific breakpoints

Debugging multi-threaded applications can be challenging: whenever you continue execution, you may be on another thread the next time a breakpoint is hit. To concentrate on debugging a specific thread, you can make any breakpoint thread-specific.

By default, any breakpoint will suspend program execution independently of the thread that hits it.

To make a breakpoint thread-specific

  1. Start a debugging session so that the debugger can collect the program threads.

  2. Right-click on the breakpoint or find it in the Breakpoints dialog (Ctrl+Alt+B).

  3. Select Suspend only on specific thread and then choose one of the program threads:

    JetBrains Rider: Making a breakpoint thread-specific

Last modified: 4 October 2018