]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/method-on-generic-struct.rs
Merge commit '7d53619064ab7045c383644cb445052d2a3d46db' into sync_cg_clif-2023-02-09
[rust.git] / tests / debuginfo / method-on-generic-struct.rs
1 // Some versions of the non-rust-enabled LLDB print the wrong generic
2 // parameter type names in this test.
3 // rust-lldb
4
5 // compile-flags:-g
6
7 // === GDB TESTS ===================================================================================
8
9 // gdb-command:run
10
11 // STACK BY REF
12 // gdb-command:print *self
13 // gdbg-check:$1 = {x = {__0 = 8888, __1 = -8888}}
14 // gdbr-check:$1 = method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)}
15 // gdb-command:print arg1
16 // gdb-check:$2 = -1
17 // gdb-command:print arg2
18 // gdb-check:$3 = -2
19 // gdb-command:continue
20
21 // STACK BY VAL
22 // gdb-command:print self
23 // gdbg-check:$4 = {x = {__0 = 8888, __1 = -8888}}
24 // gdbr-check:$4 = method_on_generic_struct::Struct<(u32, i32)> {x: (8888, -8888)}
25 // gdb-command:print arg1
26 // gdb-check:$5 = -3
27 // gdb-command:print arg2
28 // gdb-check:$6 = -4
29 // gdb-command:continue
30
31 // OWNED BY REF
32 // gdb-command:print *self
33 // gdbg-check:$7 = {x = 1234.5}
34 // gdbr-check:$7 = method_on_generic_struct::Struct<f64> {x: 1234.5}
35 // gdb-command:print arg1
36 // gdb-check:$8 = -5
37 // gdb-command:print arg2
38 // gdb-check:$9 = -6
39 // gdb-command:continue
40
41 // OWNED BY VAL
42 // gdb-command:print self
43 // gdbg-check:$10 = {x = 1234.5}
44 // gdbr-check:$10 = method_on_generic_struct::Struct<f64> {x: 1234.5}
45 // gdb-command:print arg1
46 // gdb-check:$11 = -7
47 // gdb-command:print arg2
48 // gdb-check:$12 = -8
49 // gdb-command:continue
50
51 // OWNED MOVED
52 // gdb-command:print *self
53 // gdbg-check:$13 = {x = 1234.5}
54 // gdbr-check:$13 = method_on_generic_struct::Struct<f64> {x: 1234.5}
55 // gdb-command:print arg1
56 // gdb-check:$14 = -9
57 // gdb-command:print arg2
58 // gdb-check:$15 = -10
59 // gdb-command:continue
60
61
62 // === LLDB TESTS ==================================================================================
63
64 // lldb-command:run
65
66 // STACK BY REF
67 // lldb-command:print *self
68 // lldbg-check:[...]$0 = Struct<(u32, i32)> { x: (8888, -8888) }
69 // lldbr-check:(method_on_generic_struct::Struct<(u32, i32)>) *self = { x = { = 8888 = -8888 } }
70 // lldb-command:print arg1
71 // lldbg-check:[...]$1 = -1
72 // lldbr-check:(isize) arg1 = -1
73 // lldb-command:print arg2
74 // lldbg-check:[...]$2 = -2
75 // lldbr-check:(isize) arg2 = -2
76 // lldb-command:continue
77
78 // STACK BY VAL
79 // lldb-command:print self
80 // lldbg-check:[...]$3 = Struct<(u32, i32)> { x: (8888, -8888) }
81 // lldbr-check:(method_on_generic_struct::Struct<(u32, i32)>) self = { x = { = 8888 = -8888 } }
82 // lldb-command:print arg1
83 // lldbg-check:[...]$4 = -3
84 // lldbr-check:(isize) arg1 = -3
85 // lldb-command:print arg2
86 // lldbg-check:[...]$5 = -4
87 // lldbr-check:(isize) arg2 = -4
88 // lldb-command:continue
89
90 // OWNED BY REF
91 // lldb-command:print *self
92 // lldbg-check:[...]$6 = Struct<f64> { x: 1234.5 }
93 // lldbr-check:(method_on_generic_struct::Struct<f64>) *self = Struct<f64> { x: 1234.5 }
94 // lldb-command:print arg1
95 // lldbg-check:[...]$7 = -5
96 // lldbr-check:(isize) arg1 = -5
97 // lldb-command:print arg2
98 // lldbg-check:[...]$8 = -6
99 // lldbr-check:(isize) arg2 = -6
100 // lldb-command:continue
101
102 // OWNED BY VAL
103 // lldb-command:print self
104 // lldbg-check:[...]$9 = Struct<f64> { x: 1234.5 }
105 // lldbr-check:(method_on_generic_struct::Struct<f64>) self = Struct<f64> { x: 1234.5 }
106 // lldb-command:print arg1
107 // lldbg-check:[...]$10 = -7
108 // lldbr-check:(isize) arg1 = -7
109 // lldb-command:print arg2
110 // lldbg-check:[...]$11 = -8
111 // lldbr-check:(isize) arg2 = -8
112 // lldb-command:continue
113
114 // OWNED MOVED
115 // lldb-command:print *self
116 // lldbg-check:[...]$12 = Struct<f64> { x: 1234.5 }
117 // lldbr-check:(method_on_generic_struct::Struct<f64>) *self = Struct<f64> { x: 1234.5 }
118 // lldb-command:print arg1
119 // lldbg-check:[...]$13 = -9
120 // lldbr-check:(isize) arg1 = -9
121 // lldb-command:print arg2
122 // lldbg-check:[...]$14 = -10
123 // lldbr-check:(isize) arg2 = -10
124 // lldb-command:continue
125
126 #![feature(omit_gdb_pretty_printer_section)]
127 #![omit_gdb_pretty_printer_section]
128
129 #[derive(Copy, Clone)]
130 struct Struct<T> {
131     x: T
132 }
133
134 impl<T> Struct<T> {
135
136     fn self_by_ref(&self, arg1: isize, arg2: isize) -> isize {
137         zzz(); // #break
138         arg1 + arg2
139     }
140
141     fn self_by_val(self, arg1: isize, arg2: isize) -> isize {
142         zzz(); // #break
143         arg1 + arg2
144     }
145
146     fn self_owned(self: Box<Struct<T>>, arg1: isize, arg2: isize) -> isize {
147         zzz(); // #break
148         arg1 + arg2
149     }
150 }
151
152 fn main() {
153     let stack = Struct { x: (8888_u32, -8888_i32) };
154     let _ = stack.self_by_ref(-1, -2);
155     let _ = stack.self_by_val(-3, -4);
156
157     let owned: Box<_> = Box::new(Struct { x: 1234.5f64 });
158     let _ = owned.self_by_ref(-5, -6);
159     let _ = owned.self_by_val(-7, -8);
160     let _ = owned.self_owned(-9, -10);
161 }
162
163 fn zzz() {()}