Expand description
“Loose” mode for anchor debugger — runs in any cargo workspace
without requiring an Anchor.toml.
Anchor projects ship an Anchor.toml that maps program names to
deployed pubkeys and pins the cargo test invocation. Bench /
research workspaces are plain cargo workspaces that happen to use
anchor-lang-v2 as a library — forcing them to author an Anchor.toml
just to use the debugger would be friction for no payoff.
This module covers everything the Anchor.toml-driven path provides:
- Workspace root — walk up from cwd looking for the nearest
Cargo.tomldeclaring[workspace]. - Current package — read
<cwd>/Cargo.tomlfor the[package] name. - Test invocation —
cargo test --features profile -p <pkg>from the workspace root. - Program → ELF map — pair
target/deploy/*.sowith the matching*-keypair.jsonto recover the deployed pubkey.
Sanity checks fire as early as possible so the user gets actionable errors instead of opaque “no traces” messages later.
Structs§
- Loose
Workspace - Discovered cargo workspace context.
Functions§
- clear_
profile_ dir - Wipe the per-test trace dir before a fresh run so stale traces from a previous session don’t leak into the new picker. Idempotent — missing dir is fine.
- discover_
programs - Walk the workspace’s SBF build artifacts and return a base58
program-id →
.sopath map. Two location families are considered: - run_
cargo_ test - Run
cargo build-sbf -p <pkg>from the workspace root. This produces the post-linked.so+ sibling keypair undertarget/deploy/that solana-sbpf can parse — the rawcargo build --target sbpf-solana-solanaartifact intarget/sbpf-solana-solana/release/is missing relocation metadata our debugger needs.