Skip to content

Commit 70e5c08

Browse files
debuginfo: Extended test suite with various tests for enums.
1 parent a33d1b8 commit 70e5c08

File tree

5 files changed

+343
-0
lines changed

5 files changed

+343
-0
lines changed

src/test/debug-info/borrowed-enum.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2013 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+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
// debugger:finish
17+
18+
// debugger:print *the_a_ref
19+
// check:$1 = {{TheA, x = 0, y = 8970181431921507452}, {TheA, 0, 2088533116, 2088533116}}
20+
21+
// debugger:print *the_b_ref
22+
// check:$2 = {{TheB, x = 0, y = 1229782938247303441}, {TheB, 0, 286331153, 286331153}}
23+
24+
// debugger:print *univariant_ref
25+
// check:$3 = {{4820353753753434}}
26+
27+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
28+
// the size of the discriminant value is machine dependent, this has be taken into account when
29+
// datatype layout should be predictable as in this case.
30+
enum ABC {
31+
TheA { x: i64, y: i64 },
32+
TheB (i64, i32, i32),
33+
}
34+
35+
// This is a special case since it does not have the implicit discriminant field.
36+
enum Univariant {
37+
TheOnlyCase(i64)
38+
}
39+
40+
fn main() {
41+
42+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
43+
// 0b01111100011111000111110001111100 = 2088533116
44+
// 0b0111110001111100 = 31868
45+
// 0b01111100 = 124
46+
let the_a = TheA { x: 0, y: 8970181431921507452 };
47+
let the_a_ref : &ABC = &the_a;
48+
49+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
50+
// 0b00010001000100010001000100010001 = 286331153
51+
// 0b0001000100010001 = 4369
52+
// 0b00010001 = 17
53+
let the_b = TheB (0, 286331153, 286331153);
54+
let the_b_ref : &ABC = &the_b;
55+
56+
let univariant = TheOnlyCase(4820353753753434);
57+
let univariant_ref : &Univariant = &univariant;
58+
59+
zzz();
60+
}
61+
62+
fn zzz() {()}

src/test/debug-info/evec-in-struct.rs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright 2013 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+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:set print pretty off
15+
// debugger:break zzz
16+
// debugger:run
17+
// debugger:finish
18+
19+
// debugger:print no_padding1
20+
// check:$1 = {x = {0, 1, 2}, y = -3, z = {4.5, 5.5}}
21+
// debugger:print no_padding2
22+
// check:$2 = {x = {6, 7, 8}, y = {{9, 10}, {11, 12}}}
23+
24+
// debugger:print struct_internal_padding
25+
// check:$3 = {x = {13, 14}, y = {15, 16}}
26+
27+
// debugger:print single_vec
28+
// check:$4 = {x = {17, 18, 19, 20, 21}}
29+
30+
// debugger:print struct_padded_at_end
31+
// check:$5 = {x = {22, 23}, y = {24, 25}}
32+
33+
struct NoPadding1 {
34+
x: [u32, ..3],
35+
y: i32,
36+
z: [f32, ..2]
37+
}
38+
39+
struct NoPadding2 {
40+
x: [u32, ..3],
41+
y: [[u32, ..2], ..2]
42+
}
43+
44+
struct StructInternalPadding {
45+
x: [i16, ..2],
46+
y: [i64, ..2]
47+
}
48+
49+
struct SingleVec {
50+
x: [i16, ..5]
51+
}
52+
53+
struct StructPaddedAtEnd {
54+
x: [i64, ..2],
55+
y: [i16, ..2]
56+
}
57+
58+
fn main() {
59+
60+
let no_padding1 = NoPadding1 {
61+
x: [0, 1, 2],
62+
y: -3,
63+
z: [4.5, 5.5]
64+
};
65+
66+
let no_padding2 = NoPadding2 {
67+
x: [6, 7, 8],
68+
y: [[9, 10], [11, 12]]
69+
};
70+
71+
let struct_internal_padding = StructInternalPadding {
72+
x: [13, 14],
73+
y: [15, 16]
74+
};
75+
76+
let single_vec = SingleVec {
77+
x: [17, 18, 19, 20, 21]
78+
};
79+
80+
let struct_padded_at_end = StructPaddedAtEnd {
81+
x: [22, 23],
82+
y: [24, 25]
83+
};
84+
85+
zzz();
86+
}
87+
88+
fn zzz() {()}

src/test/debug-info/managed-enum.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2013 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+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
// debugger:finish
17+
18+
// debugger:print the_a->val
19+
// check:$1 = {{TheA, x = 0, y = 8970181431921507452}, {TheA, 0, 2088533116, 2088533116}}
20+
21+
// debugger:print the_b->val
22+
// check:$2 = {{TheB, x = 0, y = 1229782938247303441}, {TheB, 0, 286331153, 286331153}}
23+
24+
// debugger:print univariant->val
25+
// check:$3 = {{-9747455}}
26+
27+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
28+
// the size of the discriminant value is machine dependent, this has be taken into account when
29+
// datatype layout should be predictable as in this case.
30+
enum ABC {
31+
TheA { x: i64, y: i64 },
32+
TheB (i64, i32, i32),
33+
}
34+
35+
// This is a special case since it does not have the implicit discriminant field.
36+
enum Univariant {
37+
TheOnlyCase(i64)
38+
}
39+
40+
fn main() {
41+
42+
// In order to avoid endianess trouble all of the following test values consist of a single
43+
// repeated byte. This way each interpretation of the union should look the same, no matter if
44+
// this is a big or little endian machine.
45+
46+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
47+
// 0b01111100011111000111110001111100 = 2088533116
48+
// 0b0111110001111100 = 31868
49+
// 0b01111100 = 124
50+
let the_a = @TheA { x: 0, y: 8970181431921507452 };
51+
52+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
53+
// 0b00010001000100010001000100010001 = 286331153
54+
// 0b0001000100010001 = 4369
55+
// 0b00010001 = 17
56+
let the_b = @TheB (0, 286331153, 286331153);
57+
58+
let univariant = @TheOnlyCase(-9747455);
59+
60+
zzz();
61+
}
62+
63+
fn zzz() {()}

src/test/debug-info/struct-in-enum.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// Copyright 2013 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+
// compile-flags:-Z extra-debug-info
12+
// debugger:set print union on
13+
// debugger:break zzz
14+
// debugger:run
15+
// debugger:finish
16+
17+
// debugger:print case1
18+
// check:$1 = {{Case1, 0, {x = 2088533116, y = 2088533116, z = 31868}}, {Case1, 0, 8970181431921507452, 31868}}
19+
20+
// debugger:print case2
21+
// check:$2 = {{Case2, 0, {x = 286331153, y = 286331153, z = 4369}}, {Case2, 0, 1229782938247303441, 4369}}
22+
23+
// debugger:print univariant
24+
// check:$3 = {{{x = 123, y = 456, z = 789}}}
25+
26+
struct Struct {
27+
x: u32,
28+
y: i32,
29+
z: i16
30+
}
31+
32+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
33+
// the size of the discriminant value is machine dependent, this has be taken into account when
34+
// datatype layout should be predictable as in this case.
35+
enum Regular {
36+
Case1(u64, Struct),
37+
Case2(u64, u64, i16)
38+
}
39+
40+
enum Univariant {
41+
TheOnlyCase(Struct)
42+
}
43+
44+
fn main() {
45+
46+
// In order to avoid endianess trouble all of the following test values consist of a single
47+
// repeated byte. This way each interpretation of the union should look the same, no matter if
48+
// this is a big or little endian machine.
49+
50+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
51+
// 0b01111100011111000111110001111100 = 2088533116
52+
// 0b0111110001111100 = 31868
53+
// 0b01111100 = 124
54+
let case1 = Case1(0, Struct { x: 2088533116, y: 2088533116, z: 31868 });
55+
56+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
57+
// 0b00010001000100010001000100010001 = 286331153
58+
// 0b0001000100010001 = 4369
59+
// 0b00010001 = 17
60+
let case2 = Case2(0, 1229782938247303441, 4369);
61+
62+
let univariant = TheOnlyCase(Struct { x: 123, y: 456, z: 789 });
63+
64+
zzz();
65+
}
66+
67+
fn zzz() {()}

src/test/debug-info/unique-enum.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2013 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+
// xfail-win32 Broken because of LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=16249
12+
13+
// compile-flags:-Z extra-debug-info
14+
// debugger:break zzz
15+
// debugger:run
16+
// debugger:finish
17+
18+
// debugger:print *the_a
19+
// check:$1 = {{TheA, x = 0, y = 8970181431921507452}, {TheA, 0, 2088533116, 2088533116}}
20+
21+
// debugger:print *the_b
22+
// check:$2 = {{TheB, x = 0, y = 1229782938247303441}, {TheB, 0, 286331153, 286331153}}
23+
24+
// debugger:print *univariant
25+
// check:$3 = {{123234}}
26+
27+
// The first element is to ensure proper alignment, irrespective of the machines word size. Since
28+
// the size of the discriminant value is machine dependent, this has be taken into account when
29+
// datatype layout should be predictable as in this case.
30+
enum ABC {
31+
TheA { x: i64, y: i64 },
32+
TheB (i64, i32, i32),
33+
}
34+
35+
// This is a special case since it does not have the implicit discriminant field.
36+
enum Univariant {
37+
TheOnlyCase(i64)
38+
}
39+
40+
fn main() {
41+
42+
// In order to avoid endianess trouble all of the following test values consist of a single
43+
// repeated byte. This way each interpretation of the union should look the same, no matter if
44+
// this is a big or little endian machine.
45+
46+
// 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
47+
// 0b01111100011111000111110001111100 = 2088533116
48+
// 0b0111110001111100 = 31868
49+
// 0b01111100 = 124
50+
let the_a = ~TheA { x: 0, y: 8970181431921507452 };
51+
52+
// 0b0001000100010001000100010001000100010001000100010001000100010001 = 1229782938247303441
53+
// 0b00010001000100010001000100010001 = 286331153
54+
// 0b0001000100010001 = 4369
55+
// 0b00010001 = 17
56+
let the_b = ~TheB (0, 286331153, 286331153);
57+
58+
let univariant = ~TheOnlyCase(123234);
59+
60+
zzz();
61+
}
62+
63+
fn zzz() {()}

0 commit comments

Comments
 (0)