-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Could not debug into a generic method defined in an external crate #19228
Comments
cc me |
Thanks for the report, @magic003! This is a known shortcoming of debuginfo in Rust at the moment: When an external crate is referenced while compiling another crate, the ASTs of any generic functions from the external crate get copied into the current compilation so that the compiler can treat them mostly like normal, 'local' generic function definitions. At that point, there is no way of emitting source locations in the generated debuginfo for the function, since this information has been lost when initially compiling the external crate. As soon as we implement that source locations are saved in the ASTs of generic functions, this should just work when compiling and using things on one machine. |
…oerister This allows to create proper debuginfo line information for items inlined from other crates (e.g. instantiations of generics). Only the codemap's 'metadata' is stored in a crate's metadata. That is, just filename, positions of line-beginnings, etc. but not the actual source code itself. Crate metadata size is increased by this change because spans in the encoded ASTs take up space now: ``` BEFORE AFTER libcore 36 MiB 39.6 MiB +10% libsyntax 51.1 MiB 60.5 MiB +18.4% libcollections 11.2 MiB 12.8 MiB +14.3% ``` This only affects binaries containing metadata (rlibs and dylibs), executables should not be affected in size. Fixes #19228 and probably #22226.
Reproduce Steps
cargo new test_rust
lib.rs
file to:Basically, it defines a trait and a generic method which accepts it as an argument.
3. Run
rustc -g src/lib.rs
to compile it and rungdb lib
to debug. It could step into theprint_area()
function and the result is correct as well.4. If I move the
main()
function into a standalone filemain.rs
and referece this library usingexternal crate test_rust
, callcargo build
to build the library(I already set the debug flag inCargo.toml
) and runrustc -g -extern test_rust=target/libXXXX main.rs
. I could not debug into theprint_area()
function, though the running result is correct. In gdb, it just goes to next line instead of going to the function definition.Please note if I don't use generic for the function, both cases are working as expected.
OS
Archlinux x86_64
Rust version
rustc 0.13.0-nightly (81eeec0 2014-11-21 23:16:48 +0000)
binary: rustc
commit-hash: 81eeec0
commit-date: 2014-11-21 23:16:48 +0000
host: x86_64-unknown-linux-gnu
release: 0.13.0-nightly
The text was updated successfully, but these errors were encountered: