]> git.proxmox.com Git - rustc.git/blame - src/test/debuginfo/packed-struct.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / test / debuginfo / packed-struct.rs
CommitLineData
1a4d82fc
JJ
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
1a4d82fc
JJ
12// min-lldb-version: 310
13
14// compile-flags:-g
15
16// === GDB TESTS ===================================================================================
17
18// gdb-command:run
19
20// gdb-command:print packed
c30ab7b3
SL
21// gdbg-check:$1 = {x = 123, y = 234, z = 345}
22// gdbr-check:$1 = packed_struct::Packed {x: 123, y: 234, z: 345}
1a4d82fc
JJ
23
24// gdb-command:print packedInPacked
c30ab7b3
SL
25// gdbg-check:$2 = {a = 1111, b = {x = 2222, y = 3333, z = 4444}, c = 5555, d = {x = 6666, y = 7777, z = 8888}}
26// gdbr-check:$2 = packed_struct::PackedInPacked {a: 1111, b: packed_struct::Packed {x: 2222, y: 3333, z: 4444}, c: 5555, d: packed_struct::Packed {x: 6666, y: 7777, z: 8888}}
1a4d82fc
JJ
27
28// gdb-command:print packedInUnpacked
c30ab7b3
SL
29// gdbg-check:$3 = {a = -1111, b = {x = -2222, y = -3333, z = -4444}, c = -5555, d = {x = -6666, y = -7777, z = -8888}}
30// gdbr-check:$3 = packed_struct::PackedInUnpacked {a: -1111, b: packed_struct::Packed {x: -2222, y: -3333, z: -4444}, c: -5555, d: packed_struct::Packed {x: -6666, y: -7777, z: -8888}}
1a4d82fc
JJ
31
32// gdb-command:print unpackedInPacked
c30ab7b3
SL
33// gdbg-check:$4 = {a = 987, b = {x = 876, y = 765, z = 654, w = 543}, c = {x = 432, y = 321, z = 210, w = 109}, d = -98}
34// gdbr-check:$4 = packed_struct::UnpackedInPacked {a: 987, b: packed_struct::Unpacked {x: 876, y: 765, z: 654, w: 543}, c: packed_struct::Unpacked {x: 432, y: 321, z: 210, w: 109}, d: -98}
1a4d82fc
JJ
35
36// gdb-command:print sizeof(packed)
37// gdb-check:$5 = 14
38
39// gdb-command:print sizeof(packedInPacked)
40// gdb-check:$6 = 40
41
42
43// === LLDB TESTS ==================================================================================
44
45// lldb-command:run
46
47// lldb-command:print packed
48// lldb-check:[...]$0 = Packed { x: 123, y: 234, z: 345 }
49
50// lldb-command:print packedInPacked
51// lldb-check:[...]$1 = PackedInPacked { a: 1111, b: Packed { x: 2222, y: 3333, z: 4444 }, c: 5555, d: Packed { x: 6666, y: 7777, z: 8888 } }
52
53// lldb-command:print packedInUnpacked
54// lldb-check:[...]$2 = PackedInUnpacked { a: -1111, b: Packed { x: -2222, y: -3333, z: -4444 }, c: -5555, d: Packed { x: -6666, y: -7777, z: -8888 } }
55
56// lldb-command:print unpackedInPacked
57// lldb-check:[...]$3 = UnpackedInPacked { a: 987, b: Unpacked { x: 876, y: 765, z: 654, w: 543 }, c: Unpacked { x: 432, y: 321, z: 210, w: 109 }, d: -98 }
58
59// lldb-command:print sizeof(packed)
60// lldb-check:[...]$4 = 14
61
62// lldb-command:print sizeof(packedInPacked)
63// lldb-check:[...]$5 = 40
64
65#![allow(unused_variables)]
b039eaaf 66#![feature(omit_gdb_pretty_printer_section)]
1a4d82fc
JJ
67#![omit_gdb_pretty_printer_section]
68
69#[repr(packed)]
70struct Packed {
71 x: i16,
72 y: i32,
73 z: i64
74}
75
76#[repr(packed)]
77struct PackedInPacked {
78 a: i32,
79 b: Packed,
80 c: i64,
81 d: Packed
82}
83
84// layout (64 bit): aaaa bbbb bbbb bbbb bb.. .... cccc cccc dddd dddd dddd dd..
85struct PackedInUnpacked {
86 a: i32,
87 b: Packed,
88 c: i64,
89 d: Packed
90}
91
92// layout (64 bit): xx.. yyyy zz.. .... wwww wwww
93struct Unpacked {
94 x: i16,
95 y: i32,
96 z: i16,
97 w: i64
98}
99
100// layout (64 bit): aabb bbbb bbbb bbbb bbbb bbbb bbcc cccc cccc cccc cccc cccc ccdd dddd dd
101#[repr(packed)]
102struct UnpackedInPacked {
103 a: i16,
104 b: Unpacked,
105 c: Unpacked,
106 d: i64
107}
108
109fn main() {
110 let packed = Packed { x: 123, y: 234, z: 345 };
111
112 let packedInPacked = PackedInPacked {
113 a: 1111,
114 b: Packed { x: 2222, y: 3333, z: 4444 },
115 c: 5555,
116 d: Packed { x: 6666, y: 7777, z: 8888 }
117 };
118
119 let packedInUnpacked = PackedInUnpacked {
120 a: -1111,
121 b: Packed { x: -2222, y: -3333, z: -4444 },
122 c: -5555,
123 d: Packed { x: -6666, y: -7777, z: -8888 }
124 };
125
126 let unpackedInPacked = UnpackedInPacked {
127 a: 987,
128 b: Unpacked { x: 876, y: 765, z: 654, w: 543 },
129 c: Unpacked { x: 432, y: 321, z: 210, w: 109 },
130 d: -98
131 };
132
133 zzz(); // #break
134}
135
136fn zzz() {()}