]> git.proxmox.com Git - rustc.git/blame - src/test/debuginfo/function-arg-initialization.rs
Imported Upstream version 1.0.0~beta.3
[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)]
227#![omit_gdb_pretty_printer_section]
228
c34b1796 229fn immediate_args(a: isize, b: bool, c: f64) {
9346a6ac 230 println!("") // #break
1a4d82fc
JJ
231}
232
233struct BigStruct {
234 a: u64,
235 b: u64,
236 c: u64,
237 d: u64,
238 e: u64,
239 f: u64,
240 g: u64,
241 h: u64
242}
243
244fn non_immediate_args(a: BigStruct, b: BigStruct) {
9346a6ac 245 println!("") // #break
1a4d82fc
JJ
246}
247
248fn binding(a: i64, b: u64, c: f64) {
85aaf69f 249 let x = 0; // #break
9346a6ac 250 println!("")
1a4d82fc
JJ
251}
252
253fn assignment(mut a: u64, b: u64, c: f64) {
254 a = b; // #break
9346a6ac 255 println!("")
1a4d82fc
JJ
256}
257
258fn function_call(x: u64, y: u64, z: f64) {
9346a6ac 259 println!("Hi!") // #break
1a4d82fc
JJ
260}
261
262fn identifier(x: u64, y: u64, z: f64) -> u64 {
263 x // #break
264}
265
266fn return_expr(x: u64, y: u64, z: f64) -> u64 {
267 return x; // #break
268}
269
270fn arithmetic_expr(x: u64, y: u64, z: f64) -> u64 {
271 x + y // #break
272}
273
274fn if_expr(x: u64, y: u64, z: f64) -> u64 {
275 if x + y < 1000 { // #break
276 x
277 } else {
278 y
279 }
280}
281
282fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
283 while x + y > 1000 { // #break
284 x += z
285 }
286 return x;
287}
288
289fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
290 loop { // #break
291 x += z;
292
293 if x + y > 1000 {
294 return x;
295 }
296 }
297}
298
299fn main() {
300 immediate_args(1, true, 2.5);
301
302 non_immediate_args(
303 BigStruct {
304 a: 3,
305 b: 4,
306 c: 5,
307 d: 6,
308 e: 7,
309 f: 8,
310 g: 9,
311 h: 10
312 },
313 BigStruct {
314 a: 11,
315 b: 12,
316 c: 13,
317 d: 14,
318 e: 15,
319 f: 16,
320 g: 17,
321 h: 18
322 }
323 );
324
325 binding(19, 20, 21.5);
326 assignment(22, 23, 24.5);
327 function_call(25, 26, 27.5);
328 identifier(28, 29, 30.5);
329 return_expr(31, 32, 33.5);
330 arithmetic_expr(34, 35, 36.5);
331 if_expr(37, 38, 39.5);
332 while_expr(40, 41, 42);
333 loop_expr(43, 44, 45);
334}