[Bug rust/23871] New: better support for slices

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Bug rust/23871] New: better support for slices

albert.aribaud at 3adev dot fr
https://sourceware.org/bugzilla/show_bug.cgi?id=23871

            Bug ID: 23871
           Summary: better support for slices
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: rust
          Assignee: unassigned at sourceware dot org
          Reporter: tromey at sourceware dot org
  Target Milestone: ---

Compile & debug this program:

pub fn main() {
    let x = &[1, 2, 3, 4, 5];
    let y = &x[..];
    let z = 7;
}


First, 'x' is not recognized as a slice:

(gdb) p x
$1 = (i32 (*)[5]) 0x555555577b40

The DWARF says it is a pointer to an array:

 <1><30d>: Abbrev Number: 6 (DW_TAG_pointer_type)
    <30e>   DW_AT_type        : <0x316>
    <312>   DW_AT_name        : (indirect string, offset: 0x2bd): &[i32; 5]
 <1><316>: Abbrev Number: 7 (DW_TAG_array_type)
    <317>   DW_AT_type        : <0x323>
 <2><31b>: Abbrev Number: 8 (DW_TAG_subrange_type)
    <31c>   DW_AT_type        : <0x32a>
    <320>   DW_AT_lower_bound : 0
    <321>   DW_AT_count       : 5
 <2><322>: Abbrev Number: 0


... maybe this should be fixed in rustc, but maybe in gdb.


Second, rust-gdb's pretty-printer shows this for 'y':

(gdb) p y
$2 = &[i32](len: 5) = {1, 2, 3, 4, 5}


But gdb shows:

(gdb) p/r y
$3 = &[i32] {
  data_ptr: 0x555555577b40,
  length: 5
}


It might make sense to have the built-in printer work
more like rust-gdb's.

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