Incorrect debug information leading to bad visualzization for &str and slice arguments in MSVC debuggers. #81894
Labels
A-debuginfo
Area: Debugging information in compiled programs (DWARF, PDB, etc.)
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
(Fix for this problem: #81898)
When lowering MIR to LLVM IR, the compiler decomposes every function argument of type &str or slice into two components: a pointer to the memory address referenced to by the &str or slice and an integer represent the length of the str or slice. Then, the original argument is constructed in the body of the function from the data pointer and the integer arguments. Since the original argument is declared in the body of the function that owns it, it should be marked as a LocalVariable instead of an ArgumentVariable. This confusion makes MSVC debuggers unable to visualize &str and slice arguments correctly. Because these debuggers implicit treat arguments whose sizes are greater than that of a pointer as pass by reference, the values of &str or slice arguments are treated as their reference, leading to incorrect visualization for &str and slice arguments.
I tried this code:
When stepping through the code in VS Code C++ debugger, I expected to see this happen:
Instead, this happened:
Meta
This error is found on rust 1.51.0-dev, 1.50, and 1.49.
The text was updated successfully, but these errors were encountered: