about summary refs log tree commit diff
path: root/tests/debuginfo
diff options
context:
space:
mode:
authorVladimir Makayev <vmakaev@fb.com>2024-04-28 14:02:32 -0700
committerVladimir Makayev <vmakaev@fb.com>2024-05-11 12:11:55 -0700
commit330ce83a8d968bb9880d7fc45f2c4b6fa5cfb53f (patch)
treea1265641834bcc941fd5748f461b190156a35d27 /tests/debuginfo
parent100b123a0d12c888705d58a40431b640364ee320 (diff)
downloadrust-330ce83a8d968bb9880d7fc45f2c4b6fa5cfb53f.tar.gz
rust-330ce83a8d968bb9880d7fc45f2c4b6fa5cfb53f.zip
lldb-formatters: Use StdSliceSyntheticProvider for &str
Diffstat (limited to 'tests/debuginfo')
-rw-r--r--tests/debuginfo/empty-string.rs2
-rw-r--r--tests/debuginfo/pretty-slices.rs4
-rw-r--r--tests/debuginfo/strings-and-strs.rs63
3 files changed, 66 insertions, 3 deletions
diff --git a/tests/debuginfo/empty-string.rs b/tests/debuginfo/empty-string.rs
index 36240730e19..35b68ed91c0 100644
--- a/tests/debuginfo/empty-string.rs
+++ b/tests/debuginfo/empty-string.rs
@@ -23,7 +23,7 @@
 // lldb-check:[...] empty_string = "" { vec = size=0 }
 
 // lldb-command:fr v empty_str
-// lldb-check:[...] empty_str = "" { data_ptr = [...] length = 0 }
+// lldb-check:[...] empty_str = ""
 
 fn main() {
     let empty_string = String::new();
diff --git a/tests/debuginfo/pretty-slices.rs b/tests/debuginfo/pretty-slices.rs
index 5d2086fa478..9defa344be0 100644
--- a/tests/debuginfo/pretty-slices.rs
+++ b/tests/debuginfo/pretty-slices.rs
@@ -27,10 +27,10 @@
 // lldb-check:(&mut [i32]) mut_slice = size=4 { [0] = 2 [1] = 3 [2] = 5 [3] = 7 }
 
 // lldb-command:v str_slice
-// lldb-check:(&str) str_slice = "string slice" { data_ptr = [...] length = 12 }
+// lldb-check:(&str) str_slice = "string slice" { [0] = 's' [1] = 't' [2] = 'r' [3] = 'i' [4] = 'n' [5] = 'g' [6] = ' ' [7] = 's' [8] = 'l' [9] = 'i' [10] = 'c' [11] = 'e' }
 
 // lldb-command:v mut_str_slice
-// lldb-check:(&mut str) mut_str_slice = "mutable string slice" { data_ptr = [...] length = 20 }
+// lldb-check:(&mut str) mut_str_slice = "mutable string slice" { [0] = 'm' [1] = 'u' [2] = 't' [3] = 'a' [4] = 'b' [5] = 'l' [6] = 'e' [7] = ' ' [8] = 's' [9] = 't' [10] = 'r' [11] = 'i' [12] = 'n' [13] = 'g' [14] = ' ' [15] = 's' [16] = 'l' [17] = 'i' [18] = 'c' [19] = 'e' }
 
 fn b() {}
 
diff --git a/tests/debuginfo/strings-and-strs.rs b/tests/debuginfo/strings-and-strs.rs
new file mode 100644
index 00000000000..48d40d167ba
--- /dev/null
+++ b/tests/debuginfo/strings-and-strs.rs
@@ -0,0 +1,63 @@
+//@ min-gdb-version: 14.0
+//@ min-lldb-version: 1800
+
+//@ compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+// gdb-command:run
+
+// gdb-command:print plain_string
+// gdbr-check:$1 = alloc::string::String {vec: alloc::vec::Vec<u8, alloc::alloc::Global> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {ptr: core::ptr::unique::Unique<u8> {pointer: core::ptr::non_null::NonNull<u8> {pointer: 0x55555555ab80}, _marker: core::marker::PhantomData<u8>}, cap: alloc::raw_vec::Cap (5), alloc: alloc::alloc::Global}, len: 5}}
+
+// gdb-command:print plain_str
+// gdbr-check:$2 = "Hello"
+
+// gdb-command:print str_in_struct
+// gdbr-check:$3 = strings_and_strs::Foo {inner: "Hello"}
+
+// gdb-command:print str_in_tuple
+// gdbr-check:$4 = ("Hello", "World")
+
+// gdb-command:print str_in_rc
+// gdbr-check:$5 = alloc::rc::Rc<&str, alloc::alloc::Global> {ptr: core::ptr::non_null::NonNull<alloc::rc::RcBox<&str>> {pointer: 0x55555555aae0}, phantom: core::marker::PhantomData<alloc::rc::RcBox<&str>>, alloc: alloc::alloc::Global}
+
+
+// === LLDB TESTS ==================================================================================
+// lldb-command:run
+// lldb-command:v plain_string
+// lldbg-check:(alloc::string::String) plain_string = "Hello" { vec = size=5 { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } }
+
+// lldb-command:v plain_str
+// lldbg-check:(&str) plain_str = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' }
+
+// lldb-command:v str_in_struct
+// lldbg-check:((&str, &str)) str_in_tuple = { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } }
+
+// lldb-command:v str_in_tuple
+// lldbg-check:((&str, &str)) str_in_tuple = { 0 = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } 1 = "World" { [0] = 'W' [1] = 'o' [2] = 'r' [3] = 'l' [4] = 'd' } }
+
+// lldb-command:v str_in_rc
+// lldbg-check:(alloc::rc::Rc<&str, alloc::alloc::Global>) str_in_rc = strong=1, weak=0 { value = "Hello" { [0] = 'H' [1] = 'e' [2] = 'l' [3] = 'l' [4] = 'o' } }
+
+
+#![allow(unused_variables)]
+#![feature(omit_gdb_pretty_printer_section)]
+#![omit_gdb_pretty_printer_section]
+
+pub struct Foo<'a> {
+    inner: &'a str,
+}
+
+fn main() {
+    let plain_string = String::from("Hello");
+    let plain_str = "Hello";
+    let str_in_struct = Foo { inner: "Hello" };
+    let str_in_tuple = ("Hello", "World");
+
+    let str_in_rc = std::rc::Rc::new("Hello");
+    zzz(); // #break
+}
+
+fn zzz() {
+    ()
+}