Skip to content

Commit fda193d

Browse files
Extended test cases for struct debug information.
Added test cases for different kinds of padding (simple-struct.rs) Added test cases for nested structs (struct-in-struct.rs)
1 parent c440743 commit fda193d

File tree

3 files changed

+237
-35
lines changed

3 files changed

+237
-35
lines changed

src/test/debug-info/simple-struct.rs

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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 noPadding16
20+
// check:$1 = {x = 10000, y = -10001}
21+
22+
// debugger:print noPadding32
23+
// check:$2 = {x = -10002, y = -10003.5, z = 10004}
24+
25+
// debugger:print noPadding64
26+
// check:$3 = {x = -10005.5, y = 10006, z = 10007}
27+
28+
// debugger:print noPadding163264
29+
// check:$4 = {a = -10008, b = 10009, c = 10010, d = 10011}
30+
31+
// debugger:print internalPadding
32+
// check:$5 = {x = 10012, y = -10013}
33+
34+
// debugger:print paddingAtEnd
35+
// check:$6 = {x = -10014, y = 10015}
36+
37+
38+
struct NoPadding16 {
39+
x: u16,
40+
y: i16
41+
}
42+
43+
struct NoPadding32 {
44+
x: i32,
45+
y: f32,
46+
z: u32
47+
}
48+
49+
struct NoPadding64 {
50+
x: f64,
51+
y: i64,
52+
z: u64
53+
}
54+
55+
struct NoPadding163264 {
56+
a: i16,
57+
b: u16,
58+
c: i32,
59+
d: u64
60+
}
61+
62+
struct InternalPadding {
63+
x: u16,
64+
y: i64
65+
}
66+
67+
struct PaddingAtEnd {
68+
x: i64,
69+
y: u16
70+
}
71+
72+
fn main() {
73+
let noPadding16 = NoPadding16 { x: 10000, y: -10001 };
74+
let noPadding32 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 };
75+
let noPadding64 = NoPadding64 { x: -10005.5, y: 10006, z: 10007 };
76+
let noPadding163264 = NoPadding163264 { a: -10008, b: 10009, c: 10010, d: 10011 };
77+
78+
let internalPadding = InternalPadding { x: 10012, y: -10013 };
79+
let paddingAtEnd = PaddingAtEnd { x: -10014, y: 10015 };
80+
81+
zzz();
82+
}
83+
84+
fn zzz() {()}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
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 three_simple_structs
20+
// check:$1 = {x = {x = 1}, y = {x = 2}, z = {x = 3}}
21+
22+
// debugger:print internal_padding_parent
23+
// check:$2 = {x = {x = 4, y = 5}, y = {x = 6, y = 7}, z = {x = 8, y = 9}}
24+
25+
// debugger:print padding_at_end_parent
26+
// check:$3 = {x = {x = 10, y = 11}, y = {x = 12, y = 13}, z = {x = 14, y = 15}}
27+
28+
29+
struct Simple {
30+
x: i32
31+
}
32+
33+
struct InternalPadding {
34+
x: i32,
35+
y: i64
36+
}
37+
38+
struct PaddingAtEnd {
39+
x: i64,
40+
y: i32
41+
}
42+
43+
struct ThreeSimpleStructs {
44+
x: Simple,
45+
y: Simple,
46+
z: Simple
47+
}
48+
49+
struct InternalPaddingParent {
50+
x: InternalPadding,
51+
y: InternalPadding,
52+
z: InternalPadding
53+
}
54+
55+
struct PaddingAtEndParent {
56+
x: PaddingAtEnd,
57+
y: PaddingAtEnd,
58+
z: PaddingAtEnd
59+
}
60+
61+
struct Mixed {
62+
x: PaddingAtEnd,
63+
y: InternalPadding,
64+
z: Simple,
65+
w: i16
66+
}
67+
68+
struct Bag {
69+
x: Simple
70+
}
71+
72+
struct BagInBag {
73+
x: Bag
74+
}
75+
76+
struct ThatsJustOverkill {
77+
x: BagInBag
78+
}
79+
80+
struct Tree {
81+
x: Simple,
82+
y: InternalPaddingParent,
83+
z: BagInBag
84+
}
85+
86+
fn main() {
87+
88+
let three_simple_structs = ThreeSimpleStructs {
89+
x: Simple { x: 1 },
90+
y: Simple { x: 2 },
91+
z: Simple { x: 3 }
92+
};
93+
94+
let internal_padding_parent = InternalPaddingParent {
95+
x: InternalPadding { x: 4, y: 5 },
96+
y: InternalPadding { x: 6, y: 7 },
97+
z: InternalPadding { x: 8, y: 9 }
98+
};
99+
100+
let padding_at_end_parent = PaddingAtEndParent {
101+
x: PaddingAtEnd { x: 10, y: 11 },
102+
y: PaddingAtEnd { x: 12, y: 13 },
103+
z: PaddingAtEnd { x: 14, y: 15 }
104+
};
105+
106+
let mixed = Mixed {
107+
x: PaddingAtEnd { x: 16, y: 17 },
108+
y: InternalPadding { x: 18, y: 19 },
109+
z: Simple { x: 20 },
110+
w: 21
111+
};
112+
113+
let bag = Bag { x: Simple { x: 22 } };
114+
let bag_in_bag = BagInBag
115+
{
116+
x: Bag
117+
{
118+
x: Simple { x: 23 }
119+
}
120+
};
121+
122+
let tjo = ThatsJustOverkill
123+
{
124+
x: BagInBag
125+
{
126+
x: Bag
127+
{
128+
x: Simple { x: 24 }
129+
}
130+
}
131+
};
132+
133+
let tree = Tree {
134+
x: Simple { x: 25 },
135+
y: InternalPaddingParent
136+
{
137+
x: InternalPadding { x: 26, y: 27 },
138+
y: InternalPadding { x: 28, y: 29 },
139+
z: InternalPadding { x: 30, y: 31 }
140+
},
141+
z: BagInBag
142+
{
143+
x: Bag
144+
{
145+
x: Simple { x: 32 }
146+
}
147+
}
148+
};
149+
150+
zzz();
151+
}
152+
153+
fn zzz() {()}

src/test/debug-info/struct.rs

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)