|
| 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 | +// first line of the function, that is if the function prologue has already been executed at the |
| 15 | +// first line. Note that because of the __morestack part of the prologue GDB incorrectly breaks at |
| 16 | +// before the arguments have been properly loaded when setting the breakpoint via the function name. |
| 17 | +// Therefore the setup here sets them using line numbers (so be careful when changing this file). |
| 18 | + |
| 19 | +// compile-flags:-Z extra-debug-info |
| 20 | +// debugger:set print pretty off |
| 21 | +// debugger:break function-arg-initialization.rs:139 |
| 22 | +// debugger:break function-arg-initialization.rs:154 |
| 23 | +// debugger:break function-arg-initialization.rs:158 |
| 24 | +// debugger:break function-arg-initialization.rs:162 |
| 25 | +// debugger:break function-arg-initialization.rs:166 |
| 26 | +// debugger:break function-arg-initialization.rs:170 |
| 27 | +// debugger:break function-arg-initialization.rs:174 |
| 28 | +// debugger:break function-arg-initialization.rs:178 |
| 29 | +// debugger:break function-arg-initialization.rs:182 |
| 30 | +// debugger:break function-arg-initialization.rs:190 |
| 31 | +// debugger:break function-arg-initialization.rs:197 |
| 32 | + |
| 33 | + |
| 34 | +// debugger:run |
| 35 | + |
| 36 | +// IMMEDIATE ARGS |
| 37 | +// debugger:print a |
| 38 | +// check:$1 = 1 |
| 39 | +// debugger:print b |
| 40 | +// check:$2 = true |
| 41 | +// debugger:print c |
| 42 | +// check:$3 = 2.5 |
| 43 | +// debugger:continue |
| 44 | + |
| 45 | +// NON IMMEDIATE ARGS |
| 46 | +// debugger:print a |
| 47 | +// check:$4 = {a = 3, b = 4, c = 5, d = 6, e = 7, f = 8, g = 9, h = 10} |
| 48 | +// debugger:print b |
| 49 | +// check:$5 = {a = 11, b = 12, c = 13, d = 14, e = 15, f = 16, g = 17, h = 18} |
| 50 | +// debugger:continue |
| 51 | + |
| 52 | +// BINDING |
| 53 | +// debugger:print a |
| 54 | +// check:$6 = 19 |
| 55 | +// debugger:print b |
| 56 | +// check:$7 = 20 |
| 57 | +// debugger:print c |
| 58 | +// check:$8 = 21.5 |
| 59 | +// debugger:continue |
| 60 | + |
| 61 | +// ASSIGNMENT |
| 62 | +// debugger:print a |
| 63 | +// check:$9 = 22 |
| 64 | +// debugger:print b |
| 65 | +// check:$10 = 23 |
| 66 | +// debugger:print c |
| 67 | +// check:$11 = 24.5 |
| 68 | +// debugger:continue |
| 69 | + |
| 70 | +// FUNCTION CALL |
| 71 | +// debugger:print x |
| 72 | +// check:$12 = 25 |
| 73 | +// debugger:print y |
| 74 | +// check:$13 = 26 |
| 75 | +// debugger:print z |
| 76 | +// check:$14 = 27.5 |
| 77 | +// debugger:continue |
| 78 | + |
| 79 | +// EXPR |
| 80 | +// debugger:print x |
| 81 | +// check:$15 = 28 |
| 82 | +// debugger:print y |
| 83 | +// check:$16 = 29 |
| 84 | +// debugger:print z |
| 85 | +// check:$17 = 30.5 |
| 86 | +// debugger:continue |
| 87 | + |
| 88 | +// RETURN EXPR |
| 89 | +// debugger:print x |
| 90 | +// check:$18 = 31 |
| 91 | +// debugger:print y |
| 92 | +// check:$19 = 32 |
| 93 | +// debugger:print z |
| 94 | +// check:$20 = 33.5 |
| 95 | +// debugger:continue |
| 96 | + |
| 97 | +// ARITHMETIC EXPR |
| 98 | +// debugger:print x |
| 99 | +// check:$21 = 34 |
| 100 | +// debugger:print y |
| 101 | +// check:$22 = 35 |
| 102 | +// debugger:print z |
| 103 | +// check:$23 = 36.5 |
| 104 | +// debugger:continue |
| 105 | + |
| 106 | +// IF EXPR |
| 107 | +// debugger:print x |
| 108 | +// check:$24 = 37 |
| 109 | +// debugger:print y |
| 110 | +// check:$25 = 38 |
| 111 | +// debugger:print z |
| 112 | +// check:$26 = 39.5 |
| 113 | +// debugger:continue |
| 114 | + |
| 115 | +// WHILE EXPR |
| 116 | +// debugger:print x |
| 117 | +// check:$27 = 40 |
| 118 | +// debugger:print y |
| 119 | +// check:$28 = 41 |
| 120 | +// debugger:print z |
| 121 | +// check:$29 = 42 |
| 122 | +// debugger:continue |
| 123 | + |
| 124 | +// LOOP EXPR |
| 125 | +// debugger:print x |
| 126 | +// check:$30 = 43 |
| 127 | +// debugger:print y |
| 128 | +// check:$31 = 44 |
| 129 | +// debugger:print z |
| 130 | +// check:$32 = 45 |
| 131 | +// debugger:continue |
| 132 | + |
| 133 | +#[allow(unused_variable)]; |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | +fn immediate_args(a: int, b: bool, c: f64) { |
| 139 | + () |
| 140 | +} |
| 141 | + |
| 142 | +struct BigStruct { |
| 143 | + a: u64, |
| 144 | + b: u64, |
| 145 | + c: u64, |
| 146 | + d: u64, |
| 147 | + e: u64, |
| 148 | + f: u64, |
| 149 | + g: u64, |
| 150 | + h: u64 |
| 151 | +} |
| 152 | + |
| 153 | +fn non_immediate_args(a: BigStruct, b: BigStruct) { |
| 154 | + () |
| 155 | +} |
| 156 | + |
| 157 | +fn binding(a: i64, b: u64, c: f64) { |
| 158 | + let x = 0; |
| 159 | +} |
| 160 | + |
| 161 | +fn assignment(mut a: u64, b: u64, c: f64) { |
| 162 | + a = b; |
| 163 | +} |
| 164 | + |
| 165 | +fn function_call(x: u64, y: u64, z: f64) { |
| 166 | + print("Hi!") |
| 167 | +} |
| 168 | + |
| 169 | +fn identifier(x: u64, y: u64, z: f64) -> u64 { |
| 170 | + x |
| 171 | +} |
| 172 | + |
| 173 | +fn return_expr(x: u64, y: u64, z: f64) -> u64 { |
| 174 | + return x; |
| 175 | +} |
| 176 | + |
| 177 | +fn arithmetic_expr(x: u64, y: u64, z: f64) -> u64 { |
| 178 | + x + y |
| 179 | +} |
| 180 | + |
| 181 | +fn if_expr(x: u64, y: u64, z: f64) -> u64 { |
| 182 | + if x + y < 1000 { |
| 183 | + x |
| 184 | + } else { |
| 185 | + y |
| 186 | + } |
| 187 | +} |
| 188 | + |
| 189 | +fn while_expr(mut x: u64, y: u64, z: u64) -> u64 { |
| 190 | + while x + y < 1000 { |
| 191 | + x += z |
| 192 | + } |
| 193 | + return x; |
| 194 | +} |
| 195 | + |
| 196 | +fn loop_expr(mut x: u64, y: u64, z: u64) -> u64 { |
| 197 | + loop { |
| 198 | + x += z; |
| 199 | + |
| 200 | + if x + y > 1000 { |
| 201 | + return x; |
| 202 | + } |
| 203 | + } |
| 204 | +} |
| 205 | + |
| 206 | +fn main() { |
| 207 | + immediate_args(1, true, 2.5); |
| 208 | + |
| 209 | + non_immediate_args( |
| 210 | + BigStruct { |
| 211 | + a: 3, |
| 212 | + b: 4, |
| 213 | + c: 5, |
| 214 | + d: 6, |
| 215 | + e: 7, |
| 216 | + f: 8, |
| 217 | + g: 9, |
| 218 | + h: 10 |
| 219 | + }, |
| 220 | + BigStruct { |
| 221 | + a: 11, |
| 222 | + b: 12, |
| 223 | + c: 13, |
| 224 | + d: 14, |
| 225 | + e: 15, |
| 226 | + f: 16, |
| 227 | + g: 17, |
| 228 | + h: 18 |
| 229 | + } |
| 230 | + ); |
| 231 | + |
| 232 | + binding(19, 20, 21.5); |
| 233 | + assignment(22, 23, 24.5); |
| 234 | + function_call(25, 26, 27.5); |
| 235 | + identifier(28, 29, 30.5); |
| 236 | + return_expr(31, 32, 33.5); |
| 237 | + arithmetic_expr(34, 35, 36.5); |
| 238 | + if_expr(37, 38, 39.5); |
| 239 | + while_expr(40, 41, 42); |
| 240 | + loop_expr(43, 44, 45); |
| 241 | +} |
| 242 | + |
| 243 | + |
| 244 | + |
0 commit comments