Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Automatically detect rust library source file map #8624

Merged
merged 3 commits into from
Apr 27, 2021

Conversation

vsrs
Copy link
Contributor

@vsrs vsrs commented Apr 22, 2021

This PR adds a new possible rust-analyzer.debug.sourceFileMap value:

{
    "rust-analyzer.debug.sourceFileMap": "auto"
}

I did not make it the default because it uses two shell calls (rustc --print sysroot and rustc -V -v). First one can be slow (rust-lang/rustup#783)

Fixes #8619

@EFanZh
Copy link

EFanZh commented Apr 23, 2021

I also found that there are paths start with /cargo/, Like /cargo/registry/src/github.com-1ecc6299db9ec823/. Is it a good idea to map it to the user .cargo cache? Like ~/.cargo/?

Also, the "auto" value prevents user from adding custom source mappings. How about using a separate configuration property for this?

@vsrs
Copy link
Contributor Author

vsrs commented Apr 23, 2021

I also found that there are paths start with /cargo/, Like /cargo/registry/src/github.com-1ecc6299db9ec823/. Is it a good idea to map it to the user .cargo cache? Like ~/.cargo/?

I suppose, these are dependencies, and all the necessary information should be in the compiled executable (or pdb on windows).

Also, the "auto" value prevents user from adding custom source mappings.

This is intentional. Conflicts are possible if you automatically add a value to the existing source map. And it's easy to forget and then spend a lot of time trying to figure out the reason. Trust me, I've done that before :)

@EFanZh
Copy link

EFanZh commented Apr 23, 2021

The /cargo dependencies are likely to be dependencies used by standard libraries.

For example, this command on my PC:

nm -Cl ~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/libstd-b1047a2788193be4.so | grep /cargo

shows many symbols that have paths start with /cargo/. This library is distributed with the Rust toolchain.

@matklad
Copy link
Member

matklad commented Apr 27, 2021

bors d+

The code looks OK to me, but I don't really understand the debugging domain at all )

@bors
Copy link
Contributor

bors bot commented Apr 27, 2021

✌️ vsrs can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@vsrs
Copy link
Contributor Author

vsrs commented Apr 27, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 27, 2021

@bors bors bot merged commit fb45d2a into rust-lang:master Apr 27, 2021
@lnicola lnicola changed the title Automatically detect rust library source file map feat: Automatically detect rust library source file map Apr 28, 2021
@vsrs vsrs deleted the auto_src_map branch October 18, 2021 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect Rust library source file map automatically according to the current toolchain
3 participants