Debug a Rust executable¶
Stop inside a Rust binary and inspect its state.
Prerequisites¶
codelldbonPATH—command -v codelldb- a Cargo project
Config¶
bugsaur init writes this for you; check that program matches your binary
name.
In a workspace there is one profile per binary, and program is
target/debug/<binary name> — target/ lives at the workspace root.
Run¶
Order matters: program points at a build artifact, and Bugsaur does not build
Rust for you.
What should happen¶
The window opens, the program runs and stops at line 15. Variables shows the locals of that frame, Call Stack shows how you got there.
Variations¶
A specific binary in a workspace¶
With arguments¶
[profiles.app]
adapter = "codelldb"
program = "target/debug/app"
args = ["import", "--dry-run", "${root}/fixtures/sample.csv"]
With environment from a file¶
[profiles.app]
adapter = "codelldb"
program = "target/debug/app"
env_file = ".env"
env = { RUST_LOG = "debug" }
Code that reads CARGO_* at runtime¶
cargo run sets variables a direct launch does not. Add what the code needs:
When it does not work¶
| Symptom | Fix |
|---|---|
program is not readable |
run cargo build; check the binary name in program |
| Session never starts | codelldb not on PATH — Adapter fails to start |
| Stops but shows no variables | you built with --release; debug the debug build |
| Never stops | Breakpoints not hit |