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
icon in the left gutter, and then choose
.
Click
on the toolbar.
Select
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 More from the menu:
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.
Place the caret at the required line and call Set Execution Point to Cursor from (Control+Shift+A).
In Set Execution Point to Cursor action.
, assign a shortcut for theSave 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:

Breaking on panics is enabled by default. If you prefer to disable it, go to Break on panic checkbox.
and clear the
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 |