]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/basic-types.rs
Rollup merge of #106638 - RalfJung:realstd, r=thomcc
[rust.git] / tests / debuginfo / basic-types.rs
1 // Caveats - gdb prints any 8-bit value (meaning rust i8 and u8 values)
2 // as its numerical value along with its associated ASCII char, there
3 // doesn't seem to be any way around this. Also, gdb doesn't know
4 // about UTF-32 character encoding and will print a rust char as only
5 // its numerical value.
6
7 // min-lldb-version: 310
8
9 // This fails on lldb 6.0.1 on x86-64 Fedora 28; so ignore Linux for now.
10 // ignore-linux
11
12 // compile-flags:-g
13
14 // === GDB TESTS ===================================================================================
15
16 // gdb-command:run
17 // gdb-command:print b
18 // gdb-check:$1 = false
19 // gdb-command:print i
20 // gdb-check:$2 = -1
21 // gdb-command:print c
22 // gdbg-check:$3 = 97
23 // gdbr-check:$3 = 97 'a'
24 // gdb-command:print/d i8
25 // gdb-check:$4 = 68
26 // gdb-command:print i16
27 // gdb-check:$5 = -16
28 // gdb-command:print i32
29 // gdb-check:$6 = -32
30 // gdb-command:print i64
31 // gdb-check:$7 = -64
32 // gdb-command:print u
33 // gdb-check:$8 = 1
34 // gdb-command:print/d u8
35 // gdb-check:$9 = 100
36 // gdb-command:print u16
37 // gdb-check:$10 = 16
38 // gdb-command:print u32
39 // gdb-check:$11 = 32
40 // gdb-command:print u64
41 // gdb-check:$12 = 64
42 // gdb-command:print f32
43 // gdb-check:$13 = 2.5
44 // gdb-command:print f64
45 // gdb-check:$14 = 3.5
46 // gdb-command:print s
47 // gdbg-check:$15 = {data_ptr = [...] "Hello, World!", length = 13}
48 // gdbr-check:$15 = "Hello, World!"
49
50 // === LLDB TESTS ==================================================================================
51
52 // lldb-command:run
53 // lldb-command:print b
54 // lldbg-check:[...]$0 = false
55 // lldbr-check:(bool) b = false
56 // lldb-command:print i
57 // lldbg-check:[...]$1 = -1
58 // lldbr-check:(isize) i = -1
59
60 // NOTE: only rust-enabled lldb supports 32bit chars
61 // lldbr-command:print c
62 // lldbr-check:(char) c = 'a'
63
64 // lldb-command:print i8
65 // lldbg-check:[...]$2 = 'D'
66 // lldbr-check:(i8) i8 = 68
67 // lldb-command:print i16
68 // lldbg-check:[...]$3 = -16
69 // lldbr-check:(i16) i16 = -16
70 // lldb-command:print i32
71 // lldbg-check:[...]$4 = -32
72 // lldbr-check:(i32) i32 = -32
73 // lldb-command:print i64
74 // lldbg-check:[...]$5 = -64
75 // lldbr-check:(i64) i64 = -64
76 // lldb-command:print u
77 // lldbg-check:[...]$6 = 1
78 // lldbr-check:(usize) u = 1
79 // lldb-command:print u8
80 // lldbg-check:[...]$7 = 'd'
81 // lldbr-check:(u8) u8 = 100
82 // lldb-command:print u16
83 // lldbg-check:[...]$8 = 16
84 // lldbr-check:(u16) u16 = 16
85 // lldb-command:print u32
86 // lldbg-check:[...]$9 = 32
87 // lldbr-check:(u32) u32 = 32
88 // lldb-command:print u64
89 // lldbg-check:[...]$10 = 64
90 // lldbr-check:(u64) u64 = 64
91 // lldb-command:print f32
92 // lldbg-check:[...]$11 = 2.5
93 // lldbr-check:(f32) f32 = 2.5
94 // lldb-command:print f64
95 // lldbg-check:[...]$12 = 3.5
96 // lldbr-check:(f64) f64 = 3.5
97
98 // === CDB TESTS ===================================================================================
99
100 // cdb-command:g
101 // cdb-command:dx b
102 // cdb-check:b                : false [Type: bool]
103 // cdb-command:dx i
104 // cdb-check:i                : -1 [Type: [...]]
105 // cdb-command:dx c
106 // cdb-check:c                : 0x61 'a' [Type: char32_t]
107 // cdb-command:dx i8
108 // cdb-check:i8               : 68 [Type: char]
109 // cdb-command:dx i16
110 // cdb-check:i16              : -16 [Type: short]
111 // cdb-command:dx i32
112 // cdb-check:i32              : -32 [Type: int]
113 // cdb-command:dx i64
114 // cdb-check:i64              : -64 [Type: __int64]
115 // cdb-command:dx u
116 // cdb-check:u                : 0x1 [Type: [...]]
117 // cdb-command:dx u8
118 // cdb-check:u8               : 0x64 [Type: unsigned char]
119 // cdb-command:dx u16
120 // cdb-check:u16              : 0x10 [Type: unsigned short]
121 // cdb-command:dx u32
122 // cdb-check:u32              : 0x20 [Type: unsigned int]
123 // cdb-command:dx u64
124 // cdb-check:u64              : 0x40 [Type: unsigned __int64]
125 // cdb-command:dx f32
126 // cdb-check:f32              : 2.500000 [Type: float]
127 // cdb-command:dx f64
128 // cdb-check:f64              : 3.500000 [Type: double]
129 // cdb-command:.enable_unicode 1
130 // FIXME(#88840): The latest version of the Windows SDK broke the visualizer for str.
131 // cdb-command:dx  s
132 // cdb-check:s                : [...] [Type: ref$<str$>]
133
134 #![allow(unused_variables)]
135 #![feature(omit_gdb_pretty_printer_section)]
136 #![omit_gdb_pretty_printer_section]
137
138 fn main() {
139     let b: bool = false;
140     let i: isize = -1;
141     let c: char = 'a';
142     let i8: i8 = 68;
143     let i16: i16 = -16;
144     let i32: i32 = -32;
145     let i64: i64 = -64;
146     let u: usize = 1;
147     let u8: u8 = 100;
148     let u16: u16 = 16;
149     let u32: u32 = 32;
150     let u64: u64 = 64;
151     let f32: f32 = 2.5;
152     let f64: f64 = 3.5;
153     let s: &str = "Hello, World!";
154     _zzz(); // #break
155 }
156
157 fn _zzz() {
158     ()
159 }