Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d36e37e

Browse files
committedOct 30, 2018
Add legacy debuginfo tests
The enum debuginfo patch includes a legacy mode that is used when building against LLVM 5 and LLVM 6. The main enum debuginfo tests have been updated to rely on the new approach and a new-enough gdb. This patch makes a copy of these tests so that the fallback mode will continue to be tested. Note that nil-enum.rs is not copied; it seemed not to provide enough value to bother. A new header directive is added, "ignore-llvm-version". I will send a patch to update the rustc documentation once this lands.
1 parent 8bbb62f commit d36e37e

9 files changed

+1019
-0
lines changed
 
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
// min-lldb-version: 310
13+
14+
// As long as LLVM 5 and LLVM 6 are supported, we want to test the
15+
// enum debuginfo fallback mode. Once those are desupported, this
16+
// test can be removed, as there is another (non-"legacy") test that
17+
// tests the new mode.
18+
// ignore-llvm-version: 7.0 - 9.9.9
19+
// ignore-gdb-version: 7.11.90 - 7.12.9
20+
// ignore-gdb-version: 8.2 - 9.9
21+
22+
// compile-flags:-g
23+
24+
// === GDB TESTS ===================================================================================
25+
26+
// gdb-command:run
27+
28+
// gdb-command:print *the_a_ref
29+
// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
30+
// gdbr-check:$1 = borrowed_enum_legacy::ABC::TheA{x: 0, y: 8970181431921507452}
31+
32+
// gdb-command:print *the_b_ref
33+
// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
34+
// gdbr-check:$2 = borrowed_enum_legacy::ABC::TheB(0, 286331153, 286331153)
35+
36+
// gdb-command:print *univariant_ref
37+
// gdbg-check:$3 = {{__0 = 4820353753753434}}
38+
// gdbr-check:$3 = borrowed_enum_legacy::Univariant::TheOnlyCase(4820353753753434)
39+
40+
41+
// === LLDB TESTS ==================================================================================
42+
43+
// lldb-command:run
44+
45+
// lldb-command:print *the_a_ref
46+
// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
47+
// lldbr-check:(borrowed_enum_legacy::ABC::TheA) *the_a_ref = TheA { borrowed_enum_legacy::ABC::TheA: 0, borrowed_enum_legacy::ABC::TheB: 8970181431921507452 }
48+
// lldb-command:print *the_b_ref
49+
// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153)
50+
// lldbr-check:(borrowed_enum_legacy::ABC::TheB) *the_b_ref = { = 0 = 286331153 = 286331153 }
51+
// lldb-command:print *univariant_ref
52+
// lldbg-check:[...]$2 = TheOnlyCase(4820353753753434)
53+
// lldbr-check:(borrowed_enum_legacy::Univariant) *univariant_ref = { borrowed_enum_legacy::TheOnlyCase = { = 4820353753753434 } }
54+
55+
#![allow(unused_variables)]
56+
#![feature(omit_gdb_pretty_printer_section)]
57+
#![omit_gdb_pretty_printer_section]
58+
59+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
60+
// the size of the discriminant value is machine dependent, this has be taken into account when
61+
// datatype layout should be predictable as in this case.
62+
enum ABC {
63+
TheA { x: i64, y: i64 },
64+
TheB (i64, i32, i32),
65+
}
66+
67+
// This is a special case since it does not have the implicit discriminant field.
68+
enum Univariant {
69+
TheOnlyCase(i64)
70+
}
71+
72+
fn main() {
73+
74+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
75+
// 0b01111100011111000111110001111100 = 2088533116
76+
// 0b0111110001111100 = 31868
77+
// 0b01111100 = 124
78+
let the_a = ABC::TheA { x: 0, y: 8970181431921507452 };
79+
let the_a_ref: &ABC = &the_a;
80+
81+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
82+
// 0b00010001000100010001000100010001 = 286331153
83+
// 0b0001000100010001 = 4369
84+
// 0b00010001 = 17
85+
let the_b = ABC::TheB (0, 286331153, 286331153);
86+
let the_b_ref: &ABC = &the_b;
87+
88+
let univariant = Univariant::TheOnlyCase(4820353753753434);
89+
let univariant_ref: &Univariant = &univariant;
90+
91+
zzz(); // #break
92+
}
93+
94+
fn zzz() {()}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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() { () }
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12.9
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-command:set print union on
25+
// gdb-command:run
26+
27+
// gdb-command:print case1
28+
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
29+
// gdbr-check:$1 = generic_struct_style_enum_legacy::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
30+
31+
// gdb-command:print case2
32+
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
33+
// gdbr-check:$2 = generic_struct_style_enum_legacy::Regular::Case2{a: 0, b: 286331153, c: 286331153}
34+
35+
// gdb-command:print case3
36+
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
37+
// gdbr-check:$3 = generic_struct_style_enum_legacy::Regular::Case3{a: 0, b: 6438275382588823897}
38+
39+
// gdb-command:print univariant
40+
// gdbg-check:$4 = {{a = -1}}
41+
// gdbr-check:$4 = generic_struct_style_enum_legacy::Univariant<i32>::TheOnlyCase{a: -1}
42+
43+
44+
#![feature(omit_gdb_pretty_printer_section)]
45+
#![omit_gdb_pretty_printer_section]
46+
47+
use self::Regular::{Case1, Case2, Case3};
48+
use self::Univariant::TheOnlyCase;
49+
50+
// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
51+
// substituted with something of size `xx` bits and the same alignment as an integer type of the
52+
// same size.
53+
54+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
55+
// the size of the discriminant value is machine dependent, this has be taken into account when
56+
// datatype layout should be predictable as in this case.
57+
enum Regular<T16, T32, T64> {
58+
Case1 { a: T64, b: T16, c: T16, d: T16, e: T16},
59+
Case2 { a: T64, b: T32, c: T32},
60+
Case3 { a: T64, b: T64 }
61+
}
62+
63+
enum Univariant<T> {
64+
TheOnlyCase { a: T }
65+
}
66+
67+
fn main() {
68+
69+
// In order to avoid endianness trouble all of the following test values consist of a single
70+
// repeated byte. This way each interpretation of the union should look the same, no matter if
71+
// this is a big or little endian machine.
72+
73+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
74+
// 0b01111100011111000111110001111100 = 2088533116
75+
// 0b0111110001111100 = 31868
76+
// 0b01111100 = 124
77+
let case1: Regular<u16, u32, i64> = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 };
78+
79+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
80+
// 0b00010001000100010001000100010001 = 286331153
81+
// 0b0001000100010001 = 4369
82+
// 0b00010001 = 17
83+
let case2: Regular<i16, u32, i64> = Case2 { a: 0, b: 286331153, c: 286331153 };
84+
85+
// 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
86+
// 0b01011001010110010101100101011001 = 1499027801
87+
// 0b0101100101011001 = 22873
88+
// 0b01011001 = 89
89+
let case3: Regular<u16, i32, u64> = Case3 { a: 0, b: 6438275382588823897 };
90+
91+
let univariant = TheOnlyCase { a: -1 };
92+
93+
zzz(); // #break
94+
}
95+
96+
fn zzz() {()}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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+
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12.9
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+
26+
// gdb-command:set print union on
27+
// gdb-command:run
28+
29+
// gdb-command:print case1
30+
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
31+
// gdbr-check:$1 = generic_tuple_style_enum_legacy::Regular::Case1(0, 31868, 31868, 31868, 31868)
32+
33+
// gdb-command:print case2
34+
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
35+
// gdbr-check:$2 = generic_tuple_style_enum_legacy::Regular::Case2(0, 286331153, 286331153)
36+
37+
// gdb-command:print case3
38+
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
39+
// gdbr-check:$3 = generic_tuple_style_enum_legacy::Regular::Case3(0, 6438275382588823897)
40+
41+
// gdb-command:print univariant
42+
// gdbg-check:$4 = {{__0 = -1}}
43+
// gdbr-check:$4 = generic_tuple_style_enum_legacy::Univariant<i64>::TheOnlyCase(-1)
44+
45+
46+
// === LLDB TESTS ==================================================================================
47+
48+
// lldb-command:run
49+
50+
// lldb-command:print case1
51+
// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
52+
// lldbr-check:(generic_tuple_style_enum_legacy::Regular<u16, u32, u64>::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
53+
54+
// lldb-command:print case2
55+
// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
56+
// lldbr-check:(generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2) case2 = Regular<i16, i32, i64>::Case2 { generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2: 286331153, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case3: 286331153 }
57+
58+
// lldb-command:print case3
59+
// lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
60+
// lldbr-check:(generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case3) case3 = Regular<i16, i32, i64>::Case3 { generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case1: 0, generic_tuple_style_enum_legacy::Regular<i16, i32, i64>::Case2: 6438275382588823897 }
61+
62+
// lldb-command:print univariant
63+
// lldbg-check:[...]$3 = TheOnlyCase(-1)
64+
// lldbr-check:(generic_tuple_style_enum_legacy::Univariant<i64>) univariant = { generic_tuple_style_enum_legacy::TheOnlyCase = { = -1 } }
65+
66+
#![feature(omit_gdb_pretty_printer_section)]
67+
#![omit_gdb_pretty_printer_section]
68+
69+
use self::Regular::{Case1, Case2, Case3};
70+
use self::Univariant::TheOnlyCase;
71+
72+
// NOTE: This is a copy of the non-generic test case. The `Txx` type parameters have to be
73+
// substituted with something of size `xx` bits and the same alignment as an integer type of the
74+
// same size.
75+
76+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
77+
// the size of the discriminant value is machine dependent, this has be taken into account when
78+
// datatype layout should be predictable as in this case.
79+
enum Regular<T16, T32, T64> {
80+
Case1(T64, T16, T16, T16, T16),
81+
Case2(T64, T32, T32),
82+
Case3(T64, T64)
83+
}
84+
85+
enum Univariant<T64> {
86+
TheOnlyCase(T64)
87+
}
88+
89+
fn main() {
90+
91+
// In order to avoid endianness trouble all of the following test values consist of a single
92+
// repeated byte. This way each interpretation of the union should look the same, no matter if
93+
// this is a big or little endian machine.
94+
95+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
96+
// 0b01111100011111000111110001111100 = 2088533116
97+
// 0b0111110001111100 = 31868
98+
// 0b01111100 = 124
99+
let case1: Regular<u16, u32, u64> = Case1(0_u64, 31868_u16, 31868_u16, 31868_u16, 31868_u16);
100+
101+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
102+
// 0b00010001000100010001000100010001 = 286331153
103+
// 0b0001000100010001 = 4369
104+
// 0b00010001 = 17
105+
let case2: Regular<i16, i32, i64> = Case2(0_i64, 286331153_i32, 286331153_i32);
106+
107+
// 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
108+
// 0b01011001010110010101100101011001 = 1499027801
109+
// 0b0101100101011001 = 22873
110+
// 0b01011001 = 89
111+
let case3: Regular<i16, i32, i64> = Case3(0_i64, 6438275382588823897_i64);
112+
113+
let univariant = TheOnlyCase(-1_i64);
114+
115+
zzz(); // #break
116+
}
117+
118+
fn zzz() { () }
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
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
13+
14+
// As long as LLVM 5 and LLVM 6 are supported, we want to test the
15+
// enum debuginfo fallback mode. Once those are desupported, this
16+
// test can be removed, as there is another (non-"legacy") test that
17+
// tests the new mode.
18+
// ignore-llvm-version: 7.0 - 9.9.9
19+
// ignore-gdb-version: 7.11.90 - 7.12.9
20+
// ignore-gdb-version: 8.2 - 9.9
21+
22+
// compile-flags:-g
23+
24+
// gdb-command:run
25+
26+
// gdb-command:print stack_unique.value
27+
// gdb-check:$1 = 0
28+
// gdbg-command:print stack_unique.next.RUST$ENCODED$ENUM$0$Empty.val->value
29+
// gdbr-command:print stack_unique.next.val.value
30+
// gdb-check:$2 = 1
31+
32+
// gdbg-command:print unique_unique->value
33+
// gdbr-command:print unique_unique.value
34+
// gdb-check:$3 = 2
35+
// gdbg-command:print unique_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
36+
// gdbr-command:print unique_unique.next.val.value
37+
// gdb-check:$4 = 3
38+
39+
// gdb-command:print vec_unique[0].value
40+
// gdb-check:$5 = 6.5
41+
// gdbg-command:print vec_unique[0].next.RUST$ENCODED$ENUM$0$Empty.val->value
42+
// gdbr-command:print vec_unique[0].next.val.value
43+
// gdb-check:$6 = 7.5
44+
45+
// gdbg-command:print borrowed_unique->value
46+
// gdbr-command:print borrowed_unique.value
47+
// gdb-check:$7 = 8.5
48+
// gdbg-command:print borrowed_unique->next.RUST$ENCODED$ENUM$0$Empty.val->value
49+
// gdbr-command:print borrowed_unique.next.val.value
50+
// gdb-check:$8 = 9.5
51+
52+
// LONG CYCLE
53+
// gdb-command:print long_cycle1.value
54+
// gdb-check:$9 = 20
55+
// gdbg-command:print long_cycle1.next->value
56+
// gdbr-command:print long_cycle1.next.value
57+
// gdb-check:$10 = 21
58+
// gdbg-command:print long_cycle1.next->next->value
59+
// gdbr-command:print long_cycle1.next.next.value
60+
// gdb-check:$11 = 22
61+
// gdbg-command:print long_cycle1.next->next->next->value
62+
// gdbr-command:print long_cycle1.next.next.next.value
63+
// gdb-check:$12 = 23
64+
65+
// gdb-command:print long_cycle2.value
66+
// gdb-check:$13 = 24
67+
// gdbg-command:print long_cycle2.next->value
68+
// gdbr-command:print long_cycle2.next.value
69+
// gdb-check:$14 = 25
70+
// gdbg-command:print long_cycle2.next->next->value
71+
// gdbr-command:print long_cycle2.next.next.value
72+
// gdb-check:$15 = 26
73+
74+
// gdb-command:print long_cycle3.value
75+
// gdb-check:$16 = 27
76+
// gdbg-command:print long_cycle3.next->value
77+
// gdbr-command:print long_cycle3.next.value
78+
// gdb-check:$17 = 28
79+
80+
// gdb-command:print long_cycle4.value
81+
// gdb-check:$18 = 29.5
82+
83+
// gdbg-command:print (*****long_cycle_w_anonymous_types).value
84+
// gdbr-command:print long_cycle_w_anonymous_types.value
85+
// gdb-check:$19 = 30
86+
87+
// gdbg-command:print (*****((*****long_cycle_w_anonymous_types).next.RUST$ENCODED$ENUM$0$Empty.val)).value
88+
// gdbr-command:print long_cycle_w_anonymous_types.next.val.value
89+
// gdb-check:$20 = 31
90+
91+
// gdb-command:continue
92+
93+
#![allow(unused_variables)]
94+
#![feature(box_syntax)]
95+
#![feature(omit_gdb_pretty_printer_section)]
96+
#![omit_gdb_pretty_printer_section]
97+
98+
use self::Opt::{Empty, Val};
99+
100+
enum Opt<T> {
101+
Empty,
102+
Val { val: T }
103+
}
104+
105+
struct UniqueNode<T> {
106+
next: Opt<Box<UniqueNode<T>>>,
107+
value: T
108+
}
109+
110+
struct LongCycle1<T> {
111+
next: Box<LongCycle2<T>>,
112+
value: T,
113+
}
114+
115+
struct LongCycle2<T> {
116+
next: Box<LongCycle3<T>>,
117+
value: T,
118+
}
119+
120+
struct LongCycle3<T> {
121+
next: Box<LongCycle4<T>>,
122+
value: T,
123+
}
124+
125+
struct LongCycle4<T> {
126+
next: Option<Box<LongCycle1<T>>>,
127+
value: T,
128+
}
129+
130+
struct LongCycleWithAnonymousTypes {
131+
next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>,
132+
value: usize,
133+
}
134+
135+
// This test case makes sure that recursive structs are properly described. The Node structs are
136+
// generic so that we can have a new type (that newly needs to be described) for the different
137+
// cases. The potential problem with recursive types is that the DI generation algorithm gets
138+
// trapped in an endless loop. To make sure, we actually test this in the different cases, we have
139+
// to operate on a new type each time, otherwise we would just hit the DI cache for all but the
140+
// first case.
141+
142+
// The different cases below (stack_*, unique_*, box_*, etc) are set up so that the type description
143+
// algorithm will enter the type reference cycle that is created by a recursive definition from a
144+
// different context each time.
145+
146+
// The "long cycle" cases are constructed to span a longer, indirect recursion cycle between types.
147+
// The different locals will cause the DI algorithm to enter the type reference cycle at different
148+
// points.
149+
150+
fn main() {
151+
let stack_unique: UniqueNode<u16> = UniqueNode {
152+
next: Val {
153+
val: box UniqueNode {
154+
next: Empty,
155+
value: 1,
156+
}
157+
},
158+
value: 0,
159+
};
160+
161+
let unique_unique: Box<UniqueNode<u32>> = box UniqueNode {
162+
next: Val {
163+
val: box UniqueNode {
164+
next: Empty,
165+
value: 3,
166+
}
167+
},
168+
value: 2,
169+
};
170+
171+
let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
172+
next: Val {
173+
val: box UniqueNode {
174+
next: Empty,
175+
value: 7.5,
176+
}
177+
},
178+
value: 6.5,
179+
}];
180+
181+
let borrowed_unique: &UniqueNode<f64> = &UniqueNode {
182+
next: Val {
183+
val: box UniqueNode {
184+
next: Empty,
185+
value: 9.5,
186+
}
187+
},
188+
value: 8.5,
189+
};
190+
191+
// LONG CYCLE
192+
let long_cycle1: LongCycle1<u16> = LongCycle1 {
193+
next: box LongCycle2 {
194+
next: box LongCycle3 {
195+
next: box LongCycle4 {
196+
next: None,
197+
value: 23,
198+
},
199+
value: 22,
200+
},
201+
value: 21
202+
},
203+
value: 20
204+
};
205+
206+
let long_cycle2: LongCycle2<u32> = LongCycle2 {
207+
next: box LongCycle3 {
208+
next: box LongCycle4 {
209+
next: None,
210+
value: 26,
211+
},
212+
value: 25,
213+
},
214+
value: 24
215+
};
216+
217+
let long_cycle3: LongCycle3<u64> = LongCycle3 {
218+
next: box LongCycle4 {
219+
next: None,
220+
value: 28,
221+
},
222+
value: 27,
223+
};
224+
225+
let long_cycle4: LongCycle4<f32> = LongCycle4 {
226+
next: None,
227+
value: 29.5,
228+
};
229+
230+
// It's important that LongCycleWithAnonymousTypes is encountered only at the end of the
231+
// `box` chain.
232+
let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes {
233+
next: Val {
234+
val: box box box box box LongCycleWithAnonymousTypes {
235+
next: Empty,
236+
value: 31,
237+
}
238+
},
239+
value: 30
240+
};
241+
242+
zzz(); // #break
243+
}
244+
245+
fn zzz() {()}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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+
// min-lldb-version: 310
13+
14+
// As long as LLVM 5 and LLVM 6 are supported, we want to test the
15+
// enum debuginfo fallback mode. Once those are desupported, this
16+
// test can be removed, as there is another (non-"legacy") test that
17+
// tests the new mode.
18+
// ignore-llvm-version: 7.0 - 9.9.9
19+
// ignore-gdb-version: 7.11.90 - 7.12.9
20+
// ignore-gdb-version: 8.2 - 9.9
21+
22+
// compile-flags:-g
23+
24+
// === GDB TESTS ===================================================================================
25+
26+
// gdb-command:set print union on
27+
// gdb-command:run
28+
29+
// gdb-command:print case1
30+
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
31+
// gdbr-check:$1 = struct_style_enum_legacy::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
32+
33+
// gdb-command:print case2
34+
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
35+
// gdbr-check:$2 = struct_style_enum_legacy::Regular::Case2{a: 0, b: 286331153, c: 286331153}
36+
37+
// gdb-command:print case3
38+
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
39+
// gdbr-check:$3 = struct_style_enum_legacy::Regular::Case3{a: 0, b: 6438275382588823897}
40+
41+
// gdb-command:print univariant
42+
// gdbg-check:$4 = {{a = -1}}
43+
// gdbr-check:$4 = struct_style_enum_legacy::Univariant::TheOnlyCase{a: -1}
44+
45+
46+
// === LLDB TESTS ==================================================================================
47+
48+
// lldb-command:run
49+
50+
// lldb-command:print case1
51+
// lldbg-check:[...]$0 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 }
52+
// lldbr-check:(struct_style_enum_legacy::Regular::Case1) case1 = { a = 0 b = 31868 c = 31868 d = 31868 e = 31868 }
53+
54+
// lldb-command:print case2
55+
// lldbg-check:[...]$1 = Case2 { a: 0, b: 286331153, c: 286331153 }
56+
// lldbr-check:(struct_style_enum_legacy::Regular::Case2) case2 = Case2 { struct_style_enum_legacy::Regular::Case1: 0, struct_style_enum_legacy::Regular::Case2: 286331153, struct_style_enum_legacy::Regular::Case3: 286331153 }
57+
58+
// lldb-command:print case3
59+
// lldbg-check:[...]$2 = Case3 { a: 0, b: 6438275382588823897 }
60+
// lldbr-check:(struct_style_enum_legacy::Regular::Case3) case3 = Case3 { struct_style_enum_legacy::Regular::Case1: 0, struct_style_enum_legacy::Regular::Case2: 6438275382588823897 }
61+
62+
// lldb-command:print univariant
63+
// lldbg-check:[...]$3 = TheOnlyCase { a: -1 }
64+
// lldbr-check:(struct_style_enum_legacy::Univariant) univariant = Univariant { struct_style_enum_legacy::TheOnlyCase: TheOnlyCase { a: -1 } }
65+
66+
#![allow(unused_variables)]
67+
#![feature(omit_gdb_pretty_printer_section)]
68+
#![omit_gdb_pretty_printer_section]
69+
70+
use self::Regular::{Case1, Case2, Case3};
71+
use self::Univariant::TheOnlyCase;
72+
73+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
74+
// the size of the discriminant value is machine dependent, this has be taken into account when
75+
// datatype layout should be predictable as in this case.
76+
enum Regular {
77+
Case1 { a: u64, b: u16, c: u16, d: u16, e: u16},
78+
Case2 { a: u64, b: u32, c: u32},
79+
Case3 { a: u64, b: u64 }
80+
}
81+
82+
enum Univariant {
83+
TheOnlyCase { a: i64 }
84+
}
85+
86+
fn main() {
87+
88+
// In order to avoid endianness trouble all of the following test values consist of a single
89+
// repeated byte. This way each interpretation of the union should look the same, no matter if
90+
// this is a big or little endian machine.
91+
92+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
93+
// 0b01111100011111000111110001111100 = 2088533116
94+
// 0b0111110001111100 = 31868
95+
// 0b01111100 = 124
96+
let case1 = Case1 { a: 0, b: 31868, c: 31868, d: 31868, e: 31868 };
97+
98+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
99+
// 0b00010001000100010001000100010001 = 286331153
100+
// 0b0001000100010001 = 4369
101+
// 0b00010001 = 17
102+
let case2 = Case2 { a: 0, b: 286331153, c: 286331153 };
103+
104+
// 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
105+
// 0b01011001010110010101100101011001 = 1499027801
106+
// 0b0101100101011001 = 22873
107+
// 0b01011001 = 89
108+
let case3 = Case3 { a: 0, b: 6438275382588823897 };
109+
110+
let univariant = TheOnlyCase { a: -1 };
111+
112+
zzz(); // #break
113+
}
114+
115+
fn zzz() {()}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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+
// min-lldb-version: 310
13+
14+
// As long as LLVM 5 and LLVM 6 are supported, we want to test the
15+
// enum debuginfo fallback mode. Once those are desupported, this
16+
// test can be removed, as there is another (non-"legacy") test that
17+
// tests the new mode.
18+
// ignore-llvm-version: 7.0 - 9.9.9
19+
// ignore-gdb-version: 7.11.90 - 7.12.9
20+
// ignore-gdb-version: 8.2 - 9.9
21+
22+
// compile-flags:-g
23+
24+
// === GDB TESTS ===================================================================================
25+
26+
// gdb-command:set print union on
27+
// gdb-command:run
28+
29+
// gdb-command:print case1
30+
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
31+
// gdbr-check:$1 = tuple_style_enum_legacy::Regular::Case1(0, 31868, 31868, 31868, 31868)
32+
33+
// gdb-command:print case2
34+
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
35+
// gdbr-check:$2 = tuple_style_enum_legacy::Regular::Case2(0, 286331153, 286331153)
36+
37+
// gdb-command:print case3
38+
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
39+
// gdbr-check:$3 = tuple_style_enum_legacy::Regular::Case3(0, 6438275382588823897)
40+
41+
// gdb-command:print univariant
42+
// gdbg-check:$4 = {{__0 = -1}}
43+
// gdbr-check:$4 = tuple_style_enum_legacy::Univariant::TheOnlyCase(-1)
44+
45+
46+
// === LLDB TESTS ==================================================================================
47+
48+
// lldb-command:run
49+
50+
// lldb-command:print case1
51+
// lldbg-check:[...]$0 = Case1(0, 31868, 31868, 31868, 31868)
52+
// lldbr-check:(tuple_style_enum_legacy::Regular::Case1) case1 = { = 0 = 31868 = 31868 = 31868 = 31868 }
53+
54+
// lldb-command:print case2
55+
// lldbg-check:[...]$1 = Case2(0, 286331153, 286331153)
56+
// lldbr-check:(tuple_style_enum_legacy::Regular::Case2) case2 = Case2 { tuple_style_enum_legacy::Regular::Case1: 0, tuple_style_enum_legacy::Regular::Case2: 286331153, tuple_style_enum_legacy::Regular::Case3: 286331153 }
57+
58+
// lldb-command:print case3
59+
// lldbg-check:[...]$2 = Case3(0, 6438275382588823897)
60+
// lldbr-check:(tuple_style_enum_legacy::Regular::Case3) case3 = Case3 { tuple_style_enum_legacy::Regular::Case1: 0, tuple_style_enum_legacy::Regular::Case2: 6438275382588823897 }
61+
62+
// lldb-command:print univariant
63+
// lldbg-check:[...]$3 = TheOnlyCase(-1)
64+
// lldbr-check:(tuple_style_enum_legacy::Univariant) univariant = { tuple_style_enum_legacy::TheOnlyCase = { = -1 } }
65+
66+
#![allow(unused_variables)]
67+
#![feature(omit_gdb_pretty_printer_section)]
68+
#![omit_gdb_pretty_printer_section]
69+
70+
use self::Regular::{Case1, Case2, Case3};
71+
use self::Univariant::TheOnlyCase;
72+
73+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
74+
// the size of the discriminant value is machine dependent, this has be taken into account when
75+
// datatype layout should be predictable as in this case.
76+
enum Regular {
77+
Case1(u64, u16, u16, u16, u16),
78+
Case2(u64, u32, u32),
79+
Case3(u64, u64)
80+
}
81+
82+
enum Univariant {
83+
TheOnlyCase(i64)
84+
}
85+
86+
fn main() {
87+
88+
// In order to avoid endianness trouble all of the following test values consist of a single
89+
// repeated byte. This way each interpretation of the union should look the same, no matter if
90+
// this is a big or little endian machine.
91+
92+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
93+
// 0b01111100011111000111110001111100 = 2088533116
94+
// 0b0111110001111100 = 31868
95+
// 0b01111100 = 124
96+
let case1 = Case1(0, 31868, 31868, 31868, 31868);
97+
98+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
99+
// 0b00010001000100010001000100010001 = 286331153
100+
// 0b0001000100010001 = 4369
101+
// 0b00010001 = 17
102+
let case2 = Case2(0, 286331153, 286331153);
103+
104+
// 0b0101100101011001010110010101100101011001010110010101100101011001 = 6438275382588823897
105+
// 0b01011001010110010101100101011001 = 1499027801
106+
// 0b0101100101011001 = 22873
107+
// 0b01011001 = 89
108+
let case3 = Case3(0, 6438275382588823897);
109+
110+
let univariant = TheOnlyCase(-1);
111+
112+
zzz(); // #break
113+
}
114+
115+
fn zzz() {()}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
// min-lldb-version: 310
13+
14+
// As long as LLVM 5 and LLVM 6 are supported, we want to test the
15+
// enum debuginfo fallback mode. Once those are desupported, this
16+
// test can be removed, as there is another (non-"legacy") test that
17+
// tests the new mode.
18+
// ignore-llvm-version: 7.0 - 9.9.9
19+
// ignore-gdb-version: 7.11.90 - 7.12.9
20+
// ignore-gdb-version: 8.2 - 9.9
21+
22+
// compile-flags:-g
23+
24+
// === GDB TESTS ===================================================================================
25+
26+
// gdb-command:run
27+
28+
// gdb-command:print *the_a
29+
// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
30+
// gdbr-check:$1 = unique_enum_legacy::ABC::TheA{x: 0, y: 8970181431921507452}
31+
32+
// gdb-command:print *the_b
33+
// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
34+
// gdbr-check:$2 = unique_enum_legacy::ABC::TheB(0, 286331153, 286331153)
35+
36+
// gdb-command:print *univariant
37+
// gdbg-check:$3 = {{__0 = 123234}}
38+
// gdbr-check:$3 = unique_enum_legacy::Univariant::TheOnlyCase(123234)
39+
40+
41+
// === LLDB TESTS ==================================================================================
42+
43+
// lldb-command:run
44+
45+
// lldb-command:print *the_a
46+
// lldbg-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
47+
// lldbr-check:(unique_enum_legacy::ABC::TheA) *the_a = TheA { unique_enum_legacy::ABC::TheA: 0, unique_enum_legacy::ABC::TheB: 8970181431921507452 }
48+
49+
// lldb-command:print *the_b
50+
// lldbg-check:[...]$1 = TheB(0, 286331153, 286331153)
51+
// lldbr-check:(unique_enum_legacy::ABC::TheB) *the_b = { = 0 = 286331153 = 286331153 }
52+
53+
// lldb-command:print *univariant
54+
// lldbg-check:[...]$2 = TheOnlyCase(123234)
55+
// lldbr-check:(unique_enum_legacy::Univariant) *univariant = { unique_enum_legacy::TheOnlyCase = { = 123234 } }
56+
57+
#![allow(unused_variables)]
58+
#![feature(box_syntax)]
59+
#![feature(omit_gdb_pretty_printer_section)]
60+
#![omit_gdb_pretty_printer_section]
61+
62+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
63+
// the size of the discriminant value is machine dependent, this has be taken into account when
64+
// datatype layout should be predictable as in this case.
65+
enum ABC {
66+
TheA { x: i64, y: i64 },
67+
TheB (i64, i32, i32),
68+
}
69+
70+
// This is a special case since it does not have the implicit discriminant field.
71+
enum Univariant {
72+
TheOnlyCase(i64)
73+
}
74+
75+
fn main() {
76+
77+
// In order to avoid endianness trouble all of the following test values consist of a single
78+
// repeated byte. This way each interpretation of the union should look the same, no matter if
79+
// this is a big or little endian machine.
80+
81+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
82+
// 0b01111100011111000111110001111100 = 2088533116
83+
// 0b0111110001111100 = 31868
84+
// 0b01111100 = 124
85+
let the_a: Box<_> = box ABC::TheA { x: 0, y: 8970181431921507452 };
86+
87+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
88+
// 0b00010001000100010001000100010001 = 286331153
89+
// 0b0001000100010001 = 4369
90+
// 0b00010001 = 17
91+
let the_b: Box<_> = box ABC::TheB (0, 286331153, 286331153);
92+
93+
let univariant: Box<_> = box Univariant::TheOnlyCase(123234);
94+
95+
zzz(); // #break
96+
}
97+
98+
fn zzz() {()}

‎src/tools/compiletest/src/header.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,29 @@ impl EarlyProps {
243243
// Ignore if using system LLVM and actual version
244244
// is smaller the minimum required version
245245
config.system_llvm && &actual_version[..] < min_version
246+
} else if line.starts_with("ignore-llvm-version") {
247+
// Syntax is: "ignore-llvm-version <version1> [- <version2>]"
248+
let range_components = line.split(' ')
249+
.skip(1) // Skip the directive.
250+
.map(|s| s.trim())
251+
.filter(|word| !word.is_empty() && word != &"-")
252+
.take(3) // 3 or more = invalid, so take at most 3.
253+
.collect::<Vec<&str>>();
254+
match range_components.len() {
255+
1 => {
256+
&actual_version[..] == range_components[0]
257+
}
258+
2 => {
259+
let v_min = range_components[0];
260+
let v_max = range_components[1];
261+
if v_max < v_min {
262+
panic!("Malformed LLVM version range: max < min")
263+
}
264+
// Ignore if version lies inside of range.
265+
&actual_version[..] >= v_min && &actual_version[..] <= v_max
266+
}
267+
_ => panic!("Malformed LLVM version directive"),
268+
}
246269
} else {
247270
false
248271
}

0 commit comments

Comments
 (0)
Please sign in to comment.