|
| 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-tidy-linelength |
| 12 | +// ignore-lldb: FIXME(#27089) |
| 13 | +// min-lldb-version: 310 |
| 14 | + |
| 15 | +// As long as LLVM 5 and LLVM 6 are supported, we want to test the |
| 16 | +// enum debuginfo fallback mode. Once those are desupported, this |
| 17 | +// test can be removed, as there is another (non-"legacy") test that |
| 18 | +// tests the new mode. |
| 19 | +// ignore-llvm-version: 7.0 - 9.9.9 |
| 20 | +// ignore-gdb-version: 8.2 - 9.9 |
| 21 | + |
| 22 | +// compile-flags:-g |
| 23 | + |
| 24 | +// === GDB TESTS =================================================================================== |
| 25 | +// gdb-command:run |
| 26 | + |
| 27 | +// gdb-command:print eight_bytes1 |
| 28 | +// gdbg-check:$1 = {{RUST$ENUM$DISR = Variant1, __0 = 100}, {RUST$ENUM$DISR = Variant1, __0 = 100}} |
| 29 | +// gdbr-check:$1 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(100) |
| 30 | + |
| 31 | +// gdb-command:print four_bytes1 |
| 32 | +// gdbg-check:$2 = {{RUST$ENUM$DISR = Variant1, __0 = 101}, {RUST$ENUM$DISR = Variant1, __0 = 101}} |
| 33 | +// gdbr-check:$2 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(101) |
| 34 | + |
| 35 | +// gdb-command:print two_bytes1 |
| 36 | +// gdbg-check:$3 = {{RUST$ENUM$DISR = Variant1, __0 = 102}, {RUST$ENUM$DISR = Variant1, __0 = 102}} |
| 37 | +// gdbr-check:$3 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(102) |
| 38 | + |
| 39 | +// gdb-command:print one_byte1 |
| 40 | +// gdbg-check:$4 = {{RUST$ENUM$DISR = Variant1, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant1, __0 = 65 'A'}} |
| 41 | +// gdbr-check:$4 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant1(65) |
| 42 | + |
| 43 | + |
| 44 | +// gdb-command:print eight_bytes2 |
| 45 | +// gdbg-check:$5 = {{RUST$ENUM$DISR = Variant2, __0 = 100}, {RUST$ENUM$DISR = Variant2, __0 = 100}} |
| 46 | +// gdbr-check:$5 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(100) |
| 47 | + |
| 48 | +// gdb-command:print four_bytes2 |
| 49 | +// gdbg-check:$6 = {{RUST$ENUM$DISR = Variant2, __0 = 101}, {RUST$ENUM$DISR = Variant2, __0 = 101}} |
| 50 | +// gdbr-check:$6 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(101) |
| 51 | + |
| 52 | +// gdb-command:print two_bytes2 |
| 53 | +// gdbg-check:$7 = {{RUST$ENUM$DISR = Variant2, __0 = 102}, {RUST$ENUM$DISR = Variant2, __0 = 102}} |
| 54 | +// gdbr-check:$7 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(102) |
| 55 | + |
| 56 | +// gdb-command:print one_byte2 |
| 57 | +// gdbg-check:$8 = {{RUST$ENUM$DISR = Variant2, __0 = 65 'A'}, {RUST$ENUM$DISR = Variant2, __0 = 65 'A'}} |
| 58 | +// gdbr-check:$8 = generic_enum_with_different_disr_sizes_legacy::Enum::Variant2(65) |
| 59 | + |
| 60 | +// gdb-command:continue |
| 61 | + |
| 62 | +// === LLDB TESTS ================================================================================== |
| 63 | +// lldb-command:run |
| 64 | + |
| 65 | +// lldb-command:print eight_bytes1 |
| 66 | +// lldb-check:[...]$0 = Variant1(100) |
| 67 | +// lldb-command:print four_bytes1 |
| 68 | +// lldb-check:[...]$1 = Variant1(101) |
| 69 | +// lldb-command:print two_bytes1 |
| 70 | +// lldb-check:[...]$2 = Variant1(102) |
| 71 | +// lldb-command:print one_byte1 |
| 72 | +// lldb-check:[...]$3 = Variant1('A') |
| 73 | + |
| 74 | +// lldb-command:print eight_bytes2 |
| 75 | +// lldb-check:[...]$4 = Variant2(100) |
| 76 | +// lldb-command:print four_bytes2 |
| 77 | +// lldb-check:[...]$5 = Variant2(101) |
| 78 | +// lldb-command:print two_bytes2 |
| 79 | +// lldb-check:[...]$6 = Variant2(102) |
| 80 | +// lldb-command:print one_byte2 |
| 81 | +// lldb-check:[...]$7 = Variant2('A') |
| 82 | + |
| 83 | +// lldb-command:continue |
| 84 | + |
| 85 | +#![allow(unused_variables)] |
| 86 | +#![allow(dead_code)] |
| 87 | +#![feature(omit_gdb_pretty_printer_section)] |
| 88 | +#![omit_gdb_pretty_printer_section] |
| 89 | + |
| 90 | +// This test case makes sure that we get correct type descriptions for the enum |
| 91 | +// discriminant of different instantiations of the same generic enum type where, |
| 92 | +// dependending on the generic type parameter(s), the discriminant has a |
| 93 | +// different size in memory. |
| 94 | + |
| 95 | +enum Enum<T> { |
| 96 | + Variant1(T), |
| 97 | + Variant2(T) |
| 98 | +} |
| 99 | + |
| 100 | +fn main() { |
| 101 | + // These are ordered for descending size on purpose |
| 102 | + let eight_bytes1 = Enum::Variant1(100.0f64); |
| 103 | + let four_bytes1 = Enum::Variant1(101i32); |
| 104 | + let two_bytes1 = Enum::Variant1(102i16); |
| 105 | + let one_byte1 = Enum::Variant1(65u8); |
| 106 | + |
| 107 | + let eight_bytes2 = Enum::Variant2(100.0f64); |
| 108 | + let four_bytes2 = Enum::Variant2(101i32); |
| 109 | + let two_bytes2 = Enum::Variant2(102i16); |
| 110 | + let one_byte2 = Enum::Variant2(65u8); |
| 111 | + |
| 112 | + zzz(); // #break |
| 113 | +} |
| 114 | + |
| 115 | +fn zzz() { () } |
0 commit comments