-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[Debuginfo] Use Reference DINode for references, delineate between mut/non-mut ref/ptr #136080
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
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Uh... huh. I can't replicate this test failure on my end (WSL Ubuntu, nor I'm not sure there's a solution that's less of a hack than the r-value reference workaround, and that Just Worked™ in a lot of ways that this one doesn't (e.g. the visualizer scripts). Either way, if i can't test this solution, I can't really fix it so it is what it is. |
Reimplementation of this pr which adds differentiation between pointers and refs, as well as differentiation between mut/non-mut for both. with a slightly less hack-y workaround to the issue below:
C-centric debuggers (read: all 3 of our supported debuggers) consider
&&u8
to be an r-value reference (no equivalent in Rust) or a completely invalid construct, I'm not sure which. In either case, it effectively reinterpret-casts it to&u8
- i.e. a reference to the bottom 8 bits of the address that points to au8
. It's questionable whether this can be solved on the debugger-end. For LLDB, since we're currently piggybacking onTypeSystemClang
, this behavior isn't incorrect for its intended language (C/C++, where ref-to-ref is explicitly illegal). GDB has rust-specific handling, but I'm not super familiar with it. If ref handling isn't inextricably linked to the universal debug info processing, it could be an easy fix. If not, it seems like it'd probably be a big rework. IIRC CDB/Natvis are essentially non-issues for this, since refs are just implicitly converted to pointers for all debugging purposes.Wrapping one of the "adjacent" refs in a fake-debuginfo-struct is necessary because, as evinced by the current behavior of raw pointer debug info, the
name
field that we pass toLLVMRustDIBuildPointerType
is not respected in any way. As such, this patch turns all "outer" refs in ref-to-refs to themsvc
-styleref$<>
(with a single raw pointer member calledptr
).For example
&&u8
->ref$<&u8>
,&mut &&u8
->ref_mut$<ref$<&u8>>
. A nice consequence of wrapping only the outer references is that it doesn't affect non-msvc handling of things like&str
and&[u8]
.The natvis script was trivial to update, and LLDB is what I'm most familiar with so those should be fine.
I did my best to keep the GDB formatter in-line with what already exists, but GDB's python API is a fair bit weaker than LLDB's so it's not perfect. If we could get a frequent GDB user to give it a spin and let me know if they'd like anything changed, that would be awesome.
Once again worth pointing out that GDB is hard-coded to format all pointers as
*mut
. That should be pretty trivial for them to remove, and I've writtenPtrTypePrinter
in such a way that it shouldn't require any changes on our end once it's fixed on theirs. I tried to write aNestedRefTypePrinter
but it straight up refused to work. The recognizer function wasn't even been called at any point. GDB's rust-specific C code might be bypassing theTypePrinter
API for struct types? I'm not 100% sure.Also, just like before,
Box
does not have any special handling and is just treated as a*mut
.