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