]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/by-value-non-immediate-argument.rs
Rollup merge of #47365 - Diggsey:issue-42630, r=alexcrichton
[rust.git] / src / test / debuginfo / by-value-non-immediate-argument.rs
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-test // Test temporarily ignored due to debuginfo tests being disabled, see PR 47155
13 // min-lldb-version: 310
14
15 // compile-flags:-g
16
17 // === GDB TESTS ===================================================================================
18
19 // gdb-command:run
20
21 // gdb-command:print s
22 // gdbg-check:$1 = {a = 1, b = 2.5}
23 // gdbr-check:$1 = by_value_non_immediate_argument::Struct {a: 1, b: 2.5}
24 // gdb-command:continue
25
26 // gdb-command:print x
27 // gdbg-check:$2 = {a = 3, b = 4.5}
28 // gdbr-check:$2 = by_value_non_immediate_argument::Struct {a: 3, b: 4.5}
29 // gdb-command:print y
30 // gdb-check:$3 = 5
31 // gdb-command:print z
32 // gdb-check:$4 = 6.5
33 // gdb-command:continue
34
35 // gdb-command:print a
36 // gdbg-check:$5 = {__0 = 7, __1 = 8, __2 = 9.5, __3 = 10.5}
37 // gdbr-check:$5 = (7, 8, 9.5, 10.5)
38 // gdb-command:continue
39
40 // gdb-command:print a
41 // gdbg-check:$6 = {__0 = 11.5, __1 = 12.5, __2 = 13, __3 = 14}
42 // gdbr-check:$6 = by_value_non_immediate_argument::Newtype (11.5, 12.5, 13, 14)
43 // gdb-command:continue
44
45 // gdb-command:print x
46 // gdbg-check:$7 = {{RUST$ENUM$DISR = Case1, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = Case1, [...]}}
47 // gdbr-check:$7 = by_value_non_immediate_argument::Enum::Case1{x: 0, y: 8970181431921507452}
48 // gdb-command:continue
49
50
51 // === LLDB TESTS ==================================================================================
52
53 // lldb-command:run
54
55 // lldb-command:print s
56 // lldb-check:[...]$0 = Struct { a: 1, b: 2.5 }
57 // lldb-command:continue
58
59 // lldb-command:print x
60 // lldb-check:[...]$1 = Struct { a: 3, b: 4.5 }
61 // lldb-command:print y
62 // lldb-check:[...]$2 = 5
63 // lldb-command:print z
64 // lldb-check:[...]$3 = 6.5
65 // lldb-command:continue
66
67 // lldb-command:print a
68 // lldb-check:[...]$4 = (7, 8, 9.5, 10.5)
69 // lldb-command:continue
70
71 // lldb-command:print a
72 // lldb-check:[...]$5 = Newtype(11.5, 12.5, 13, 14)
73 // lldb-command:continue
74
75 // lldb-command:print x
76 // lldb-check:[...]$6 = Case1 { x: 0, y: 8970181431921507452 }
77 // lldb-command:continue
78
79 #![feature(omit_gdb_pretty_printer_section)]
80 #![omit_gdb_pretty_printer_section]
81
82 #[derive(Clone)]
83 struct Struct {
84     a: isize,
85     b: f64
86 }
87
88 #[derive(Clone)]
89 struct StructStruct {
90     a: Struct,
91     b: Struct
92 }
93
94 fn fun(s: Struct) {
95     zzz(); // #break
96 }
97
98 fn fun_fun(StructStruct { a: x, b: Struct { a: y, b: z } }: StructStruct) {
99     zzz(); // #break
100 }
101
102 fn tup(a: (isize, usize, f64, f64)) {
103     zzz(); // #break
104 }
105
106 struct Newtype(f64, f64, isize, usize);
107
108 fn new_type(a: Newtype) {
109     zzz(); // #break
110 }
111
112 // The first element is to ensure proper alignment, irrespective of the machines word size. Since
113 // the size of the discriminant value is machine dependent, this has be taken into account when
114 // datatype layout should be predictable as in this case.
115 enum Enum {
116     Case1 { x: i64, y: i64 },
117     Case2 (i64, i32, i32),
118 }
119
120 fn by_val_enum(x: Enum) {
121     zzz(); // #break
122 }
123
124 fn main() {
125     fun(Struct { a: 1, b: 2.5 });
126     fun_fun(StructStruct { a: Struct { a: 3, b: 4.5 }, b: Struct { a: 5, b: 6.5 } });
127     tup((7, 8, 9.5, 10.5));
128     new_type(Newtype(11.5, 12.5, 13, 14));
129
130     // 0b0111110001111100011111000111110001111100011111000111110001111100 = 8970181431921507452
131     // 0b01111100011111000111110001111100 = 2088533116
132     // 0b0111110001111100 = 31868
133     // 0b01111100 = 124
134     by_val_enum(Enum::Case1 { x: 0, y: 8970181431921507452 });
135 }
136
137 fn zzz() { () }