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 ifCargo.lockor the cargo cache isn’t available. - discover_
path_ dep_ roots - Discover path dependencies from a crate’s
Cargo.tomland return their resolved absolute directories. These are local deps likeanchor-lang-v2 = { path = "../../../../lang-v2" }— their source root is the resolved path itself, which needs to be insrc_rootsso relative DWARF paths likesrc/lib.rsresolve to the right crate instead of colliding with a same-named file at the workspace root.