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