JetBrains Rider 2017.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.

StateIconDescription
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.
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.

A breakpoint is represented with a red circle on the left gutter. The line of code where the breakpoint is set is highlighted. After you start debugging, the 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.

To disable/enable a line breakpoint

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

To disable/enable all line breakpoints

To delete a line breakpoint

  • Do one of he following:

    • 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 box, select the desired line breakpoint, and click Remove remove rider icon.

If you need a breakpoint that works just once, you can create a temporary line breakpoint. 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:
    • PressCtrl+Shift+Alt+F8.
    • In the main menu, choose Run | Toggle Temporary Line Breakpoint.

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 box, select the desired line breakpoint.
  2. In Condition, enter the desired logic expression that returns true or false.
  3. If you want to have multiple conditions, click Edit shift enter button next to the Condition field and enter expressions separated by the semicolon (;) in the Edit window that opens.

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.

breakpoint condition example

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.

breakpoint 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 box, 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 breakpoints to log program state

Sometimes, you may need to evaluate an expression at a specific execution point and print the result to the debug output (the Debug Output tab of the Debug window), and typically, you do not need to suspend the program execution for each log entry.

To log the program state at a breakpoint

  1. Set a breakpoint at the desired statement or choose one of the existing line 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 line breakpoint.
  3. In Evaluate and log, enter the desired expression(s). To print the value of a variable or expression, enclose it in curly braces. For example, {myVariable}. The text without braces will be treated as a generic string and logged as is.
  4. If you want to have multiple expressions, click Edit shift enter button next to the Evaluate and log field and enter the expressions in the Edit window that opens.
  5. If you do not want your program to stop on this breakpoint, clear the Suspend property.

For example, an expression like this

breakpoint evaluate log
will print the following result to the Debug Output tab
breakpoint evaluate log result

Note that if you are interested only in the fact that some breakpoint is reached, you can simply turn on the Log message to console property. In this case, once the breakpoint is reached, the debugger will add a message like Breakpoint reached: C:\RiderProjects\MyApp\Program.cs:28 to the Debug Output tab.

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.

The specified description will be shown next to the address of the breakpoint:

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 box, 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 remove rider icon when that group is selected.

Last modified: 17 November 2017