Debugging Tools
Combine dbg!, tracing, debuggers (lldb/gdb), rust-analyzer, and cargo expand for compile-time and runtime issues.
Busca en todas las páginas de la documentación
Combine dbg!, tracing, debuggers (lldb/gdb), rust-analyzer, and cargo expand for compile-time and runtime issues.
use tracing::{info, instrument};
#[instrument]
async fn handle(id: u64) -> Result<(), Error> {
info!(%id, "start");
dbg!(&config);
Ok(())
}RUST_LOG=debug cargo run
rust-lldb target/debug/myapp| Tool | Use |
|---|---|
dbg! | quick stderr print of value+location |
tracing | structured logs and spans in async |
rust-lldb / rust-gdb | breakpoints, backtrace |
rust-analyzer | types, borrow errors inline |
cargo expand | macro debugging |
samply / perf | CPU profiles |
# backtrace on panic
RUST_BACKTRACE=1 cargo runEnable debug = 1 in release profile for symbolicated prod profiles. tracing-subscriber with EnvFilter. tokio-console for async task introspection.
| Alternative | Use When | Don't Use When |
|---|---|---|
eprintln! | tiny scripts | production services |
log crate | legacy | new projects use tracing |
| printf debug | quick | team services |
macOS lldb common; linux either; use rust-lldb wrapper.
CodeLLDB extension with launch.json cargo build.
color-eyre in binaries for human panic reports.
dhat/heaptrack separate from lldb.
gdbserver in container; attach from host.
browser devtools not lldb.
fmt, json, opentelemetry subscriber layers stack.
cargo test -- --nocapture plus lldb on test binary.
Miri UB; lldb runtime state.
Filter crates sqlx=warn etc.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Revisado por Chris St. John·Última actualización: 16 jul 2026