Skip to content

Quick start ​

Cairo Debugger is currently only distributed with snforge - a testing tool for Cairo, part of Starknet Foundry.

Installation ​

WARNING

Make sure to use a version >=0.60.0 of snforge - previous versions do not have the integrated debugger.

WARNING

Make sure to use a version >=2.18.0 of Scarb - previous versions cannot produce the required debug information nor display ▶ Debug Test code lens.

To make the Cairo Debugger work, you have to install:

  1. snforge - a part of Starknet Foundry. Make sure to use version >=0.60.0
  2. Scarb package manager. Make sure to use version >=2.18.0.
  3. For Visual Studio Code, install the latest Cairo 1.0 extension from the marketplace. Make sure to use version >=3.6.0.

Prerequisites ​

Live debugging relies on debug information generated by Scarb. Make sure the cairo compiler configuration in your workspace Scarb.toml is equivalent to the following one:

toml
[profile.dev.cairo]
skip-optimizations = true
add-statements-code-locations-debug-info = true
add-statements-functions-debug-info = true
add-functions-debug-info = true
add-types-debug-info = true

Usage ​

Visual Studio Code ​

Click the ▶ Debug Test code lens above the test function you want to debug - the Cairo extension will start a debugging session automatically.

See the Debugging in VSCode guide for a full step-by-step walkthrough.

Debugging in another IDE ​

If you are using another IDE, you need to make sure that your DAP client establishes the connection with snforge's debug adapter after it is launched. If you run:

shell
$ snforge test --exact my_package::my_module::test_name --launch-debugger

snforge will start a TCP server and print the port it is listening on to stdout in the following format:

shell
DEBUGGER PORT: 12345

Connect your DAP client to localhost on that port to begin the debugging session.

NOTE

--launch-debugger requires --exact - only a single test can be debugged at a time.

Troubleshooting ​

If you run into issues, see the Troubleshooting page.