Gimlet is a VSCode Extension for debugging Solana programs. It is a wrapper for the locally installed tools agave-ledger-tool and solana-lldb.
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 |
Choose the appropriate setup instructions for your operating system:
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/sbfRun this command inside a Solana Rust project:
cargo-build-sbf --force-tools-installThis will force the installation of missing Solana build tools required for debugging.
- Follow the Solana Guide for WSL
- 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- To correctly debug
sBPFSolana programs you must use thellvm-objdumpandsolana-lldbprovided by Solana's Platform Tools - not your locally(system) installed version.
export PATH="$PATH:$HOME/.local/share/solana/install/active_release/bin/sdk/sbf/dependencies/platform-tools/llvm/bin"which llvm-objdumpwhich solana-lldb- Install the extension from the VS Code Marketplace
- Ensure you have all Prerequisites installed locally
- Open VS Code inside your Solana project folder
- Start your local ledger (see Running Agave Ledger Tool)
- Use
Ctrl+Shift+P(orCmd+Shift+Pon macOS) to runGimlet: Check Dependecies- this will run a script to verify all dependencies - Use the command palette to run either
Run Agave Ledger ToolorRun Solana LLDB
Before running any commands, you need to start a local ledger:
solana-test-validator --ledger ./ledger- Open the Command Palette (
Ctrl+Shift+PorCmd+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.
IMPORTANT for Native Solana Programs:
When debugging native Solana programs (not using Anchor), you must add the#[no_mangle]and#[inline(never)]attributes to each instruction function you want to debug.
This ensures the function names are preserved and not optimized away, making breakpoints and debugging possible.
Note:
Gimlet: Check Dependenciesin the Command Palette to verify all requirements.
!IMPORTANT: You must have JSON file to execute an instruction using
agave-ledger-tool-> Input JSON Guide.
-
Start Local Ledger
Run:solana-test-validator --ledger ./ledger
(This launches the Agave ledger environment.)
-
Open Command Palette
- Windows/Linux:
Ctrl + Shift + P - macOS:
Cmd + Shift + P
- Windows/Linux:
-
Launch Solana LLDB Debugging
- In the Command Palette, select
Run Solana LLDB.
- In the Command Palette, select
-
Run Agave Ledger Tool for Breakpoints
- In the Command Palette again, select
Run Agave Ledger Tool for Breakpoint. - This will deploy and execute your instruction using the
input.jsonfile.
- In the Command Palette again, select
-
Monitor the Solana LLDB Terminal
- Wait until agave-ledger-tool connects successfully.
- Then focus on the Solana LLDB terminal.
-
Set Breakpoints
- Once the setup is complete, set or remove breakpoints in your IDE as needed.
-
Continue Process
- Run the
continuecommand inside thesolana-lldbterminal to start debugging with your breakpoints active. - Or use the
Continue processfrom Command Palette both of them are the same
- Run the
-
Restarting: To debug another instruction, run the
Agave Ledger Tool for Breakpointscommand again with a newinput.jsonfor that specific instruction. -
Process Launching: After setting breakpoints, use
continueto restart the program and stop at your breakpoints. -
Multiple Breakpoints: Gimlet will make you choose one of your set breakpoints because
agave-ledger-toolcan run only for one instruction at a time.
This command resumes the currently paused breakpoint in the same terminal, allowing you to resume the debugging with your current breakpoint.
Tip: You can run the debugging command multiple times to restart the entire debugging session.
For a comprehensive list of LLDB commands and their usage, refer to the official LLDB Commands Documentation.
For detailed step-by-step instructions on how to run the example project, refer to the Installation and Run Guide.
If you encounter issues with the extension, verify that you have the following packages installed:
| Package | Installation Command |
|---|---|
protobuf |
brew install protobuf |
llvm |
brew install llvm |
Add this to your .zshrc or .bashrc:
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"Add this to your .zshrc or .bashrc:
export LLDB_DEBUGSERVER_PATH="/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver"-
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
- Go to
-
Disable Debugging Protection: On some machines, you may need to disable debugging protection. Refer to this Apple Developer Forum thread for detailed instructions.
Refer to the Apple Developer Forum thread for instructions on disabling debugging protection for macOS systems.
Install Python 3.10 and development libraries:
sudo apt update
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10 python3.10-dev
python 3.10 --versionThis 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"Sometimes, even after following the documentation to set up your PATH, tools like solana-lldb may not appear immediately. The exact location of platform-tools can vary slightly between machines, so you might need to locate it manually.
Steps:
- Locate the solana installation folder
The default location is usually:
$HOME/.local/solana/install/active_release/bin- Find the
llvm/binfolder
platform-tools/llvm/binThis directory contains solana-lldb, llvm-objdump, and other necessary tools.
- Add the folder to your PATH You can temporarily add it with:
export PATH=$HOME/.local/solana/install/active_release/bin/platform-tools/llvm/bin:$PATH- Verify the installation
solana-lldb --version If it shows the version, your PATH is set correctly, and the debugger tools are ready to use.