Skip to main content

Module cargo_deps

Module cargo_deps 

Source
Expand description

Discover dependency source trees so the TUI can read files whose DWARF paths were emitted relative to each crate’s compile dir (cargo strips DW_AT_comp_dir on some builds, leaving entries like src/cpi.rs).

Strategy: parse the workspace Cargo.lock, locate each registry or git dep in the local cargo cache, and hand back those directories. The resolver in [super::tui::resolve_src_path] tries each as a join-root and uses the first match.

Ambiguity note. Relative paths like src/lib.rs exist in almost every crate. When multiple deps could match, the first one in Cargo.lock wins — deterministic but not always semantically correct. Unique paths like src/sysvars/rent.rs disambiguate cleanly in practice. We accept this tradeoff because the alternative — routing each relative path through PC-and-symbol-aware dep selection — is disproportionate effort for the mostly-cosmetic win.

Functions§

discover_dep_src_roots
Return a list of directories to try when joining a relative DWARF path. Each entry is a crate source root under $CARGO_HOME/registry/src/ or $CARGO_HOME/git/checkouts/. Empty vec if Cargo.lock or the cargo cache isn’t available.
discover_path_dep_roots
Discover path dependencies from a crate’s Cargo.toml and return their resolved absolute directories. These are local deps like anchor-lang-v2 = { path = "../../../../lang-v2" } — their source root is the resolved path itself, which needs to be in src_roots so relative DWARF paths like src/lib.rs resolve to the right crate instead of colliding with a same-named file at the workspace root.