This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rust/21466] New: better printing of unsized types


https://sourceware.org/bugzilla/show_bug.cgi?id=21466

            Bug ID: 21466
           Summary: better printing of unsized types
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: rust
          Assignee: unassigned at sourceware dot org
          Reporter: tromey at sourceware dot org
  Target Milestone: ---

I found this example on reddit
(https://www.reddit.com/r/rust/comments/60ywnb/initializing_a_dynamically_sized_type/)

struct Bar<T: ?Sized> {
    info: u32,
    data: T,
}

type Foo = Bar<[u8]>;

fn main() {
    let x: Box<Bar<[u8; 3]>> = Box::new(Bar { info: 0, data: [1, 2, 3] });
    let y: Box<Foo> = x;
}

I had to add "let z = y" to get debuginfo for "y".
Then running in gdb I get:

(gdb) p *y
$2 = us::Bar<[u8]> {
  info: 0,
  data: 0x7ffff6c1f014
}

... but that doesn't seem very friendly; in fact it seems odd that the
array's address is printed.

Also the ptype output is a bit off:

(gdb) ptype *y
type = struct us::Bar<[u8]> {
  info: u32,
  data: [u8; ],
}


It ought to print "data: [u8]" there.

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]