]> git.lizzy.rs Git - rust.git/blob - tests/debuginfo/generator-objects.rs
Rollup merge of #107580 - lenko-d:default_value_for_a_lifetime_generic_parameter_prod...
[rust.git] / tests / debuginfo / generator-objects.rs
1 // Require a gdb that can read DW_TAG_variant_part.
2 // min-gdb-version: 8.2
3
4 // LLDB without native Rust support cannot read DW_TAG_variant_part,
5 // so it prints nothing for generators. But those tests are kept to
6 // ensure that LLDB won't crash at least (like #57822).
7
8 // compile-flags:-g
9
10 // === GDB TESTS ===================================================================================
11
12 // gdb-command:run
13 // gdb-command:print b
14 // gdb-check:$1 = generator_objects::main::{generator_env#0}::Unresumed{_ref__a: 0x[...]}
15 // gdb-command:continue
16 // gdb-command:print b
17 // gdb-check:$2 = generator_objects::main::{generator_env#0}::Suspend0{c: 6, d: 7, _ref__a: 0x[...]}
18 // gdb-command:continue
19 // gdb-command:print b
20 // gdb-check:$3 = generator_objects::main::{generator_env#0}::Suspend1{c: 7, d: 8, _ref__a: 0x[...]}
21 // gdb-command:continue
22 // gdb-command:print b
23 // gdb-check:$4 = generator_objects::main::{generator_env#0}::Returned{_ref__a: 0x[...]}
24
25 // === LLDB TESTS ==================================================================================
26
27 // lldb-command:run
28 // lldb-command:print b
29 // lldbg-check:(generator_objects::main::{generator_env#0}) $0 =
30 // lldb-command:continue
31 // lldb-command:print b
32 // lldbg-check:(generator_objects::main::{generator_env#0}) $1 =
33 // lldb-command:continue
34 // lldb-command:print b
35 // lldbg-check:(generator_objects::main::{generator_env#0}) $2 =
36 // lldb-command:continue
37 // lldb-command:print b
38 // lldbg-check:(generator_objects::main::{generator_env#0}) $3 =
39
40 // === CDB TESTS ===================================================================================
41
42 // cdb-command: g
43 // cdb-command: dx b
44 // cdb-check: b                : Unresumed [Type: enum2$<generator_objects::main::generator_env$0>]
45 // cdb-check:    [+0x[...]] _ref__a          : 0x[...] : 5 [Type: int *]
46
47 // cdb-command: g
48 // cdb-command: dx b
49 // cdb-check: b                : Suspend0 [Type: enum2$<generator_objects::main::generator_env$0>]
50 // cdb-check:    [+0x[...]] c                : 6 [Type: int]
51 // cdb-check:    [+0x[...]] d                : 7 [Type: int]
52 // cdb-check:    [+0x[...]] _ref__a          : 0x[...] : 5 [Type: int *]
53
54 // cdb-command: g
55 // cdb-command: dx b
56 // cdb-check: b                : Suspend1 [Type: enum2$<generator_objects::main::generator_env$0>]
57 // cdb-check:    [+0x[...]] c                : 7 [Type: int]
58 // cdb-check:    [+0x[...]] d                : 8 [Type: int]
59 // cdb-check:    [+0x[...]] _ref__a          : 0x[...] : 6 [Type: int *]
60
61 // cdb-command: g
62 // cdb-command: dx b
63 // cdb-check: b                : Returned [Type: enum2$<generator_objects::main::generator_env$0>]
64 // cdb-check:    [+0x[...]] _ref__a          : 0x[...] : 6 [Type: int *]
65
66 #![feature(omit_gdb_pretty_printer_section, generators, generator_trait)]
67 #![omit_gdb_pretty_printer_section]
68
69 use std::ops::Generator;
70 use std::pin::Pin;
71
72 fn main() {
73     let mut a = 5;
74     let mut b = || {
75         let mut c = 6;
76         let mut d = 7;
77
78         yield;
79         a += 1;
80         c += 1;
81         d += 1;
82
83         yield;
84         println!("{} {} {}", a, c, d);
85     };
86     _zzz(); // #break
87     Pin::new(&mut b).resume(());
88     _zzz(); // #break
89     Pin::new(&mut b).resume(());
90     _zzz(); // #break
91     Pin::new(&mut b).resume(());
92     _zzz(); // #break
93 }
94
95 #[inline(never)]
96 fn _zzz() {
97     ()
98 }