Gimlet
Gimlet is a VSCode Extension for debugging Solana programs. It is a wrapper for the locally installed tools agave-ledger-tool
and solana-lldb
.
Table of Contents
Prerequisites
Before using Gimlet, ensure you have the following tools installed:
Tool |
Installation Command |
Notes |
rust-analyzer |
Rust Analyzer Extension |
VSCode extension |
agave-ledger-tool |
cargo install agave-ledger-tool |
|
solana-cli |
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)" |
Use latest version (2.0.23 at time of writing) |
solana-lldb |
See setup instructions |
|
Setup
Choose the appropriate setup instructions for your operating system:
macOS
1. Configuring PATH Variables
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
2. If solana-lldb is not found
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.
Windows (WSL)
1. Prerequisites
2. Configuring PATH Variables (IMPORTANT!)
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
Installation
- Install the extension from the VS Code Marketplace
- Ensure you have all Prerequisites installed locally
Usage
Getting Started
- Open VS Code inside your Solana project folder
- Start your local ledger (see Running Agave Ledger Tool)
- Use
Ctrl+Shift+P
(or Cmd+Shift+P
on macOS) to run Gimlet: Check Dependecies
- this will run a script to verify all dependencies
- Use the command palette to run either
Run Agave Ledger Tool
or Run Solana LLDB
Starting a Local Ledger
Before running any commands, you need to start a local ledger:
solana-test-validator --ledger ./ledger
- Open the Command Palette (
Ctrl+Shift+P
or Cmd+Shift+P
)
- Select
Run Agave Ledger Tool
- Enter a valid subcommand when prompted (example:
accounts
)
The output will be displayed in the integrated terminal.
Note: Make sure you have a local ledger set up and running before executing commands.
Debugging a Solana Program
Step-by-Step Process
Note: Gimlet: Check Dependencies
in the Command Palette to verify all requirements.
- Start local ledger - Follow the instructions in Running Agave Ledger Tool
- Open Command Palette - Use
Ctrl+Shift+P
(or Cmd+Shift+P
on macOS)
- Select debugging option - Choose
Run Solana LLDB
- Automatic setup - The extension will build and start debugging your Solana program using solana-lldb
- Set breakpoints - Once setup is complete, you can set and remove breakpoints in the IDE
- Launch process - Run the
Re-run process launch
command to start debugging with your breakpoints
Important Notes
- Breakpoint management: If you run the debugger again, remove current breakpoints and set them again
- Process launching: After setting breakpoints, use
Re-run process launch
to restart the program and stop at your breakpoints
- Restarting: You can run the entire debugging command again to restart the whole process
Re-run process launch
Command from Command Pallette
This command re-runs the currently mounted executable in the same terminal, allowing you to restart debugging with your current breakpoints.
Tip: You can run the debugging command multiple times to restart the entire debugging session.
Additional LLDB Commands
For a comprehensive list of LLDB commands and their usage, refer to the official LLDB Commands Documentation.
Example Project
For detailed step-by-step instructions on how to run the example project, refer to the Installation and Run Guide.
Troubleshooting
macOS
If you encounter issues with the extension, verify that you have the following packages installed:
Required Packages
Package |
Installation Command |
protobuf |
brew install protobuf |
llvm |
brew install llvm |
Common Issues and Solutions
PATH Configuration for LLVM
Add this to your .zshrc
or .bashrc
:
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
args-dumper
Not Found Error
Add this to your .zshrc
or .bashrc
:
export LLDB_DEBUGSERVER_PATH="/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver"
Attach Failed (Not Allowed to Attach to Process)
Check Console Messages: Look in Console.app near the debugserver entries when the attach failed. The subsystem that denied permission will likely have logged an informative message.
Grant Developer Tools Access:
- Go to
System Preferences
→ Privacy & Security
→ Developer Tools
- Grant access to Terminal
Disable Debugging Protection: On some machines, you may need to disable debugging protection. Refer to this Apple Developer Forum thread for detailed instructions.
Permission Denied When Trying to Debug a Program
Refer to the Apple Developer Forum thread for instructions on disabling debugging protection for macOS systems.
Windows (WSL)
Common Issues and Solutions
libpython 3.8.so.1.0
Not Found or Executable Not Found
Install Python 3.8 and development libraries:
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
lldb-server
Not Found Error
This issue occurs when the PATH for the LLDB server is not set correctly. Add this to your .bashrc
:
export LLDB_DEBUGSERVER_PATH="/usr/bin/lldb-server"