|
| 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-windows failing on win32 bot |
| 12 | +// ignore-freebsd: output doesn't match |
| 13 | +// ignore-tidy-linelength |
| 14 | +// ignore-lldb |
| 15 | +// ignore-android: FIXME(#10381) |
| 16 | +// compile-flags:-g |
| 17 | + |
| 18 | +// This test uses some GDB Python API features (e.g. accessing anonymous fields) |
| 19 | +// which are only available in newer GDB version. The following directive will |
| 20 | +// case the test runner to ignore this test if an older GDB version is used: |
| 21 | +// min-gdb-version 7.7 |
| 22 | + |
| 23 | +// gdb-command: run |
| 24 | + |
| 25 | +// gdb-command: print regular_struct |
| 26 | +// gdb-check:$1 = RegularStruct = {the_first_field = 101, the_second_field = 102.5, the_third_field = false, the_fourth_field = "I'm so pretty, oh so pretty..."} |
| 27 | + |
| 28 | +// gdb-command: print tuple |
| 29 | +// gdb-check:$2 = {true, 103, "blub"} |
| 30 | + |
| 31 | +// gdb-command: print tuple_struct |
| 32 | +// gdb-check:$3 = TupleStruct = {-104.5, 105} |
| 33 | + |
| 34 | +// gdb-command: print empty_struct |
| 35 | +// gdb-check:$4 = EmptyStruct |
| 36 | + |
| 37 | +// gdb-command: print c_style_enum1 |
| 38 | +// gdb-check:$5 = CStyleEnumVar1 |
| 39 | + |
| 40 | +// gdb-command: print c_style_enum2 |
| 41 | +// gdb-check:$6 = CStyleEnumVar2 |
| 42 | + |
| 43 | +// gdb-command: print c_style_enum3 |
| 44 | +// gdb-check:$7 = CStyleEnumVar3 |
| 45 | + |
| 46 | +// gdb-command: print mixed_enum_c_style_var |
| 47 | +// gdb-check:$8 = MixedEnumCStyleVar |
| 48 | + |
| 49 | +// gdb-command: print mixed_enum_tuple_var |
| 50 | +// gdb-check:$9 = MixedEnumTupleVar = {106, 107, false} |
| 51 | + |
| 52 | +// gdb-command: print mixed_enum_struct_var |
| 53 | +// gdb-check:$10 = MixedEnumStructVar = {field1 = 108.5, field2 = 109} |
| 54 | + |
| 55 | +// gdb-command: print some |
| 56 | +// gdb-check:$11 = Some = {110} |
| 57 | + |
| 58 | +// gdb-command: print none |
| 59 | +// gdb-check:$12 = None |
| 60 | + |
| 61 | +// gdb-command: print some_fat |
| 62 | +// gdb-check:$13 = Some = {"abc"} |
| 63 | + |
| 64 | +// gdb-command: print none_fat |
| 65 | +// gdb-check:$14 = None |
| 66 | + |
| 67 | +// gdb-command: print nested_variant1 |
| 68 | +// gdb-check:$15 = NestedVariant1 = {NestedStruct = {regular_struct = RegularStruct = {the_first_field = 111, the_second_field = 112.5, the_third_field = true, the_fourth_field = "NestedStructString1"}, tuple_struct = TupleStruct = {113.5, 114}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar2, mixed_enum = MixedEnumTupleVar = {115, 116, false}}} |
| 69 | + |
| 70 | +// gdb-command: print nested_variant2 |
| 71 | +// gdb-check:$16 = NestedVariant2 = {abc = NestedStruct = {regular_struct = RegularStruct = {the_first_field = 117, the_second_field = 118.5, the_third_field = false, the_fourth_field = "NestedStructString10"}, tuple_struct = TupleStruct = {119.5, 120}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar3, mixed_enum = MixedEnumStructVar = {field1 = 121.5, field2 = -122}}} |
| 72 | + |
| 73 | +// gdb-command: print none_check1 |
| 74 | +// gdb-check:$17 = None |
| 75 | + |
| 76 | +// gdb-command: print none_check2 |
| 77 | +// gdb-check:$18 = None |
| 78 | + |
| 79 | +#![allow(dead_code, unused_variables)] |
| 80 | + |
| 81 | +use self::CStyleEnum::{CStyleEnumVar1, CStyleEnumVar2, CStyleEnumVar3}; |
| 82 | +use self::MixedEnum::{MixedEnumCStyleVar, MixedEnumTupleVar, MixedEnumStructVar}; |
| 83 | +use self::NestedEnum::{NestedVariant1, NestedVariant2}; |
| 84 | + |
| 85 | +struct RegularStruct { |
| 86 | + the_first_field: isize, |
| 87 | + the_second_field: f64, |
| 88 | + the_third_field: bool, |
| 89 | + the_fourth_field: &'static str, |
| 90 | +} |
| 91 | + |
| 92 | +struct TupleStruct(f64, i16); |
| 93 | + |
| 94 | +struct EmptyStruct; |
| 95 | + |
| 96 | +enum CStyleEnum { |
| 97 | + CStyleEnumVar1, |
| 98 | + CStyleEnumVar2, |
| 99 | + CStyleEnumVar3, |
| 100 | +} |
| 101 | + |
| 102 | +enum MixedEnum { |
| 103 | + MixedEnumCStyleVar, |
| 104 | + MixedEnumTupleVar(u32, u16, bool), |
| 105 | + MixedEnumStructVar { field1: f64, field2: i32 } |
| 106 | +} |
| 107 | + |
| 108 | +struct NestedStruct { |
| 109 | + regular_struct: RegularStruct, |
| 110 | + tuple_struct: TupleStruct, |
| 111 | + empty_struct: EmptyStruct, |
| 112 | + c_style_enum: CStyleEnum, |
| 113 | + mixed_enum: MixedEnum, |
| 114 | +} |
| 115 | + |
| 116 | +enum NestedEnum { |
| 117 | + NestedVariant1(NestedStruct), |
| 118 | + NestedVariant2 { abc: NestedStruct } |
| 119 | +} |
| 120 | + |
| 121 | +fn main() { |
| 122 | + |
| 123 | + let regular_struct = RegularStruct { |
| 124 | + the_first_field: 101, |
| 125 | + the_second_field: 102.5, |
| 126 | + the_third_field: false, |
| 127 | + the_fourth_field: "I'm so pretty, oh so pretty..." |
| 128 | + }; |
| 129 | + |
| 130 | + let tuple = ( true, 103u32, "blub" ); |
| 131 | + |
| 132 | + let tuple_struct = TupleStruct(-104.5, 105); |
| 133 | + |
| 134 | + let empty_struct = EmptyStruct; |
| 135 | + |
| 136 | + let c_style_enum1 = CStyleEnumVar1; |
| 137 | + let c_style_enum2 = CStyleEnumVar2; |
| 138 | + let c_style_enum3 = CStyleEnumVar3; |
| 139 | + |
| 140 | + let mixed_enum_c_style_var = MixedEnumCStyleVar; |
| 141 | + let mixed_enum_tuple_var = MixedEnumTupleVar(106, 107, false); |
| 142 | + let mixed_enum_struct_var = MixedEnumStructVar { field1: 108.5, field2: 109 }; |
| 143 | + |
| 144 | + let some = Some(110_usize); |
| 145 | + let none: Option<isize> = None; |
| 146 | + let some_fat = Some("abc"); |
| 147 | + let none_fat: Option<&'static str> = None; |
| 148 | + |
| 149 | + let nested_variant1 = NestedVariant1( |
| 150 | + NestedStruct { |
| 151 | + regular_struct: RegularStruct { |
| 152 | + the_first_field: 111, |
| 153 | + the_second_field: 112.5, |
| 154 | + the_third_field: true, |
| 155 | + the_fourth_field: "NestedStructString1", |
| 156 | + }, |
| 157 | + tuple_struct: TupleStruct(113.5, 114), |
| 158 | + empty_struct: EmptyStruct, |
| 159 | + c_style_enum: CStyleEnumVar2, |
| 160 | + mixed_enum: MixedEnumTupleVar(115, 116, false) |
| 161 | + } |
| 162 | + ); |
| 163 | + |
| 164 | + let nested_variant2 = NestedVariant2 { |
| 165 | + abc: NestedStruct { |
| 166 | + regular_struct: RegularStruct { |
| 167 | + the_first_field: 117, |
| 168 | + the_second_field: 118.5, |
| 169 | + the_third_field: false, |
| 170 | + the_fourth_field: "NestedStructString10", |
| 171 | + }, |
| 172 | + tuple_struct: TupleStruct(119.5, 120), |
| 173 | + empty_struct: EmptyStruct, |
| 174 | + c_style_enum: CStyleEnumVar3, |
| 175 | + mixed_enum: MixedEnumStructVar { |
| 176 | + field1: 121.5, |
| 177 | + field2: -122 |
| 178 | + } |
| 179 | + } |
| 180 | + }; |
| 181 | + |
| 182 | + let none_check1: Option<(usize, Vec<usize>)> = None; |
| 183 | + let none_check2: Option<String> = None; |
| 184 | + |
| 185 | + zzz(); // #break |
| 186 | +} |
| 187 | + |
| 188 | +fn zzz() { () } |
0 commit comments