-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix debug information for function arguments of type &str or slice. #81898
Fix debug information for function arguments of type &str or slice. #81898
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @varkor (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
3350e00
to
b873670
Compare
When using DWARF debuginfo, using fn foo(a: &str) {}
fn main() {
foo("a");
} Lldb will currently show:
This PR would remove the |
@bjorn3: Thank you for your feedback. My fix aims to target CodeView symbols only. I wonder what would be the ideal way to fix this issue for both CodeView and DWARF symbols? |
Maybe you could add a check that the target is windows. (msvc only. I think mingw uses dwarf, but I am not sure) |
@bjorn3: I believe the is_like_msvc check should be sufficient? mingw would meet the is_like_windows check but not is_like_msvc? |
I think so. |
This comment has been minimized.
This comment has been minimized.
731b9e6
to
615fd14
Compare
Alright, I just updated my code accordingly. |
I have absolutely zero knowledge about the format of pdb debuginfo, so I have no idea if this is correct for msvc targets. r? @varkor |
@varkor : Hi, I wonder if there is any further work that should be done for this PR? |
Hi, @varkor . I'm @nanguye2496 's manager. We are members of the Windows Engineering System, at Microsoft. We have worked with our peers in the Windows Debugger team, and confirmed that this change is correct. Before this commit, the PDB / CodeView records are malformed. This commit fixes that, and allows the debug-spill variable that is created for We believe there is more work to do in this area, but that this change is a good first step toward improving the experience of debugging Rust code on Windows. |
Sorry for the delay; I've been busy with non-Rust priorities for the last few days. The change looks fine to me, thanks! @bors r+ |
📌 Commit 615fd14 has been approved by |
No worries. Thanks! |
Rollup of 8 pull requests Successful merges: - rust-lang#77728 (Expose force_quotes on Windows.) - rust-lang#80572 (Add a `Result::into_ok_or_err` method to extract a `T` from `Result<T, T>`) - rust-lang#81860 (Fix SourceMap::start_point) - rust-lang#81869 (Simplify pattern grammar, improve or-pattern diagnostics) - rust-lang#81898 (Fix debug information for function arguments of type &str or slice.) - rust-lang#81972 (Placeholder lifetime error cleanup) - rust-lang#82007 (Implement reborrow for closure captures) - rust-lang#82021 (Spell out nested Self type in lint message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…ests, r=Mark-Simulacrum Add debug info tests for range, fix-sized array, and cell types This PR add several debug info tests to guarantee that the displays of fixed sized arrays, range types, cell types, threads, locks, and mutexes in CDB are correct. It also updates CDB tests for slices in pretty-std.rs after string visualization in WinDbg is fixed by this PR: rust-lang#81898.
…ests, r=Mark-Simulacrum Add debug info tests for range, fix-sized array, and cell types This PR add several debug info tests to guarantee that the displays of fixed sized arrays, range types, cell types, threads, locks, and mutexes in CDB are correct. It also updates CDB tests for slices in pretty-std.rs after string visualization in WinDbg is fixed by this PR: rust-lang#81898.
…ts, r=Mark-Simulacrum Add debug info tests for range, fix-sized array, and cell types This PR add several debug info tests to guarantee that the displays of fixed sized arrays, range types, cell types, threads, locks, and mutexes in CDB are correct. It also updates CDB tests for slices in pretty-std.rs after string visualization in WinDbg is fixed by this PR: rust-lang#81898.
Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in PR rust-lang#81898.
…rpair_params, r=oli-obk Fix debuginfo for parameters passed via the ScalarPair abi on Windows Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in rust-lang#81898. Fixes rust-lang#88625
Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in PR rust-lang#81898.
…air_params, r=oli-obk Fix debuginfo for parameters passed via the ScalarPair abi on Windows Mark all of these as locals so the debugger does not try to interpret them as being a pointer to the value. This extends the approach used in rust-lang#81898. Fixes rust-lang#88625
Issue details:
When lowering MIR to LLVM IR, the compiler decomposes every &str and slice argument into a data pointer and a usize. Then, the original argument is reconstructed from the pointer and the usize arguments in the body of the function that owns it. Since the original argument is declared in the body of a function, it should be marked as a LocalVariable instead of an ArgumentVairable. This confusion causes MSVC debuggers unable to visualize &str and slice arguments correctly. (See #81894 for more details).
Fix details:
Making sure that the debug variable for every &str and slice argument is marked as LocalVariable instead of ArgumentVariable in computing_per_local_var_debug_info. This change has been verified on VS Code debugger, VS debugger, WinDbg and LLDB.