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