Skip to content

Fix debug representation of arrays of structs #1340

Description

@jdm

"Up-to-date" test case:

fn main() {
    struct moo {a: float};
    let x = [moo{a: 1.5}, moo{a: 2.3}];
    io::println(fmt!("%?", x));
}

(build with rustc -Z debug-info, then load it up in gdb and set a breakpoint on main.)

Original reported test case follows

let x = [{a: 1.5},{a: 2.3}]

The values of a in gdb are wildly incorrect.

Activity

  1. marijnh commented on Jan 13, 2012

    @marijnh
    Contributor

    Objs are no longer with us.

  2. reopened this on Jan 14, 2012
  3. jdm commented on Jan 14, 2012

    @jdm
    ContributorAuthor

    This was a poorly worded issue.

  4. ghost assigned on Apr 12, 2012
  5. catamorphism commented on Apr 12, 2012

    @catamorphism
    Contributor

    (And if that doesn't work, I bet debug representations of classes don't work either :-)

  6. pnkfelix commented on May 29, 2013

    @pnkfelix
    Contributor

    This is blocked by Issue #5836

  7. huonw commented on Aug 14, 2013

    @huonw
    Contributor

    Triage visit: #5836 is closed, @michaelwoerister has done amazing work, and this is fixed!

    fn main() {
        struct moo {a: float};
        let x = [moo{a: 1.5}, moo{a: 2.3}];
        printfln!("%?", x);
    }
    $ rustc -Z debug-info -Z extra-debug-info 1340.rs
    
    (gdb) break 4
    [...]
    (gdb) r
    [...]
    (gdb) p x
    $1 = {{a = 1.5}, {a = 2.2999999999999998}}
    
  8. removed their assignment
    on Jun 16, 2014
  9. added a commit that references this issue on Jan 24, 2023
  10. added 3 commits that reference this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions