]> git.lizzy.rs Git - rust.git/blob - src/test/debug-info/function-prologue-stepping-no-split-stack.rs
enable fp-elim when debug info is disabled
[rust.git] / src / test / debug-info / function-prologue-stepping-no-split-stack.rs
1 // Copyright 2013 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 // xfail-android: FIXME(#10381)
12
13 // This test case checks if function arguments already have the correct value when breaking at the
14 // beginning of a function. Functions with the #[no_split_stack] attribute have the same prologue as
15 // regular C functions compiled with GCC or Clang and therefore are better handled by GDB. As a
16 // consequence, and as opposed to regular Rust functions, we can set the breakpoints via the
17 // function name (and don't have to fall back on using line numbers).
18
19 // compile-flags:-Z extra-debug-info
20 // debugger:set print pretty off
21 // debugger:rbreak immediate_args
22 // debugger:rbreak binding
23 // debugger:rbreak assignment
24 // debugger:rbreak function_call
25 // debugger:rbreak identifier
26 // debugger:rbreak return_expr
27 // debugger:rbreak arithmetic_expr
28 // debugger:rbreak if_expr
29 // debugger:rbreak while_expr
30 // debugger:rbreak loop_expr
31 // debugger:run
32
33 // IMMEDIATE ARGS
34 // debugger:print a
35 // check:$1 = 1
36 // debugger:print b
37 // check:$2 = true
38 // debugger:print c
39 // check:$3 = 2.5
40 // debugger:continue
41
42 // NON IMMEDIATE ARGS
43 // debugger:print a
44 // check:$4 = {a = 3, b = 4, c = 5, d = 6, e = 7, f = 8, g = 9, h = 10}
45 // debugger:print b
46 // check:$5 = {a = 11, b = 12, c = 13, d = 14, e = 15, f = 16, g = 17, h = 18}
47 // debugger:continue
48
49 // BINDING
50 // debugger:print a
51 // check:$6 = 19
52 // debugger:print b
53 // check:$7 = 20
54 // debugger:print c
55 // check:$8 = 21.5
56 // debugger:continue
57
58 // ASSIGNMENT
59 // debugger:print a
60 // check:$9 = 22
61 // debugger:print b
62 // check:$10 = 23
63 // debugger:print c
64 // check:$11 = 24.5
65 // debugger:continue
66
67 // FUNCTION CALL
68 // debugger:print x
69 // check:$12 = 25
70 // debugger:print y
71 // check:$13 = 26
72 // debugger:print z
73 // check:$14 = 27.5
74 // debugger:continue
75
76 // EXPR
77 // debugger:print x
78 // check:$15 = 28
79 // debugger:print y
80 // check:$16 = 29
81 // debugger:print z
82 // check:$17 = 30.5
83 // debugger:continue
84
85 // RETURN EXPR
86 // debugger:print x
87 // check:$18 = 31
88 // debugger:print y
89 // check:$19 = 32
90 // debugger:print z
91 // check:$20 = 33.5
92 // debugger:continue
93
94 // ARITHMETIC EXPR
95 // debugger:print x
96 // check:$21 = 34
97 // debugger:print y
98 // check:$22 = 35
99 // debugger:print z
100 // check:$23 = 36.5
101 // debugger:continue
102
103 // IF EXPR
104 // debugger:print x
105 // check:$24 = 37
106 // debugger:print y
107 // check:$25 = 38
108 // debugger:print z
109 // check:$26 = 39.5
110 // debugger:continue
111
112 // WHILE EXPR
113 // debugger:print x
114 // check:$27 = 40
115 // debugger:print y
116 // check:$28 = 41
117 // debugger:print z
118 // check:$29 = 42
119 // debugger:continue
120
121 // LOOP EXPR
122 // debugger:print x
123 // check:$30 = 43
124 // debugger:print y
125 // check:$31 = 44
126 // debugger:print z
127 // check:$32 = 45
128 // debugger:continue
129
130 #[allow(unused_variable)];
131
132 #[no_split_stack]
133 fn immediate_args(a: int, b: bool, c: f64) {
134     ()
135 }
136
137 struct BigStruct {
138     a: u64,
139     b: u64,
140     c: u64,
141     d: u64,
142     e: u64,
143     f: u64,
144     g: u64,
145     h: u64
146 }
147
148 #[no_split_stack]
149 fn non_immediate_args(a: BigStruct, b: BigStruct) {
150     ()
151 }
152
153 #[no_split_stack]
154 fn binding(a: i64, b: u64, c: f64) {
155     let x = 0;
156 }
157
158 #[no_split_stack]
159 fn assignment(mut a: u64, b: u64, c: f64) {
160     a = b;
161 }
162
163 #[no_split_stack]
164 fn function_call(x: u64, y: u64, z: f64) {
165     std::io::stdio::print("Hi!")
166 }
167
168 #[no_split_stack]
169 fn identifier(x: u64, y: u64, z: f64) -> u64 {
170     x
171 }
172
173 #[no_split_stack]
174 fn return_expr(x: u64, y: u64, z: f64) -> u64 {
175     return x;
176 }
177
178 #[no_split_stack]
179 fn arithmetic_expr(x: u64, y: u64, z: f64) -> u64 {
180     x + y
181 }
182
183 #[no_split_stack]
184 fn if_expr(x: u64, y: u64, z: f64) -> u64 {
185     if x + y < 1000 {
186         x
187     } else {
188         y
189     }
190 }
191
192 #[no_split_stack]
193 fn while_expr(mut x: u64, y: u64, z: u64) -> u64 {
194     while x + y < 1000 {
195         x += z
196     }
197     return x;
198 }
199
200 #[no_split_stack]
201 fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 {
202     loop {
203         x += z;
204
205         if x + y > 1000 {
206             return x;
207         }
208     }
209 }
210
211 fn main() {
212     immediate_args(1, true, 2.5);
213
214     non_immediate_args(
215         BigStruct {
216             a: 3,
217             b: 4,
218             c: 5,
219             d: 6,
220             e: 7,
221             f: 8,
222             g: 9,
223             h: 10
224         },
225         BigStruct {
226             a: 11,
227             b: 12,
228             c: 13,
229             d: 14,
230             e: 15,
231             f: 16,
232             g: 17,
233             h: 18
234         }
235     );
236
237     binding(19, 20, 21.5);
238     assignment(22, 23, 24.5);
239     function_call(25, 26, 27.5);
240     identifier(28, 29, 30.5);
241     return_expr(31, 32, 33.5);
242     arithmetic_expr(34, 35, 36.5);
243     if_expr(37, 38, 39.5);
244     while_expr(40, 41, 42);
245     loop_expr(43, 44, 45);
246 }