]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/pretty-std.rs
Remove astconv usage in diagnostic
[rust.git] / tests / debuginfo / pretty-std.rs
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)
4 // compile-flags:-g
5 // min-gdb-version: 7.7
6 // min-lldb-version: 310
7 // min-cdb-version: 10.0.18317.1001
8
9 // === GDB TESTS ===================================================================================
10
11 // gdb-command: run
12
13 // gdb-command: print slice
14 // gdb-check:$1 = &[i32](len: 4) = {0, 1, 2, 3}
15
16 // gdb-command: print vec
17 // gdb-check:$2 = Vec<u64, alloc::alloc::Global>(len: 4, cap: [...]) = {4, 5, 6, 7}
18
19 // gdb-command: print str_slice
20 // gdb-check:$3 = "IAMA string slice!"
21
22 // gdb-command: print string
23 // gdb-check:$4 = "IAMA string!"
24
25 // gdb-command: print some
26 // gdb-check:$5 = Some = {8}
27
28 // gdb-command: print none
29 // gdbg-check:$6 = None
30 // gdbr-check:$6 = core::option::Option::None
31
32 // gdb-command: print os_string
33 // gdb-check:$7 = "IAMA OS string ðŸ˜ƒ"
34
35 // gdb-command: print some_string
36 // gdb-check:$8 = Some = {"IAMA optional string!"}
37
38 // gdb-command: set print length 5
39 // gdb-command: print some_string
40 // gdb-check:$8 = Some = {"IAMA "...}
41
42 // === LLDB TESTS ==================================================================================
43
44 // lldb-command: run
45
46 // lldb-command: print slice
47 // lldb-check:[...]$0 = &[0, 1, 2, 3]
48
49 // lldb-command: print vec
50 // lldb-check:[...]$1 = vec![4, 5, 6, 7]
51
52 // lldb-command: print str_slice
53 // lldb-check:[...]$2 = "IAMA string slice!"
54
55 // lldb-command: print string
56 // lldb-check:[...]$3 = "IAMA string!"
57
58 // lldb-command: print some
59 // lldb-check:[...]$4 = Some(8)
60
61 // lldb-command: print none
62 // lldb-check:[...]$5 = None
63
64 // lldb-command: print os_string
65 // lldb-check:[...]$6 = "IAMA OS string ðŸ˜ƒ"[...]
66
67 // === CDB TESTS ==================================================================================
68
69 // cdb-command: g
70
71 // cdb-command: dx slice,d
72 // cdb-check:slice,d          : { len=4 } [Type: ref$<slice2$<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]
78
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]
87
88 // cdb-command: dx str_slice
89 // cdb-check:str_slice        : "IAMA string slice!" [Type: ref$<str$>]
90
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: [...]]
96
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]
110
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 [...]"
117
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]
122
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> >]
126
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]
131
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]
137
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 [Type: unsigned [...]]
142 // cdb-check:    [capacity]       : 0x8 [Type: unsigned [...]]
143 // cdb-check:    [0x0]            : 90 [Type: int]
144 // cdb-check:    [0x1]            : 20 [Type: int]
145
146 #![allow(unused_variables)]
147 use std::collections::{LinkedList, VecDeque};
148 use std::ffi::OsString;
149
150 fn main() {
151     // &[]
152     let slice: &[i32] = &[0, 1, 2, 3];
153
154     // Vec
155     let vec = vec![4u64, 5, 6, 7];
156
157     // &str
158     let str_slice = "IAMA string slice!";
159
160     // String
161     let string = "IAMA string!".to_string();
162
163     // OsString
164     let os_string = OsString::from("IAMA OS string \u{1F603}");
165
166     // Option
167     let some = Some(8i16);
168     let none: Option<i64> = None;
169
170     let some_string = Some("IAMA optional string!".to_owned());
171
172     // LinkedList
173     let mut linkedlist = LinkedList::new();
174     linkedlist.push_back(42);
175     linkedlist.push_front(128);
176
177     // VecDeque
178     let mut vecdeque = VecDeque::with_capacity(8);
179     vecdeque.push_back(20);
180     vecdeque.push_front(90);
181
182     zzz(); // #break
183 }
184
185 fn zzz() {
186     ()
187 }