-
Notifications
You must be signed in to change notification settings - Fork 13k
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
[Debuginfo] Use Reference DINode for references, delineate between mut and const ref/ptr #134597
Conversation
r? @wesleywiser rustbot has assigned @wesleywiser. Use |
There are merge commits (commits with multiple parents) in your changes. We have a no merge policy so these commits will need to be removed for this pull request to be merged. You can start a rebase with the following commands:
The following commits are merge commits: |
This comment has been minimized.
This comment has been minimized.
3201838
to
f386d48
Compare
This comment has been minimized.
This comment has been minimized.
lol that's about what I expected. Looks like gdb auto-derefs any references, so it errors on any attempts to dereference them (which seems like kinda silly behavior?). The tests currently expect:
Whereas refs are formatted with both the type information and the address:
In order to make changing these less painful, I'll probably make a separate test to |
I've also done a bit of digging and GDB's pointer problem can be solved on their end. Right now they unconditionally format all pointer-tagged types as |
This comment has been minimized.
This comment has been minimized.
Huh, in
Note the extra space inbetween |
This comment has been minimized.
This comment has been minimized.
and now it prints without the extra space
??? |
This comment has been minimized.
This comment has been minimized.
@rustbot review |
☔ The latest upstream changes (presumably #133990) made this pull request unmergeable. Please resolve the merge conflicts. |
…orn3 Subtree sync for rustc_codegen_cranelift Aside from a Cranelift update, nothing major this time. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
Co-authored-by: Jubilee <[email protected]>
rustc-dev-guide subtree update This PR performs the first update of rustc-dev-guide code from its repository. r? `@BoxyUwU`
…s, r=workingjubilee Add a notion of "some ABIs require certain target features" I think I finally found the right shape for the data and checks that I recently added in rust-lang#133099, rust-lang#133417, rust-lang#134337: we have a notion of "this ABI requires the following list of target features, and it is incompatible with the following list of target features". Both `-Ctarget-feature` and `#[target_feature]` are updated to ensure we follow the rules of the ABI. This removes all the "toggleability" stuff introduced before, though we do keep the notion of a fully "forbidden" target feature -- this is needed to deal with target features that are actual ABI switches, and hence are needed to even compute the list of required target features. We always explicitly (un)set all required and in-conflict features, just to avoid potential trouble caused by the default features of whatever the base CPU is. We do this *before* applying `-Ctarget-feature` to maintain backward compatibility; this poses a slight risk of missing some implicit feature dependencies in LLVM but has the advantage of not breaking users that deliberately toggle ABI-relevant target features. They get a warning but the feature does get toggled the way they requested. For now, our logic supports x86, ARM, and RISC-V (just like the previous logic did). Unsurprisingly, RISC-V is the nicest. ;) As a side-effect this also (unstably) allows *enabling* `x87` when that is harmless. I used the opportunity to mark SSE2 as required on x86-64, to better match the actual logic in LLVM and because all x86-64 chips do have SSE2. This infrastructure also prepares us for requiring SSE on x86-32 when we want to use that for our ABI (and for float semantics sanity), see rust-lang#133611, but no such change is happening in this PR. r? `@workingjubilee`
…iaskrgr Rollup of 3 pull requests Successful merges: - rust-lang#134898 (Make it easier to run CI jobs locally) - rust-lang#135195 (Make `lit_to_mir_constant` and `lit_to_const` infallible) - rust-lang#135261 (Account for identity substituted items in symbol mangling) r? `@ghost` `@rustbot` modify labels: rollup
There is a difference between the `image` (the Dockerfile), the `name` of the job (which determines also its properties) and the `full_name`, which includes the `auto/try/pr` prefix.
CI: fix name of jobs There is a difference between the `image` (the Dockerfile), the `name` of the job (which determines also its properties) and the `full_name`, which includes the `auto/try/pr` prefix. Missed this in rust-lang#134898.
…nceType` to RustWrapper and fii
…o reference_vis
Closing in favor of an alternative solution based on the pieces here |
The job Click to see the possible cause of the failure (guessed by this bot)
|
Adds
LLVMRustDIBuilderCreateReferenceType
to create proper reference type elements forty::Ref
, rather than blanket-outputting pointer types for all pointers and referencesAlso uses
LLVMRustDIBuilderCreateQualifiedType
in a similar way to this pr to make immutable references and pointers intoconst <type> *
.Tested with
*-msvc
with cdb and LLDB, as well as*-windows-gnu
with LLDB and GDBsample code
Unformatted output Before:
Unformatted output After:
With formatter script:
Hacks
In LLDB, nested references (
&&T
) flat out do not work. Nested pointers (*const *const T
) and ptr-to-ref (*&T
)/ref-to-pointer (&*T
) work, but presumably ref-to-ref doesn't work because it is not a legal construct in C/C++. As we're piggybacking onTypeSystemClang
, that probably isn't something we can change on the LLDB end.To work around this, you can convert the inner ref into a pointer (
&&T
->&*T
) to prevent&&
from ever occurring. This has the downside of losing debug information though, as ref-to-ref that looks like ref-to-ptr is not differentiable from an actual ref-to-ptr.To work around that, I've hijacked dwarf's
rvalue_reference
tag (which does not have a real equivalent in rust anyway, and is incredibly conveniently denoted by&&
) to indicate ref-to-ref. Debugger scripts can then match on this to "unpack" the type name to accurately convert it back to its Rust equivalent. I've left a solid essay explaining this in detail in the rust debuginfo code to help ease the maintenance burden of this.AFAIK there is not an alternative that maintains the ref vs pointer information besides wrapping the values in an even more obtrusive struct.
Deficiencies
mutability
field, so it's not immediately clear how to format the type name. The comments ofbuild_pointer_or_reference_di_node
mention eventually maybe handlingBox
as a smart pointer, so that might be an option to fix things.*mut
(even without any formatting script at all). So no regression there, but it's still strange. It might be fixable in the future? Some cursory testing showed that the pointers didn't even get thrown through the type recognizer, so iunno.whatis
,ptype
, etc.). Displaying types is an optional toggle (disabled by default iirc), and it doesn't display any information that's actually incorrect, it just exposes the "internal" debug representation (e.g.u8 *&&
) so it should be okay.