3 // Require LLVM with DW_TAG_variant_part and a gdb that can read it.
4 // min-system-llvm-version: 8.0
5 // min-gdb-version: 8.2
11 // gdb-command:print stack_unique.value
13 // gdbr-command:print stack_unique.next.val.value
16 // gdbr-command:print unique_unique.value
18 // gdbr-command:print unique_unique.next.val.value
21 // gdb-command:print vec_unique[0].value
23 // gdbr-command:print vec_unique[0].next.val.value
26 // gdbr-command:print borrowed_unique.value
28 // gdbr-command:print borrowed_unique.next.val.value
32 // gdb-command:print long_cycle1.value
34 // gdbr-command:print long_cycle1.next.value
36 // gdbr-command:print long_cycle1.next.next.value
38 // gdbr-command:print long_cycle1.next.next.next.value
41 // gdb-command:print long_cycle2.value
43 // gdbr-command:print long_cycle2.next.value
45 // gdbr-command:print long_cycle2.next.next.value
48 // gdb-command:print long_cycle3.value
50 // gdbr-command:print long_cycle3.next.value
53 // gdb-command:print long_cycle4.value
54 // gdb-check:$18 = 29.5
56 // gdbr-command:print long_cycle_w_anonymous_types.value
59 // gdbr-command:print long_cycle_w_anonymous_types.next.val.value
62 // gdb-command:continue
64 #![allow(unused_variables)]
65 #![feature(box_syntax)]
66 #![feature(omit_gdb_pretty_printer_section)]
67 #![omit_gdb_pretty_printer_section]
69 use self::Opt::{Empty, Val};
76 struct UniqueNode<T> {
77 next: Opt<Box<UniqueNode<T>>>,
81 struct LongCycle1<T> {
82 next: Box<LongCycle2<T>>,
86 struct LongCycle2<T> {
87 next: Box<LongCycle3<T>>,
91 struct LongCycle3<T> {
92 next: Box<LongCycle4<T>>,
96 struct LongCycle4<T> {
97 next: Option<Box<LongCycle1<T>>>,
101 struct LongCycleWithAnonymousTypes {
102 next: Opt<Box<Box<Box<Box<Box<LongCycleWithAnonymousTypes>>>>>>,
106 // This test case makes sure that recursive structs are properly described. The Node structs are
107 // generic so that we can have a new type (that newly needs to be described) for the different
108 // cases. The potential problem with recursive types is that the DI generation algorithm gets
109 // trapped in an endless loop. To make sure, we actually test this in the different cases, we have
110 // to operate on a new type each time, otherwise we would just hit the DI cache for all but the
113 // The different cases below (stack_*, unique_*, box_*, etc) are set up so that the type description
114 // algorithm will enter the type reference cycle that is created by a recursive definition from a
115 // different context each time.
117 // The "long cycle" cases are constructed to span a longer, indirect recursion cycle between types.
118 // The different locals will cause the DI algorithm to enter the type reference cycle at different
122 let stack_unique: UniqueNode<u16> = UniqueNode {
124 val: box UniqueNode {
132 let unique_unique: Box<UniqueNode<u32>> = box UniqueNode {
134 val: box UniqueNode {
142 let vec_unique: [UniqueNode<f32>; 1] = [UniqueNode {
144 val: box UniqueNode {
152 let borrowed_unique: &UniqueNode<f64> = &UniqueNode {
154 val: box UniqueNode {
163 let long_cycle1: LongCycle1<u16> = LongCycle1 {
164 next: box LongCycle2 {
165 next: box LongCycle3 {
166 next: box LongCycle4 {
177 let long_cycle2: LongCycle2<u32> = LongCycle2 {
178 next: box LongCycle3 {
179 next: box LongCycle4 {
188 let long_cycle3: LongCycle3<u64> = LongCycle3 {
189 next: box LongCycle4 {
196 let long_cycle4: LongCycle4<f32> = LongCycle4 {
201 // It's important that LongCycleWithAnonymousTypes is encountered only at the end of the
203 let long_cycle_w_anonymous_types = box box box box box LongCycleWithAnonymousTypes {
205 val: box box box box box LongCycleWithAnonymousTypes {