Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 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 | |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 11 | // ignore-android: FIXME(#10381) |
Michael Woerister | 47e8cf7 | 2014-10-09 14:31:03 | [diff] [blame] | 12 | // min-lldb-version: 310 |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 13 | |
| 14 | // compile-flags:-g |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame] | 15 | |
| 16 | // === GDB TESTS =================================================================================== |
| 17 | |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 18 | // gdb-command:print 'simple-struct::NO_PADDING_16' |
| 19 | // gdb-check:$1 = {x = 1000, y = -1001} |
| 20 | |
| 21 | // gdb-command:print 'simple-struct::NO_PADDING_32' |
| 22 | // gdb-check:$2 = {x = 1, y = 2, z = 3} |
| 23 | |
| 24 | // gdb-command:print 'simple-struct::NO_PADDING_64' |
| 25 | // gdb-check:$3 = {x = 4, y = 5, z = 6} |
| 26 | |
| 27 | // gdb-command:print 'simple-struct::NO_PADDING_163264' |
| 28 | // gdb-check:$4 = {a = 7, b = 8, c = 9, d = 10} |
| 29 | |
| 30 | // gdb-command:print 'simple-struct::INTERNAL_PADDING' |
| 31 | // gdb-check:$5 = {x = 11, y = 12} |
| 32 | |
| 33 | // gdb-command:print 'simple-struct::PADDING_AT_END' |
| 34 | // gdb-check:$6 = {x = 13, y = 14} |
| 35 | |
| 36 | // gdb-command:run |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 37 | |
| 38 | // gdb-command:print no_padding16 |
| 39 | // gdb-check:$7 = {x = 10000, y = -10001} |
| 40 | |
| 41 | // gdb-command:print no_padding32 |
| 42 | // gdb-check:$8 = {x = -10002, y = -10003.5, z = 10004} |
| 43 | |
| 44 | // gdb-command:print no_padding64 |
| 45 | // gdb-check:$9 = {x = -10005.5, y = 10006, z = 10007} |
| 46 | |
| 47 | // gdb-command:print no_padding163264 |
| 48 | // gdb-check:$10 = {a = -10008, b = 10009, c = 10010, d = 10011} |
| 49 | |
| 50 | // gdb-command:print internal_padding |
| 51 | // gdb-check:$11 = {x = 10012, y = -10013} |
| 52 | |
| 53 | // gdb-command:print padding_at_end |
| 54 | // gdb-check:$12 = {x = -10014, y = 10015} |
| 55 | |
| 56 | // gdb-command:print 'simple-struct::NO_PADDING_16' |
| 57 | // gdb-check:$13 = {x = 100, y = -101} |
| 58 | |
| 59 | // gdb-command:print 'simple-struct::NO_PADDING_32' |
| 60 | // gdb-check:$14 = {x = -15, y = -16, z = 17} |
| 61 | |
| 62 | // gdb-command:print 'simple-struct::NO_PADDING_64' |
| 63 | // gdb-check:$15 = {x = -18, y = 19, z = 20} |
| 64 | |
| 65 | // gdb-command:print 'simple-struct::NO_PADDING_163264' |
| 66 | // gdb-check:$16 = {a = -21, b = 22, c = 23, d = 24} |
| 67 | |
| 68 | // gdb-command:print 'simple-struct::INTERNAL_PADDING' |
| 69 | // gdb-check:$17 = {x = 25, y = -26} |
| 70 | |
| 71 | // gdb-command:print 'simple-struct::PADDING_AT_END' |
| 72 | // gdb-check:$18 = {x = -27, y = 28} |
| 73 | |
Michael Woerister | 54a5a2b | 2014-10-29 06:13:29 | [diff] [blame] | 74 | // gdb-command:continue |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 75 | |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame] | 76 | // === LLDB TESTS ================================================================================== |
| 77 | |
| 78 | // lldb-command:run |
| 79 | |
| 80 | // lldb-command:print no_padding16 |
| 81 | // lldb-check:[...]$0 = NoPadding16 { x: 10000, y: -10001 } |
| 82 | |
| 83 | // lldb-command:print no_padding32 |
| 84 | // lldb-check:[...]$1 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 } |
| 85 | |
| 86 | // lldb-command:print no_padding64 |
| 87 | // lldb-check:[...]$2 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 } |
| 88 | |
| 89 | // lldb-command:print no_padding163264 |
| 90 | // lldb-check:[...]$3 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 } |
| 91 | |
| 92 | // lldb-command:print internal_padding |
| 93 | // lldb-check:[...]$4 = InternalPadding { x: 10012, y: -10013 } |
| 94 | |
| 95 | // lldb-command:print padding_at_end |
| 96 | // lldb-check:[...]$5 = PaddingAtEnd { x: -10014, y: 10015 } |
| 97 | |
Michael Woerister | 91a0e18 | 2014-12-03 22:48:18 | [diff] [blame^] | 98 | #![allow(unused_variables)] |
| 99 | #![allow(dead_code)] |
| 100 | #![omit_gdb_pretty_printer_section] |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 101 | |
| 102 | struct NoPadding16 { |
| 103 | x: u16, |
| 104 | y: i16 |
| 105 | } |
| 106 | |
Jakub Wieczorek | 17da4c7 | 2014-10-11 17:24:33 | [diff] [blame] | 107 | struct NoPadding32 { |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 108 | x: i32, |
| 109 | y: f32, |
| 110 | z: u32 |
| 111 | } |
| 112 | |
| 113 | struct NoPadding64 { |
| 114 | x: f64, |
| 115 | y: i64, |
| 116 | z: u64 |
| 117 | } |
| 118 | |
| 119 | struct NoPadding163264 { |
| 120 | a: i16, |
| 121 | b: u16, |
| 122 | c: i32, |
| 123 | d: u64 |
| 124 | } |
| 125 | |
| 126 | struct InternalPadding { |
| 127 | x: u16, |
| 128 | y: i64 |
| 129 | } |
| 130 | |
| 131 | struct PaddingAtEnd { |
| 132 | x: i64, |
| 133 | y: u16 |
| 134 | } |
| 135 | |
| 136 | static mut NO_PADDING_16: NoPadding16 = NoPadding16 { |
| 137 | x: 1000, |
| 138 | y: -1001 |
| 139 | }; |
| 140 | |
| 141 | static mut NO_PADDING_32: NoPadding32 = NoPadding32 { |
| 142 | x: 1, |
| 143 | y: 2.0, |
| 144 | z: 3 |
| 145 | }; |
| 146 | |
| 147 | static mut NO_PADDING_64: NoPadding64 = NoPadding64 { |
| 148 | x: 4.0, |
| 149 | y: 5, |
| 150 | z: 6 |
| 151 | }; |
| 152 | |
| 153 | static mut NO_PADDING_163264: NoPadding163264 = NoPadding163264 { |
| 154 | a: 7, |
| 155 | b: 8, |
| 156 | c: 9, |
| 157 | d: 10 |
| 158 | }; |
| 159 | |
| 160 | static mut INTERNAL_PADDING: InternalPadding = InternalPadding { |
| 161 | x: 11, |
| 162 | y: 12 |
| 163 | }; |
| 164 | |
| 165 | static mut PADDING_AT_END: PaddingAtEnd = PaddingAtEnd { |
| 166 | x: 13, |
| 167 | y: 14 |
| 168 | }; |
| 169 | |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 170 | fn main() { |
| 171 | let no_padding16 = NoPadding16 { x: 10000, y: -10001 }; |
| 172 | let no_padding32 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 }; |
| 173 | let no_padding64 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 }; |
| 174 | let no_padding163264 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 }; |
| 175 | |
| 176 | let internal_padding = InternalPadding { x: 10012, y: -10013 }; |
| 177 | let padding_at_end = PaddingAtEnd { x: -10014, y: 10015 }; |
| 178 | |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 179 | unsafe { |
| 180 | NO_PADDING_16.x = 100; |
| 181 | NO_PADDING_16.y = -101; |
| 182 | |
| 183 | NO_PADDING_32.x = -15; |
| 184 | NO_PADDING_32.y = -16.0; |
| 185 | NO_PADDING_32.z = 17; |
| 186 | |
| 187 | NO_PADDING_64.x = -18.0; |
| 188 | NO_PADDING_64.y = 19; |
| 189 | NO_PADDING_64.z = 20; |
| 190 | |
| 191 | NO_PADDING_163264.a = -21; |
| 192 | NO_PADDING_163264.b = 22; |
| 193 | NO_PADDING_163264.c = 23; |
| 194 | NO_PADDING_163264.d = 24; |
| 195 | |
| 196 | INTERNAL_PADDING.x = 25; |
| 197 | INTERNAL_PADDING.y = -26; |
| 198 | |
| 199 | PADDING_AT_END.x = -27; |
| 200 | PADDING_AT_END.y = 28; |
| 201 | } |
| 202 | |
Michael Woerister | c7f45a9 | 2014-07-09 12:46:09 | [diff] [blame] | 203 | zzz(); // #break |
Michael Woerister | 55a8bd5 | 2014-04-24 09:35:48 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | fn zzz() {()} |