diff options
author | Tom Tromey <tom@tromey.com> | 2022-03-25 13:36:53 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-04-15 10:34:03 -0600 |
commit | 506ec52e8805d8edd538d6bd11750489a8c8bbee (patch) | |
tree | 9201c10e67505609846c0a6f51ed98c033a3e3c6 /gdb/testsuite/gdb.rust | |
parent | 925ea601f1892c6eb344e2c916f0ef448b42b606 (diff) | |
download | gdb-506ec52e8805d8edd538d6bd11750489a8c8bbee.zip gdb-506ec52e8805d8edd538d6bd11750489a8c8bbee.tar.gz gdb-506ec52e8805d8edd538d6bd11750489a8c8bbee.tar.bz2 |
Reimplement Rust slice printing
The current nightly Rust compiler (aka 1.61) added better DWARF
representation for unsized types. Fixing this is PR rust/21466; but
the code is actually the same as what is required to make slice
printing more useful, which is PR rust/23871. This patch implements
this. I tested this against various Rust compilers: 1.48, current
stable, current beta, and current nightly.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=21466
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23871
Diffstat (limited to 'gdb/testsuite/gdb.rust')
-rw-r--r-- | gdb/testsuite/gdb.rust/simple.exp | 3 | ||||
-rw-r--r-- | gdb/testsuite/gdb.rust/unsized.exp | 8 | ||||
-rw-r--r-- | gdb/testsuite/gdb.rust/unsized.rs | 2 |
3 files changed, 12 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp index b6f2993..246aff6 100644 --- a/gdb/testsuite/gdb.rust/simple.exp +++ b/gdb/testsuite/gdb.rust/simple.exp @@ -314,7 +314,8 @@ proc test_one_slice {svar length base range} { with_test_prefix $range { global hex - set result " = &\\\[.*\\\] \\{data_ptr: $hex, length: $length\\}" + # Just accept any array here. + set result " = &\\\[.*\\\] \\\[.*\\\]" gdb_test "print $svar" $result gdb_test "print &${base}\[${range}\]" $result diff --git a/gdb/testsuite/gdb.rust/unsized.exp b/gdb/testsuite/gdb.rust/unsized.exp index 76d0bbb..67ee49d 100644 --- a/gdb/testsuite/gdb.rust/unsized.exp +++ b/gdb/testsuite/gdb.rust/unsized.exp @@ -32,3 +32,11 @@ if {![runto ${srcfile}:$line]} { } gdb_test "ptype us" " = .*V<\\\[u8\\\]>.*" + +set v [split [rust_compiler_version] .] +# The necessary debuginfo generation landed in 1.60, but had a bug +# that was fixed in 1.61. +if {[lindex $v 0] > 1 || [lindex $v 1] >= 61} { + gdb_test "print us2" " = .*Box<.*> \\\[1, 2, 3\\\]" + gdb_test "ptype us2" "type = .*" +} diff --git a/gdb/testsuite/gdb.rust/unsized.rs b/gdb/testsuite/gdb.rust/unsized.rs index f4897d6..af3192e 100644 --- a/gdb/testsuite/gdb.rust/unsized.rs +++ b/gdb/testsuite/gdb.rust/unsized.rs @@ -28,6 +28,8 @@ fn ignore<T>(x: T) { } fn main() { let v: Box<V<[u8; 3]>> = Box::new(V { data: [1, 2, 3] }); let us: Box<Unsized> = v; + let v2 : Box<[u8; 3]> = Box::new([1, 2, 3]); + let us2 : Box<[u8]> = v2; ignore(us); // set breakpoint here } |