]> git.proxmox.com Git - rustc.git/blame - src/test/debuginfo/generator-objects.rs
New upstream version 1.65.0+dfsg1
[rustc.git] / src / test / debuginfo / generator-objects.rs
CommitLineData
ba9703b0 1// Require a gdb that can read DW_TAG_variant_part.
48663c56
XL
2// min-gdb-version: 8.2
3
17df50a5
XL
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
48663c56
XL
8// compile-flags:-g
9
10// === GDB TESTS ===================================================================================
11
12// gdb-command:run
13// gdb-command:print b
5099ac24 14// gdb-check:$1 = generator_objects::main::{generator_env#0}::Unresumed{_ref__a: 0x[...]}
48663c56
XL
15// gdb-command:continue
16// gdb-command:print b
5099ac24 17// gdb-check:$2 = generator_objects::main::{generator_env#0}::Suspend0{c: 6, d: 7, _ref__a: 0x[...]}
48663c56
XL
18// gdb-command:continue
19// gdb-command:print b
5099ac24 20// gdb-check:$3 = generator_objects::main::{generator_env#0}::Suspend1{c: 7, d: 8, _ref__a: 0x[...]}
48663c56
XL
21// gdb-command:continue
22// gdb-command:print b
5099ac24 23// gdb-check:$4 = generator_objects::main::{generator_env#0}::Returned{_ref__a: 0x[...]}
48663c56
XL
24
25// === LLDB TESTS ==================================================================================
26
27// lldb-command:run
28// lldb-command:print b
5099ac24 29// lldbg-check:(generator_objects::main::{generator_env#0}) $0 =
48663c56
XL
30// lldb-command:continue
31// lldb-command:print b
5099ac24 32// lldbg-check:(generator_objects::main::{generator_env#0}) $1 =
48663c56
XL
33// lldb-command:continue
34// lldb-command:print b
5099ac24 35// lldbg-check:(generator_objects::main::{generator_env#0}) $2 =
48663c56
XL
36// lldb-command:continue
37// lldb-command:print b
5099ac24 38// lldbg-check:(generator_objects::main::{generator_env#0}) $3 =
48663c56 39
5e7ed085
FG
40// === CDB TESTS ===================================================================================
41
42// cdb-command: g
43// cdb-command: dx b
f2b60f7d 44// cdb-check: b : Unresumed [Type: enum2$<generator_objects::main::generator_env$0>]
5e7ed085
FG
45// cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *]
46
47// cdb-command: g
48// cdb-command: dx b
f2b60f7d 49// cdb-check: b : Suspend0 [Type: enum2$<generator_objects::main::generator_env$0>]
5e7ed085
FG
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
f2b60f7d 56// cdb-check: b : Suspend1 [Type: enum2$<generator_objects::main::generator_env$0>]
5e7ed085
FG
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
f2b60f7d 63// cdb-check: b : Returned [Type: enum2$<generator_objects::main::generator_env$0>]
5e7ed085
FG
64// cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *]
65
48663c56
XL
66#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)]
67#![omit_gdb_pretty_printer_section]
68
69use std::ops::Generator;
70use std::pin::Pin;
71
72fn 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
74b04a01 87 Pin::new(&mut b).resume(());
48663c56 88 _zzz(); // #break
74b04a01 89 Pin::new(&mut b).resume(());
48663c56 90 _zzz(); // #break
74b04a01 91 Pin::new(&mut b).resume(());
48663c56
XL
92 _zzz(); // #break
93}
94
5e7ed085 95#[inline(never)]
5099ac24
FG
96fn _zzz() {
97 ()
98}