Research Environment

Debugging

Introduction

The debugger is a built-in tool to help you debug coding errors while in the Research Environment. The debugger enables you to slow down the code execution, step through the program line-by-line, and inspect the variables to understand the internal state of the notebook.

The Research Environment debugger isn't currently available for C#.

Breakpoints

Breakpoints are lines in your notebook where execution pauses. You need at least one breakpoint in your notebook to start the debugger. Open a project to start adjusting its breakpoints.

Add Breakpoints

Click to the left of a line to add a breakpoint on that line.

Add breakpoint Add breakpoint

Edit Breakpoint Conditions

Follow these steps to customize what happens when a breakpoint is hit:

  1. Right-click the breakpoint and then click Edit Breakpoint....
  2. Click one of the options in the following table:
OptionAdditional StepsDescription
ExpressionEnter an expression and then press Enter.The breakpoint only pauses the notebook when the expression is true.
Hit CountEnter an integer and then press Enter. The breakpoint doesn't pause the notebook until its hit the number of times you specify.

Enable and Disable Breakpoints

To enable a breakpoint, right-click it and then click Enable Breakpoint.

To disable a breakpoint, right-click it and then click Disable Breakpoint.

Follow these steps to enable and disable all breakpoints:

  1. In the right navigation menu, click the Run & debug icon Run and Debug icon.
  2. In the Run and Debug panel, hover over the Breakpoints section and then click the Toggle Active Breakpoints icon.

Remove Breakpoints

To remove a breakpoint, right-click it and then click Remove Breakpoint.

Follow these steps to remove all breakpoints:

  1. In the right navigation menu, click the Run & debug icon Run and Debug icon.
  2. In the Run and Debug panel, hover over the Breakpoints section and then click the Remove All Breakpoints icon.

Launch Debugger

Follow these steps to launch the debugger:

  1. Open the project you want to debug.
  2. Open the notebook file in your project.
  3. In a notebook cell, add at least one breakpoint.
  4. In the top-left corner of the cell, click the drop-down arrow and then click Debug Cell.

If the Run and Debug panel is not open, it opens when the first breakpoint is hit.

Control Debugger

After you launch the debugger, you can use the following buttons to control it:

ButtonNameDefault Keyboard ShortcutDescription
Debugger continue iconContinueContinue execution until the next breakpoint
Debugger step over iconStep OverAlt+F10Step to the next line of code in the current or parent scope
Debugger step into iconStep IntoAlt+F11Step into the definition of the function call on the current line
Debugger restart iconRestartShift+F11Restart the debugger
Debugger disconnect iconDisconnectShift+F5Exit the debugger

Inspect Variables

After you launch the debugger, you can inspect the state of your notebook as it executes each line of code. You can inspect local variables or custom expressions. The values of variables in your notebook are formatted in the IDE to improve readability. For example, if you inspect a variable that references a DataFrame, the debugger represents the variable value as the following:

Dataframe in a debugger variable view

Local Variables

The Variables section of the Run and Debug panel shows the local variables at the current breakpoint. If a variable in the panel is an object, click it to see its members. The panel updates as the notebook runs.

Local variables in debugger view

Follow these steps to update the value of a variable:

  1. In the Run and Debug panel, right-click a variable and then click Set Value.
  2. Enter the new value and then press Enter.

Custom Expressions

The Watch section of the Run and Debug panel shows any custom expressions you add. For example, you can add an expression to show a datetime object.

Inspect custom variables in debugger view

Follow these steps to add a custom expression:

  1. Hover over the Watch section and then click the plus icon that appears.
  2. Enter an expression and then press Enter.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: