RustRover 2023.3 Help

Debugging

During a debugging session, you launch your program with the debugger attached to it. The purpose of the debugger is to interfere with the program execution and provide you with the information on what’s happening under the hood. This facilitates the process of detecting and fixing bugs in your program.

Start a debug session

Use one of the following options:

  • Click the Run icon icon in the left gutter, and then choose App actions start debugger.

    Initiating debug from the gutter
  • Click the Run button on the toolbar.

    Initiating debug from the toolbar
  • Select Run | Debug [selected configuration] from the main menu.

  • Press Shift+F9.

When you start debugging, the IDE calls cargo test to get the non-optimized binary with debug information, and then launches it under the debugger.

Setting breakpoints

Breakpoints are source code markers that let you suspend program execution at a specific point and examine its behavior.

Set breakpoint

  • Click the gutter at the executable line of code where you want to set the breakpoint. Alternatively, place the caret at the line and press Control+F8.

You can view and edit breakpoints in your code via Run | View Breakpoints (Control+Shift+F8). Alternatively, right-click a breakpoint and select More from the menu:

Setting and editing a breakpoint

Setting execution points

The Set Execution Point action allows you to jump to an arbitrary line of code in the editor during a debug session and set the execution point there, skipping all the other commands in between.

Set execution point

Use one of the following options:

  • Drag the current execution pointer (the orange arrow in the gutter) to the required line of code.

    Execution pointer in the gutter
  • Place the caret at the required line and call Set Execution Point to Cursor from Help | Find Action (Control+Shift+A).

    Set Execution Point in Search Everywhere dialog
  • In Settings | Keymap, assign a shortcut for the Set Execution Point to Cursor action.

    Assigning a shortcut to Set Execution Point

    Save the settings, place the caret at the required line, and use the shortcut.

Break on panic

When a panic occurs, the debugger stops inside the panic! call automatically. This helps to investigate the stack trace and variable context around the point of panic:

Automatic break on panic

Breaking on panics is enabled by default. If you prefer to disable it, go to Settings | Build, Execution, Deployment | Debugger and clear the Break on panic checkbox.

Breaking on panic option in settings

Useful debugger shortcuts

Action

Shotcut

Toggle breakpoint

Control+F8

Resume program

F9

Step over

F8

Step into

F7

Stop

Control+F2

View breakpoint details/all breakpoints

Control+Shift+F8

Debug code at caret

Shift+F9 (within the main method) or Alt+Shift+F9

Last modified: 03 November 2023