]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/var-captured-in-nested-closure.rs
Extend `BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE`.
[rust.git] / tests / debuginfo / var-captured-in-nested-closure.rs
1 // min-lldb-version: 310
2
3 // compile-flags:-g
4
5 // === GDB TESTS ===================================================================================
6
7 // gdb-command:run
8
9 // gdb-command:print variable
10 // gdb-check:$1 = 1
11 // gdb-command:print constant
12 // gdb-check:$2 = 2
13 // gdb-command:print a_struct
14 // gdbg-check:$3 = {a = -3, b = 4.5, c = 5}
15 // gdbr-check:$3 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5}
16 // gdb-command:print *struct_ref
17 // gdbg-check:$4 = {a = -3, b = 4.5, c = 5}
18 // gdbr-check:$4 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5}
19 // gdb-command:print *owned
20 // gdb-check:$5 = 6
21 // gdb-command:print closure_local
22 // gdb-check:$6 = 8
23 // gdb-command:continue
24
25 // gdb-command:print variable
26 // gdb-check:$7 = 1
27 // gdb-command:print constant
28 // gdb-check:$8 = 2
29 // gdb-command:print a_struct
30 // gdbg-check:$9 = {a = -3, b = 4.5, c = 5}
31 // gdbr-check:$9 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5}
32 // gdb-command:print *struct_ref
33 // gdbg-check:$10 = {a = -3, b = 4.5, c = 5}
34 // gdbr-check:$10 = var_captured_in_nested_closure::Struct {a: -3, b: 4.5, c: 5}
35 // gdb-command:print *owned
36 // gdb-check:$11 = 6
37 // gdb-command:print closure_local
38 // gdb-check:$12 = 8
39 // gdb-command:continue
40
41
42 // === LLDB TESTS ==================================================================================
43
44 // lldb-command:run
45
46 // lldb-command:print variable
47 // lldbg-check:[...]$0 = 1
48 // lldbr-check:(isize) variable = 1
49 // lldb-command:print constant
50 // lldbg-check:[...]$1 = 2
51 // lldbr-check:(isize) constant = 2
52 // lldb-command:print a_struct
53 // lldbg-check:[...]$2 = { a = -3 b = 4.5 c = 5 }
54 // lldbr-check:(var_captured_in_nested_closure::Struct) a_struct = { a = -3 b = 4.5 c = 5 }
55 // lldb-command:print *struct_ref
56 // lldbg-check:[...]$3 = { a = -3 b = 4.5 c = 5 }
57 // lldbr-check:(var_captured_in_nested_closure::Struct) *struct_ref = { a = -3 b = 4.5 c = 5 }
58 // lldb-command:print *owned
59 // lldbg-check:[...]$4 = 6
60 // lldbr-check:(isize) *owned = 6
61 // lldb-command:print closure_local
62 // lldbg-check:[...]$5 = 8
63 // lldbr-check:(isize) closure_local = 8
64 // lldb-command:continue
65
66 // lldb-command:print variable
67 // lldbg-check:[...]$6 = 1
68 // lldbr-check:(isize) variable = 1
69 // lldb-command:print constant
70 // lldbg-check:[...]$7 = 2
71 // lldbr-check:(isize) constant = 2
72 // lldb-command:print a_struct
73 // lldbg-check:[...]$8 = { a = -3 b = 4.5 c = 5 }
74 // lldbr-check:(var_captured_in_nested_closure::Struct) a_struct = { a = -3 b = 4.5 c = 5 }
75 // lldb-command:print *struct_ref
76 // lldbg-check:[...]$9 = { a = -3 b = 4.5 c = 5 }
77 // lldbr-check:(var_captured_in_nested_closure::Struct) *struct_ref = { a = -3 b = 4.5 c = 5 }
78 // lldb-command:print *owned
79 // lldbg-check:[...]$10 = 6
80 // lldbr-check:(isize) *owned = 6
81 // lldb-command:print closure_local
82 // lldbg-check:[...]$11 = 8
83 // lldbr-check:(isize) closure_local = 8
84 // lldb-command:continue
85
86
87 // === CDB TESTS ===================================================================================
88
89 // cdb-command: g
90
91 // cdb-command: dx variable
92 // cdb-check:variable         : 1 [Type: [...]]
93 // cdb-command: dx constant
94 // cdb-check:constant         : 2 [Type: [...]]
95 // cdb-command: dx a_struct
96 // cdb-check:a_struct         [Type: var_captured_in_nested_closure::Struct]
97 // cdb-check:    [+0x[...]] a                : -3 [Type: [...]]
98 // cdb-check:    [+0x[...]] b                : 4.500000 [Type: [...]]
99 // cdb-check:    [+0x[...]] c                : 0x5 [Type: unsigned [...]]
100 // cdb-command: dx struct_ref
101 // cdb-check:struct_ref       : 0x[...] [Type: var_captured_in_nested_closure::Struct *]
102 // cdb-check:    [+0x[...]] a                : -3 [Type: [...]]
103 // cdb-check:    [+0x[...]] b                : 4.500000 [Type: [...]]
104 // cdb-check:    [+0x[...]] c                : 0x5 [Type: unsigned [...]]
105 // cdb-command: dx owned
106 // cdb-check:owned            : 0x[...] : 6 [Type: [...] *]
107 // cdb-check:    6 [Type: [...]]
108 // cdb-command: dx closure_local
109 // cdb-check:closure_local    : 8 [Type: [...]]
110 // cdb-command: dx nested_closure
111 // cdb-check:nested_closure   [Type: var_captured_in_nested_closure::main::closure$0::closure_env$0]
112
113 // cdb-command: g
114
115 // cdb-command: dx variable
116 // cdb-check:variable         : 1 [Type: [...]]
117 // cdb-command: dx constant
118 // cdb-check:constant         : 2 [Type: [...]]
119 // cdb-command: dx a_struct
120 // cdb-check:a_struct         [Type: var_captured_in_nested_closure::Struct]
121 // cdb-check:    [+0x[...]] a                : -3 [Type: [...]]
122 // cdb-check:    [+0x[...]] b                : 4.500000 [Type: [...]]
123 // cdb-check:    [+0x[...]] c                : 0x5 [Type: unsigned [...]]
124 // cdb-command: dx struct_ref
125 // cdb-check:struct_ref       : 0x[...] [Type: var_captured_in_nested_closure::Struct *]
126 // cdb-check:    [+0x[...]] a                : -3 [Type: [...]]
127 // cdb-check:    [+0x[...]] b                : 4.500000 [Type: [...]]
128 // cdb-check:    [+0x[...]] c                : 0x5 [Type: unsigned [...]]
129 // cdb-command: dx owned
130 // cdb-check:owned            : 0x[...] : 6 [Type: [...] *]
131 // cdb-check:    6 [Type: [...]]
132 // cdb-command: dx closure_local
133 // cdb-check:closure_local    : 8 [Type: [...]]
134
135 #![allow(unused_variables)]
136 #![feature(omit_gdb_pretty_printer_section)]
137 #![omit_gdb_pretty_printer_section]
138
139 struct Struct {
140     a: isize,
141     b: f64,
142     c: usize
143 }
144
145 fn main() {
146     let mut variable = 1;
147     let constant = 2;
148
149     let a_struct = Struct {
150         a: -3,
151         b: 4.5,
152         c: 5
153     };
154
155     let struct_ref = &a_struct;
156     let owned: Box<_> = Box::new(6);
157
158     let mut closure = || {
159         let closure_local = 8;
160
161         let mut nested_closure = || {
162             zzz(); // #break
163             variable = constant + a_struct.a + struct_ref.a + *owned + closure_local;
164         };
165
166         zzz(); // #break
167
168         nested_closure();
169     };
170
171     closure();
172 }
173
174 fn zzz() {()}