1 // ignore-freebsd: gdb package too new
2 // only-cdb // "Temporarily" ignored on GDB/LLDB due to debuginfo tests being disabled, see PR 47155
3 // ignore-android: FIXME(#10381)
5 // min-gdb-version: 7.7
6 // min-lldb-version: 310
7 // min-cdb-version: 10.0.18317.1001
9 // === GDB TESTS ===================================================================================
13 // gdb-command: print slice
14 // gdb-check:$1 = &[i32](len: 4) = {0, 1, 2, 3}
16 // gdb-command: print vec
17 // gdb-check:$2 = Vec<u64, alloc::alloc::Global>(len: 4, cap: [...]) = {4, 5, 6, 7}
19 // gdb-command: print str_slice
20 // gdb-check:$3 = "IAMA string slice!"
22 // gdb-command: print string
23 // gdb-check:$4 = "IAMA string!"
25 // gdb-command: print some
26 // gdb-check:$5 = Some = {8}
28 // gdb-command: print none
29 // gdbg-check:$6 = None
30 // gdbr-check:$6 = core::option::Option::None
32 // gdb-command: print os_string
33 // gdb-check:$7 = "IAMA OS string 😃"
35 // gdb-command: print some_string
36 // gdb-check:$8 = Some = {"IAMA optional string!"}
38 // gdb-command: set print length 5
39 // gdb-command: print some_string
40 // gdb-check:$8 = Some = {"IAMA "...}
42 // === LLDB TESTS ==================================================================================
46 // lldb-command: print slice
47 // lldb-check:[...]$0 = &[0, 1, 2, 3]
49 // lldb-command: print vec
50 // lldb-check:[...]$1 = vec![4, 5, 6, 7]
52 // lldb-command: print str_slice
53 // lldb-check:[...]$2 = "IAMA string slice!"
55 // lldb-command: print string
56 // lldb-check:[...]$3 = "IAMA string!"
58 // lldb-command: print some
59 // lldb-check:[...]$4 = Some(8)
61 // lldb-command: print none
62 // lldb-check:[...]$5 = None
64 // lldb-command: print os_string
65 // lldb-check:[...]$6 = "IAMA OS string 😃"[...]
67 // === CDB TESTS ==================================================================================
71 // cdb-command: dx slice,d
72 // cdb-check:slice,d : { len=4 } [Type: slice$<i32>]
73 // cdb-check: [len] : 4 [Type: [...]]
74 // cdb-check: [0] : 0 [Type: int]
75 // cdb-check: [1] : 1 [Type: int]
76 // cdb-check: [2] : 2 [Type: int]
77 // cdb-check: [3] : 3 [Type: int]
79 // cdb-command: dx vec,d
80 // cdb-check:vec,d [...] : { len=4 } [Type: [...]::Vec<u64,alloc::alloc::Global>]
81 // cdb-check: [len] : 4 [Type: [...]]
82 // cdb-check: [capacity] : [...] [Type: [...]]
83 // cdb-check: [0] : 4 [Type: unsigned __int64]
84 // cdb-check: [1] : 5 [Type: unsigned __int64]
85 // cdb-check: [2] : 6 [Type: unsigned __int64]
86 // cdb-check: [3] : 7 [Type: unsigned __int64]
88 // cdb-command: dx str_slice
89 // cdb-check:str_slice : "IAMA string slice!" [Type: str]
91 // cdb-command: dx string
92 // cdb-check:string : "IAMA string!" [Type: [...]::String]
93 // cdb-check: [<Raw View>] [Type: [...]::String]
94 // cdb-check: [len] : 0xc [Type: [...]]
95 // cdb-check: [capacity] : 0xc [Type: [...]]
97 // cdb-command: dx -r2 string
98 // cdb-check: [0] : 73 'I' [Type: char]
99 // cdb-check: [1] : 65 'A' [Type: char]
100 // cdb-check: [2] : 77 'M' [Type: char]
101 // cdb-check: [3] : 65 'A' [Type: char]
102 // cdb-check: [4] : 32 ' ' [Type: char]
103 // cdb-check: [5] : 115 's' [Type: char]
104 // cdb-check: [6] : 116 't' [Type: char]
105 // cdb-check: [7] : 114 'r' [Type: char]
106 // cdb-check: [8] : 105 'i' [Type: char]
107 // cdb-check: [9] : 110 'n' [Type: char]
108 // cdb-check: [10] : 103 'g' [Type: char]
109 // cdb-check: [11] : 33 '!' [Type: char]
111 // cdb-command: dx os_string
112 // NOTE: OSString is WTF-8 encoded which Windows debuggers don't understand. Verify the UTF-8
113 // portion displays correctly.
114 // cdb-check:os_string : "IAMA OS string [...]" [Type: std::ffi::os_str::OsString]
115 // cdb-check: [<Raw View>] [Type: std::ffi::os_str::OsString]
116 // cdb-check: [chars] : "IAMA OS string [...]"
118 // cdb-command: dx some
119 // cdb-check:some : Some [Type: enum2$<core::option::Option<i16> >]
120 // cdb-check: [<Raw View>] [Type: enum2$<core::option::Option<i16> >]
121 // cdb-check: [+0x002] __0 : 8 [Type: short]
123 // cdb-command: dx none
124 // cdb-check:none : None [Type: enum2$<core::option::Option<i64> >]
125 // cdb-check: [<Raw View>] [Type: enum2$<core::option::Option<i64> >]
127 // cdb-command: dx some_string
128 // cdb-check:some_string : Some [Type: enum2$<core::option::Option<alloc::string::String> >]
129 // cdb-check: [<Raw View>] [Type: enum2$<core::option::Option<alloc::string::String> >]
130 // cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String]
132 // cdb-command: dx linkedlist
133 // cdb-check:linkedlist : { len=0x2 } [Type: alloc::collections::linked_list::LinkedList<i32>]
134 // cdb-check: [<Raw View>] [Type: alloc::collections::linked_list::LinkedList<i32>]
135 // cdb-check: [0x0] : 128 [Type: int]
136 // cdb-check: [0x1] : 42 [Type: int]
138 // cdb-command: dx vecdeque
139 // cdb-check:vecdeque : { len=0x2 } [Type: alloc::collections::vec_deque::VecDeque<i32,alloc::alloc::Global>]
140 // cdb-check: [<Raw View>] [Type: alloc::collections::vec_deque::VecDeque<i32,alloc::alloc::Global>]
141 // cdb-check: [len] : 0x2
142 // cdb-check: [capacity] : 0x8 [Type: unsigned [...]]
143 // cdb-check: [0x0] : 90 [Type: int]
144 // cdb-check: [0x1] : 20 [Type: int]
146 #![allow(unused_variables)]
147 use std::collections::{LinkedList, VecDeque};
148 use std::ffi::OsString;
152 let slice: &[i32] = &[0, 1, 2, 3];
155 let vec = vec![4u64, 5, 6, 7];
158 let str_slice = "IAMA string slice!";
161 let string = "IAMA string!".to_string();
164 let os_string = OsString::from("IAMA OS string \u{1F603}");
167 let some = Some(8i16);
168 let none: Option<i64> = None;
170 let some_string = Some("IAMA optional string!".to_owned());
173 let mut linkedlist = LinkedList::new();
174 linkedlist.push_back(42);
175 linkedlist.push_front(128);
178 let mut vecdeque = VecDeque::new();
179 vecdeque.push_back(20);
180 vecdeque.push_front(90);