about summary refs log tree commit diff
path: root/src/test/debuginfo
diff options
context:
space:
mode:
authorEFanZh <efanzh@gmail.com>2021-07-03 23:42:07 +0800
committerEFanZh <efanzh@gmail.com>2021-07-03 23:42:07 +0800
commit0112b908f78960dc3485ca3de01a62861fc7311f (patch)
treead497fab372966c97d9d5638a9935c7ff4976573 /src/test/debuginfo
parenta8b8558f083d86247ef3260ebb4f97b276cdbf73 (diff)
downloadrust-0112b908f78960dc3485ca3de01a62861fc7311f.tar.gz
rust-0112b908f78960dc3485ca3de01a62861fc7311f.zip
Support pretty printing slices using GDB
Diffstat (limited to 'src/test/debuginfo')
-rw-r--r--src/test/debuginfo/pretty-huge-vec.rs2
-rw-r--r--src/test/debuginfo/pretty-slices.rs45
2 files changed, 46 insertions, 1 deletions
diff --git a/src/test/debuginfo/pretty-huge-vec.rs b/src/test/debuginfo/pretty-huge-vec.rs
index 67155b4e9f0..84f76ba4e6e 100644
--- a/src/test/debuginfo/pretty-huge-vec.rs
+++ b/src/test/debuginfo/pretty-huge-vec.rs
@@ -13,7 +13,7 @@
 // gdb-check:$1 = Vec(size=1000000000) = {[...]...}
 
 // gdb-command: print slice
-// gdb-check:$2 = &[u8] {data_ptr: [...], length: 1000000000}
+// gdb-check:$2 = &[u8](size=1000000000) = {[...]...}
 
 #![allow(unused_variables)]
 
diff --git a/src/test/debuginfo/pretty-slices.rs b/src/test/debuginfo/pretty-slices.rs
new file mode 100644
index 00000000000..4e17661dd36
--- /dev/null
+++ b/src/test/debuginfo/pretty-slices.rs
@@ -0,0 +1,45 @@
+// compile-flags:-g
+
+// gdb-command: run
+
+// gdb-command: print slice
+// gdbg-check: $1 = struct &[i32](size=3) = {0, 1, 2}
+// gdbr-check: $1 = &[i32](size=3) = {0, 1, 2}
+
+// gdb-command: print mut_slice
+// gdbg-check: $2 = struct &mut [i32](size=4) = {2, 3, 5, 7}
+// gdbr-check: $2 = &mut [i32](size=4) = {2, 3, 5, 7}
+
+// gdb-command: print str_slice
+// gdb-check: $3 = "string slice"
+
+// gdb-command: print mut_str_slice
+// gdb-check: $4 = "mutable string slice"
+
+// lldb-command: run
+
+// lldb-command: print slice
+// lldb-check: (&[i32]) $0 = size=3 { [0] = 0 [1] = 1 [2] = 2 }
+
+// lldb-command: print mut_slice
+// lldb-check: (&mut [i32]) $1 = size=4 { [0] = 2 [1] = 3 [2] = 5 [3] = 7 }
+
+// lldb-command: print str_slice
+// lldb-check: (&str) $2 = "string slice" { data_ptr = [...] length = 12 }
+
+// lldb-command: print mut_str_slice
+// lldb-check: (&mut str) $3 = "mutable string slice" { data_ptr = [...] length = 20 }
+
+fn b() {}
+
+fn main() {
+
+    let slice: &[i32] = &[0, 1, 2];
+    let mut_slice: &mut [i32] = &mut [2, 3, 5, 7];
+
+    let str_slice: &str = "string slice";
+    let mut mut_str_slice_buffer = String::from("mutable string slice");
+    let mut_str_slice: &mut str = mut_str_slice_buffer.as_mut_str();
+
+    b(); // #break
+}