2020-04-14 14:10:58 -05:00
|
|
|
// Require a gdb that can read DW_TAG_variant_part.
|
2019-04-12 19:03:03 -05:00
|
|
|
//@ min-gdb-version: 8.2
|
2024-04-22 20:55:29 -05:00
|
|
|
//@ min-lldb-version: 1800
|
2019-04-12 19:03:03 -05:00
|
|
|
|
2024-04-22 20:55:29 -05:00
|
|
|
// LLDB (18.1+) now supports DW_TAG_variant_part, but there is some bug in either compiler or LLDB
|
|
|
|
// with memory layout of discriminant for this particular enum
|
2021-04-30 07:02:53 -05:00
|
|
|
// ensure that LLDB won't crash at least (like #57822).
|
|
|
|
|
2019-04-12 19:03:03 -05:00
|
|
|
//@ compile-flags:-g
|
|
|
|
|
|
|
|
// === GDB TESTS ===================================================================================
|
|
|
|
|
|
|
|
// gdb-command:run
|
|
|
|
// gdb-command:print b
|
2023-10-19 16:46:28 -05:00
|
|
|
// gdb-check:$1 = coroutine_objects::main::{coroutine_env#0}::Unresumed{_ref__a: 0x[...]}
|
2019-04-12 19:03:03 -05:00
|
|
|
// gdb-command:continue
|
|
|
|
// gdb-command:print b
|
2023-10-19 16:46:28 -05:00
|
|
|
// gdb-check:$2 = coroutine_objects::main::{coroutine_env#0}::Suspend0{c: 6, d: 7, _ref__a: 0x[...]}
|
2019-04-12 19:03:03 -05:00
|
|
|
// gdb-command:continue
|
|
|
|
// gdb-command:print b
|
2023-10-19 16:46:28 -05:00
|
|
|
// gdb-check:$3 = coroutine_objects::main::{coroutine_env#0}::Suspend1{c: 7, d: 8, _ref__a: 0x[...]}
|
2019-04-12 19:03:03 -05:00
|
|
|
// gdb-command:continue
|
|
|
|
// gdb-command:print b
|
2023-10-19 16:46:28 -05:00
|
|
|
// gdb-check:$4 = coroutine_objects::main::{coroutine_env#0}::Returned{_ref__a: 0x[...]}
|
2019-04-12 19:03:03 -05:00
|
|
|
|
|
|
|
// === LLDB TESTS ==================================================================================
|
|
|
|
|
|
|
|
// lldb-command:run
|
2024-03-15 09:05:57 -05:00
|
|
|
// lldb-command:v b
|
2024-04-22 20:55:29 -05:00
|
|
|
// lldb-check:(coroutine_objects::main::{coroutine_env#0}) b = { value = { _ref__a = 0x[...] } $discr$ = [...] }
|
2019-04-12 19:03:03 -05:00
|
|
|
|
2022-03-03 05:10:02 -06:00
|
|
|
// === CDB TESTS ===================================================================================
|
|
|
|
|
|
|
|
// cdb-command: g
|
|
|
|
// cdb-command: dx b
|
2023-10-19 16:46:28 -05:00
|
|
|
// cdb-check: b : Unresumed [Type: enum2$<coroutine_objects::main::coroutine_env$0>]
|
2022-03-15 05:45:51 -05:00
|
|
|
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *]
|
2022-03-03 05:10:02 -06:00
|
|
|
|
|
|
|
// cdb-command: g
|
|
|
|
// cdb-command: dx b
|
2023-10-19 16:46:28 -05:00
|
|
|
// cdb-check: b : Suspend0 [Type: enum2$<coroutine_objects::main::coroutine_env$0>]
|
2022-03-15 05:45:51 -05:00
|
|
|
// cdb-check: [+0x[...]] c : 6 [Type: int]
|
|
|
|
// cdb-check: [+0x[...]] d : 7 [Type: int]
|
|
|
|
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 5 [Type: int *]
|
2022-03-03 05:10:02 -06:00
|
|
|
|
|
|
|
// cdb-command: g
|
|
|
|
// cdb-command: dx b
|
2023-10-19 16:46:28 -05:00
|
|
|
// cdb-check: b : Suspend1 [Type: enum2$<coroutine_objects::main::coroutine_env$0>]
|
2022-03-15 05:45:51 -05:00
|
|
|
// cdb-check: [+0x[...]] c : 7 [Type: int]
|
|
|
|
// cdb-check: [+0x[...]] d : 8 [Type: int]
|
|
|
|
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *]
|
2022-03-03 05:10:02 -06:00
|
|
|
|
|
|
|
// cdb-command: g
|
|
|
|
// cdb-command: dx b
|
2023-10-19 16:46:28 -05:00
|
|
|
// cdb-check: b : Returned [Type: enum2$<coroutine_objects::main::coroutine_env$0>]
|
2022-03-15 05:45:51 -05:00
|
|
|
// cdb-check: [+0x[...]] _ref__a : 0x[...] : 6 [Type: int *]
|
2022-03-03 05:10:02 -06:00
|
|
|
|
2024-04-11 08:15:34 -05:00
|
|
|
#![feature(omit_gdb_pretty_printer_section, coroutines, coroutine_trait, stmt_expr_attributes)]
|
2019-04-12 19:03:03 -05:00
|
|
|
#![omit_gdb_pretty_printer_section]
|
|
|
|
|
2023-10-19 11:06:43 -05:00
|
|
|
use std::ops::Coroutine;
|
2019-04-12 19:03:03 -05:00
|
|
|
use std::pin::Pin;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut a = 5;
|
2024-04-11 08:15:34 -05:00
|
|
|
let mut b = #[coroutine]
|
|
|
|
|| {
|
2019-04-12 19:03:03 -05:00
|
|
|
let mut c = 6;
|
|
|
|
let mut d = 7;
|
|
|
|
|
|
|
|
yield;
|
|
|
|
a += 1;
|
|
|
|
c += 1;
|
|
|
|
d += 1;
|
|
|
|
|
|
|
|
yield;
|
|
|
|
println!("{} {} {}", a, c, d);
|
|
|
|
};
|
|
|
|
_zzz(); // #break
|
2020-01-25 13:03:10 -06:00
|
|
|
Pin::new(&mut b).resume(());
|
2019-04-12 19:03:03 -05:00
|
|
|
_zzz(); // #break
|
2020-01-25 13:03:10 -06:00
|
|
|
Pin::new(&mut b).resume(());
|
2019-04-12 19:03:03 -05:00
|
|
|
_zzz(); // #break
|
2020-01-25 13:03:10 -06:00
|
|
|
Pin::new(&mut b).resume(());
|
2019-04-12 19:03:03 -05:00
|
|
|
_zzz(); // #break
|
|
|
|
}
|
|
|
|
|
2022-03-15 05:45:51 -05:00
|
|
|
#[inline(never)]
|
2022-01-19 10:56:53 -06:00
|
|
|
fn _zzz() {
|
|
|
|
()
|
|
|
|
}
|