]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/function-arg-initialization.rs
Auto merge of #72696 - jethrogb:jb/llvm-zlib, r=Mark-Simulacrum
[rust.git] / src / test / debuginfo / function-arg-initialization.rs
1 // ignore-tidy-linelength
2 // ignore-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
3 // min-lldb-version: 310
4
5 // This test case checks if function arguments already have the correct value
6 // when breaking at the first line of the function, that is if the function
7 // prologue has already been executed at the first line. Note that because of
8 // the __morestack part of the prologue GDB incorrectly breaks at before the
9 // arguments have been properly loaded when setting the breakpoint via the
10 // function name.
11
12 // compile-flags:-g
13
14 // === GDB TESTS ===================================================================================
15
16 // gdb-command:run
17
18 // IMMEDIATE ARGS
19 // gdb-command:print a
20 // gdb-check:$1 = 1
21 // gdb-command:print b
22 // gdb-check:$2 = true
23 // gdb-command:print c
24 // gdb-check:$3 = 2.5
25 // gdb-command:continue
26
27 // NON IMMEDIATE ARGS
28 // gdb-command:print a
29 // gdbg-check:$4 = {a = 3, b = 4, c = 5, d = 6, e = 7, f = 8, g = 9, h = 10}
30 // gdbt-check:$4 = function_arg_initialization::BigStruct {a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10}
31 // gdb-command:print b
32 // gdbg-check:$5 = {a = 11, b = 12, c = 13, d = 14, e = 15, f = 16, g = 17, h = 18}
33 // gdbt-check:$5 = function_arg_initialization::BigStruct {a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18}
34 // gdb-command:continue
35
36 // BINDING
37 // gdb-command:print a
38 // gdb-check:$6 = 19
39 // gdb-command:print b
40 // gdb-check:$7 = 20
41 // gdb-command:print c
42 // gdb-check:$8 = 21.5
43 // gdb-command:continue
44
45 // ASSIGNMENT
46 // gdb-command:print a
47 // gdb-check:$9 = 22
48 // gdb-command:print b
49 // gdb-check:$10 = 23
50 // gdb-command:print c
51 // gdb-check:$11 = 24.5
52 // gdb-command:continue
53
54 // FUNCTION CALL
55 // gdb-command:print x
56 // gdb-check:$12 = 25
57 // gdb-command:print y
58 // gdb-check:$13 = 26
59 // gdb-command:print z
60 // gdb-check:$14 = 27.5
61 // gdb-command:continue
62
63 // EXPR
64 // gdb-command:print x
65 // gdb-check:$15 = 28
66 // gdb-command:print y
67 // gdb-check:$16 = 29
68 // gdb-command:print z
69 // gdb-check:$17 = 30.5
70 // gdb-command:continue
71
72 // RETURN EXPR
73 // gdb-command:print x
74 // gdb-check:$18 = 31
75 // gdb-command:print y
76 // gdb-check:$19 = 32
77 // gdb-command:print z
78 // gdb-check:$20 = 33.5
79 // gdb-command:continue
80
81 // ARITHMETIC EXPR
82 // gdb-command:print x
83 // gdb-check:$21 = 34
84 // gdb-command:print y
85 // gdb-check:$22 = 35
86 // gdb-command:print z
87 // gdb-check:$23 = 36.5
88 // gdb-command:continue
89
90 // IF EXPR
91 // gdb-command:print x
92 // gdb-check:$24 = 37
93 // gdb-command:print y
94 // gdb-check:$25 = 38
95 // gdb-command:print z
96 // gdb-check:$26 = 39.5
97 // gdb-command:continue
98
99 // WHILE EXPR
100 // gdb-command:print x
101 // gdb-check:$27 = 40
102 // gdb-command:print y
103 // gdb-check:$28 = 41
104 // gdb-command:print z
105 // gdb-check:$29 = 42
106 // gdb-command:continue
107
108 // LOOP EXPR
109 // gdb-command:print x
110 // gdb-check:$30 = 43
111 // gdb-command:print y
112 // gdb-check:$31 = 44
113 // gdb-command:print z
114 // gdb-check:$32 = 45
115 // gdb-command:continue
116
117
118 // === LLDB TESTS ==================================================================================
119
120 // lldb-command:run
121
122 // IMMEDIATE ARGS
123 // lldb-command:print a
124 // lldb-check:[...]$0 = 1
125 // lldb-command:print b
126 // lldb-check:[...]$1 = true
127 // lldb-command:print c
128 // lldb-check:[...]$2 = 2.5
129 // lldb-command:continue
130
131 // NON IMMEDIATE ARGS
132 // lldb-command:print a
133 // lldb-check:[...]$3 = BigStruct { a: 3, b: 4, c: 5, d: 6, e: 7, f: 8, g: 9, h: 10 }
134 // lldb-command:print b
135 // lldb-check:[...]$4 = BigStruct { a: 11, b: 12, c: 13, d: 14, e: 15, f: 16, g: 17, h: 18 }
136 // lldb-command:continue
137
138 // BINDING
139 // lldb-command:print a
140 // lldb-check:[...]$5 = 19
141 // lldb-command:print b
142 // lldb-check:[...]$6 = 20
143 // lldb-command:print c
144 // lldb-check:[...]$7 = 21.5
145 // lldb-command:continue
146
147 // ASSIGNMENT
148 // lldb-command:print a
149 // lldb-check:[...]$8 = 22
150 // lldb-command:print b
151 // lldb-check:[...]$9 = 23
152 // lldb-command:print c
153 // lldb-check:[...]$10 = 24.5
154 // lldb-command:continue
155
156 // FUNCTION CALL
157 // lldb-command:print x
158 // lldb-check:[...]$11 = 25
159 // lldb-command:print y
160 // lldb-check:[...]$12 = 26
161 // lldb-command:print z
162 // lldb-check:[...]$13 = 27.5
163 // lldb-command:continue
164
165 // EXPR
166 // lldb-command:print x
167 // lldb-check:[...]$14 = 28
168 // lldb-command:print y
169 // lldb-check:[...]$15 = 29
170 // lldb-command:print z
171 // lldb-check:[...]$16 = 30.5
172 // lldb-command:continue
173
174 // RETURN EXPR
175 // lldb-command:print x
176 // lldb-check:[...]$17 = 31
177 // lldb-command:print y
178 // lldb-check:[...]$18 = 32
179 // lldb-command:print z
180 // lldb-check:[...]$19 = 33.5
181 // lldb-command:continue
182
183 // ARITHMETIC EXPR
184 // lldb-command:print x
185 // lldb-check:[...]$20 = 34
186 // lldb-command:print y
187 // lldb-check:[...]$21 = 35
188 // lldb-command:print z
189 // lldb-check:[...]$22 = 36.5
190 // lldb-command:continue
191
192 // IF EXPR
193 // lldb-command:print x
194 // lldb-check:[...]$23 = 37
195 // lldb-command:print y
196 // lldb-check:[...]$24 = 38
197 // lldb-command:print z
198 // lldb-check:[...]$25 = 39.5
199 // lldb-command:continue
200
201 // WHILE EXPR
202 // lldb-command:print x
203 // lldb-check:[...]$26 = 40
204 // lldb-command:print y
205 // lldb-check:[...]$27 = 41
206 // lldb-command:print z
207 // lldb-check:[...]$28 = 42
208 // lldb-command:continue
209
210 // LOOP EXPR
211 // lldb-command:print x
212 // lldb-check:[...]$29 = 43
213 // lldb-command:print y
214 // lldb-check:[...]$30 = 44
215 // lldb-command:print z
216 // lldb-check:[...]$31 = 45
217 // lldb-command:continue
218
219
220 #![allow(unused_variables)]
221 #![feature(omit_gdb_pretty_printer_section)]
222 #![omit_gdb_pretty_printer_section]
223
224 fn immediate_args(a: isize, b: bool, c: f64) {
225     zzz(); // #break
226 }
227
228 struct BigStruct {
229     a: u64,
230     b: u64,
231     c: u64,
232     d: u64,
233     e: u64,
234     f: u64,
235     g: u64,
236     h: u64
237 }
238
239 fn non_immediate_args(a: BigStruct, b: BigStruct) {
240     zzz(); // #break
241 }
242
243 fn binding(a: i64, b: u64, c: f64) {
244     let x = 0; // #break
245     println!()
246 }
247
248 fn assignment(mut a: u64, b: u64, c: f64) {
249     a = b; // #break
250     println!()
251 }
252
253 fn function_call(x: u64, y: u64, z: f64) {
254     zzz(); // #break
255 }
256
257 fn identifier(x: u64, y: u64, z: f64) -> u64 {
258     x // #break
259 }
260
261 fn return_expr(x: u64, y: u64, z: f64) -> u64 {
262     return x; // #break
263 }
264
265 fn arithmetic_expr(x: u64, y: u64, z: f64) -> u64 {
266     x + y // #break
267 }
268
269 fn if_expr(x: u64, y: u64, z: f64) -> u64 {
270     if x + y < 1000 { // #break
271         x
272     } else {
273         y
274     }
275 }
276
277 fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
278     while x + y > 1000 { // #break
279         x += z
280     }
281     return x;
282 }
283
284 fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
285     loop {
286         x += z; // #break
287
288         if x + y > 1000 {
289             return x;
290         }
291     }
292 }
293
294 fn main() {
295     immediate_args(1, true, 2.5);
296
297     non_immediate_args(
298         BigStruct {
299             a: 3,
300             b: 4,
301             c: 5,
302             d: 6,
303             e: 7,
304             f: 8,
305             g: 9,
306             h: 10
307         },
308         BigStruct {
309             a: 11,
310             b: 12,
311             c: 13,
312             d: 14,
313             e: 15,
314             f: 16,
315             g: 17,
316             h: 18
317         }
318     );
319
320     binding(19, 20, 21.5);
321     assignment(22, 23, 24.5);
322     function_call(25, 26, 27.5);
323     identifier(28, 29, 30.5);
324     return_expr(31, 32, 33.5);
325     arithmetic_expr(34, 35, 36.5);
326     if_expr(37, 38, 39.5);
327     while_expr(40, 41, 42);
328     loop_expr(43, 44, 45);
329 }
330
331 fn zzz() {()}