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