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

tromey at sourceware dot org sourceware-bugzilla@sourceware.org
Sun May 7 05:31:00 GMT 2017


            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

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.

More information about the Gdb-prs mailing list