Skip to main content
Version: v1.0.0-beta.0

Using the VS Code Debugger

This guide will show you how to use VS Code with the vscode-noir extension to debug a Noir project.

Pre-requisites

  • Nargo
  • vscode-noir
  • A Noir project with a Nargo.toml, Prover.toml and at least one Noir (.nr) containing an entry point function (typically main).

Running the debugger

The easiest way to start debugging is to open the file you want to debug, and press F5. This will cause the debugger to launch, using your Prover.toml file as input.

You should see something like this:

Debugger launched

Let's inspect the state of the program. For that, we open VS Code's Debug pane. Look for this icon:

Debug pane icon

You will now see two categories of variables: Locals and Witness Map.

Debug pane expanded

  1. Locals: variables of your program. At this point in execution this section is empty, but as we step through the code it will get populated by x, result, digest, etc.

  2. Witness map: these are initially populated from your project's Prover.toml file. In this example, they will be used to populate x and result at the beginning of the main function.

Most of the time you will probably be focusing mostly on locals, as they represent the high level state of your program.

You might be interested in inspecting the witness map in case you are trying to solve a really low level issue in the compiler or runtime itself, so this concerns mostly advanced or niche users.

Let's step through the program, by using the debugger buttons or their corresponding keyboard shortcuts.

Debugger buttons

Now we can see in the variables pane that there's values for digest, result and x.

Inspecting locals

We can also inspect the values of variables by directly hovering on them on the code.

Hover locals

Let's set a break point at the keccak256 function, so we can continue execution up to the point when it's first invoked without having to go one step at a time.

We just need to click the to the right of the line number 18. Once the breakpoint appears, we can click the continue button or use its corresponding keyboard shortcut (F5 by default).

Breakpoint

Now we are debugging the keccak256 function, notice the Call Stack pane at the lower right. This lets us inspect the current call stack of our process.

That covers most of the current debugger functionalities. Check out the reference for more details on how to configure the debugger.