Gimlet is a VSCode Extension for debugging Solana programs. It is a wrapper for the locally installed tools agave-ledger-tool
and solana-lldb
.
rust-analyzer
-> Rust Analyzer Extensionagave-ledger-tool
->cargo install agave-ledger-tool
solana-cli
->sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
NOTE: Use latest version (2.0.23 at time of writing)solana-lldb
-> setup
Depending on your operating system, follow the relevant setup instructions below:
# Add the following lines to your `.zshrc` or `.bashrc`:
# Solana CLI path
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
# Solana LLDB tools path
# Note: Choose only one of the two options based on your Solana installation structure.
# Option 1
export PATH="/$PATH:/Users/user/.local/share/solana/install/active_release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin"
# Option 2
export PATH="$PATH:$HOME/.local/share/solana/install/active_release/bin/sdk/sbf
Run this command inside a Solana Rust project
cargo-build-sbf --force-tools-install
This will force the installation of missing Solana build tools required for debugging.
-
Follow the Solana Guide for WSL
-
Additionally install lldb ->
sudo apt install lldb
# Add the following lines to your `.bashrc`:
. "$HOME/.cargo/env"
export PATH="/usr/bin:$PATH"
export PATH="/usr/local/bin:$PATH"
export PATH="$HOME/.cargo/bin:$PATH"
export PATH="/root/.avm/bin:$PATH"
export PATH="/root/.local/share/solana/install/active_release/bin:$PATH"
export LLDB_DEBUGSERVER_PATH="/usr/bin/lldb-server"
# Solana LLDB tools path (choose the one matching your installation)
# Option 1
export PATH="/$PATH:/root/.local/share/solana/install/active_release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin"
# Option 2
export PATH="/$PATH:/root/.local/share/solana/install/active_release/bin/sdk/sbf
- Install the extension from the VS Code Marketplace.
- Ensure you have the Prerequisites installed locally.
- Open your VS Code inside the Solana project folder.
- Use the command palette (
Ctrl+Shift+P
orCmd+Shift+P
) to runRun Agave Ledger Tool
orRun Solana LLDB
.
- Open the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
). - Select
Run Agave Ledger Tool
. - Enter a valid subcommand when prompted, for example:
accounts
The output will be displayed in the integrated terminal.
Note: Before running commands, make sure you have a local ledger set up and running.
You can start a local ledger using the following command:
solana-test-validator --ledger ./ledger
- Open the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
). - Select
Run Solana LLDB
. - The extension will build and start debugging your Solana program using solana-lldb.
- Once everything is completed you can set and remove breakpoints in the IDE and commands will automatically run inside the terminal. (If you run it again you should remove current breakpoints and redo them).
- After you've set breakpoint you need to run the command
Re-run process launch
to launch the program again and stop at the set breakpoints.
- It re-runs the currently mounted executable in the same terminal.
TIP: You can run the command again to restart the whole thing.
Refer to this site LLDB Commands
For detailed steps on how to run the example project, refer to the installation and run guide.
if you have troubles with the extension, check if you have the following things installed:
protobuf
->brew install protobuf
llvm
->brew install llvm
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
In .zshrc
or .bashrc
:
export LLDB_DEBUGSERVER_PATH="/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver"
Look in the console messages (Console.app), near the debugserver entries, when the attach failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.
Go to:
System Preferences
->Privacy & Security
->Developer Tools
->Grant access to Terminal
On some machines, the step below could also fix the issue:
Refer to this Apple Developer Forum thread to disable debugging protection for macOS systems.
sudo apt update
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.8 python3.8-dev
python 3.8 --version
This might be caused if PATH for the lldb server is not set correctly. In .bashrc
export LLDB_DEBUGSERVER_PATH="/usr/bin/lldb-server"