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