[Bug rust/24801] New: Pretty-printing support for Rust generators

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug rust/24801] New: Pretty-printing support for Rust generators

Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24801

            Bug ID: 24801
           Summary: Pretty-printing support for Rust generators
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rust
          Assignee: unassigned at sourceware dot org
          Reporter: tmandry at gmail dot com
  Target Milestone: ---

Support printing Rust generators in a way that looks more like enums.
Generators are represented in Rust as variant layouts with some extra fields on
the outer layout. These extra fields (which are upvars, captured from the
environment of the generator closure) seem to cause printing to become less
pretty.

Today printing a Rust generator looks like this:

$2 = generator_objects::main::generator {__0: 0x7fffffffd204, <<variant>>:
{__state: 3, 0: generator_objects::main::generator::Unresumed, 1:
generator_objects::main::generator::Returned, 2:
generator_objects::main::generator::Panicked, 3:
generator_objects::main::generator::Suspend0 {c: 6, d: 7}, 4:
generator_objects::main::generator::Suspend1 {c: 6, d: 7}}}

Note that we print the fields of every single variant, even though the
discriminant is marked in DWARF.

Here's the source code:
https://github.com/rust-lang/rust/blob/c6a9e766f90a5271c2356fbc7941e38559200ab5/src/test/debuginfo/generator-objects.rs.
The above excerpt is from the second print in the test. __0 in the output is
the upvar for `a` from the environment (it should be called `a` instead of
`__0`, but this is a problem in the Rust compiler).

The corresponding DWARF:
https://gist.github.com/tmandry/92e1368b51bea06d11da1e45218813db

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug rust/24801] Pretty-printing support for Rust generators

Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24801

--- Comment #1 from Tyler Mandry <tmandry at gmail dot com> ---
Opened as https://github.com/rust-lang/rust/issues/62572 on the Rust project;
if you feel it's more appropriate to track there then feel free to close this
issue.

--
You are receiving this mail because:
You are on the CC list for the bug.
Reply | Threaded
Open this post in threaded view
|

[Bug rust/24801] Pretty-printing support for Rust generators

Martin.Jansa at gmail dot com
In reply to this post by Martin.Jansa at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=24801

Tom Tromey <tromey at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
It would be helpful to have a small Rust test program using generators.

--
You are receiving this mail because:
You are on the CC list for the bug.