Skip to content

Commit f18b572

Browse files
committed
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 26702da commit f18b572

9 files changed

+1001
-0
lines changed
+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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+
// lldb-check:[...]$0 = TheA { x: 0, y: 8970181431921507452 }
47+
// lldb-command:print *the_b_ref
48+
// lldb-check:[...]$1 = TheB(0, 286331153, 286331153)
49+
// lldb-command:print *univariant_ref
50+
// lldb-check:[...]$2 = TheOnlyCase(4820353753753434)
51+
52+
#![allow(unused_variables)]
53+
#![feature(omit_gdb_pretty_printer_section)]
54+
#![omit_gdb_pretty_printer_section]
55+
56+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
57+
// the size of the discriminant value is machine dependent, this has be taken into account when
58+
// datatype layout should be predictable as in this case.
59+
enum ABC {
60+
TheA { x: i64, y: i64 },
61+
TheB (i64, i32, i32),
62+
}
63+
64+
// This is a special case since it does not have the implicit discriminant field.
65+
enum Univariant {
66+
TheOnlyCase(i64)
67+
}
68+
69+
fn main() {
70+
71+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
72+
// 0b01111100011111000111110001111100 = 2088533116
73+
// 0b0111110001111100 = 31868
74+
// 0b01111100 = 124
75+
let the_a = ABC::TheA { x: 0, y: 8970181431921507452 };
76+
let the_a_ref: &ABC = &the_a;
77+
78+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
79+
// 0b00010001000100010001000100010001 = 286331153
80+
// 0b0001000100010001 = 4369
81+
// 0b00010001 = 17
82+
let the_b = ABC::TheB (0, 286331153, 286331153);
83+
let the_b_ref: &ABC = &the_b;
84+
85+
let univariant = Univariant::TheOnlyCase(4820353753753434);
86+
let univariant_ref: &Univariant = &univariant;
87+
88+
zzz(); // #break
89+
}
90+
91+
fn zzz() {()}
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() { () }
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() {()}

0 commit comments

Comments
 (0)