Add nightly-only support for Cargo unremap trim-paths files in rust-gdb - #160560
Add nightly-only support for Cargo unremap trim-paths files in rust-gdb#160560Urgau wants to merge 1 commit into
rust-gdb#160560Conversation
|
rustbot has assigned @Mark-Simulacrum. Use Why was this reviewer chosen?The reviewer was selected based on:
|
There was a problem hiding this comment.
How should we test this? Do you have any manual steps to follow?
There was a problem hiding this comment.
Side note: I am adding tests in rust-lang/rust exercising the unremap file itself.
There was a problem hiding this comment.
I tested it by manually modifying the rust-gdb script to point to my local gdb_trim_paths.py ("$GDB_PYTHON_MODULE_DIRECTORY/gdb_trim_paths.py" to "$YOUR_RUST_LOCAL_CHECKOUT/src/etc/gdb_trim_paths.py"), as otherwise you need to do x.py dist which annoying.
Then I created a dummy hello-world Cargo project, cargo build-it and manually added the hello-world.trim-paths.jsonl file (since the Cargo bump PR is not yet merged).
After that you can just execute rust-gdb as always:
rust-gdb target/debug/hello-world&run- or
rust-gdb&file target/debug/hello-world&run
Tip: show substitute-path shows all the substitutions.
813cc60 to
cb80619
Compare
cb80619 to
410b8d8
Compare
|
|
||
| # We only handle version 1 | ||
| if ver == 1: | ||
| _process_v1_trim_paths(lines, trim_paths_path) |
There was a problem hiding this comment.
Should we print a warning for unrecognized version?
There was a problem hiding this comment.
I don't know, I added one at first, but I don't want users to have one (or more) warnings about unsupported versions, which can happen when Cargo update the version, in particular since this logic is been handled automatically.
There isn't a way to suppress the warning at the moment.
This PR adds support in
rust-gdbfor the un-remapping file produced by Cargo with-Ztrim-paths(rust-lang/cargo#17303). This support is nightly-only, and only activated whenRUST_GDB_TRIM_PATHS=unstableis set.An example of the unremap file:
{"v":1} {"rust_version":"1.96.0-nightly","workspace_root":"/home/me/app"} {"from":"/cargo/build-dir","to":"/home/me/app/target"} {"from":"/cargo/registry/6f17d22d3f0a95d1","to":"/home/me/.cargo/registry/src/index.crates.io-6f17d22d3f0a95d1"} {"from":"/rustc/abc123","to":"/home/me/.rustup/toolchains/nightly/lib/rustlib/src/rust"}Disclaimer: I used Gemini to figure out how to interact with GDB, GDB doc is not very discoverable, everything can be sourced to the docs (links in the source code).
cc @weihanglo